APNs(英文全称:Apple Push Notification service)Demo与实践
1.将用到的工具 Easy APNs Peovider
2.操作步骤
一些准备工作
1.建立一个Xcode工程 我将其命名为SJAPNSdemo
2.一个测试机(自己的手机)因为APNS只能在实体设备上工作
3.在apple developer官网上申请一个APP ID并使其与自身项目的Bundle identifier 相一致
。
证书的准备与下载
1.LaunchPad -> 其他 -> 钥匙串访问 在左上方钥匙串访问一栏中选择证书助理->从证书颁发机构请求证书
2.在对话框中的常用名称中填入SJAPNSdemo并在”请求是:”一栏中选择存储到磁盘
image
3.得到一个名为CertificateSigningRequest.certSigningRequest的文件 将其保存在桌面
4.在apple developer官网找到自己所申请的app id后点开下方的edit。并在Push Notifications一栏下的Development SSL Certificate 和 Production SSL Certificate分别Creat a Certificate 点击continue之后上传前面生成CertificateSigningRequest.certSigningRequest文件并等待生成完成后下载到妥善位置保存
5.在apple developer官网找到Provisioning Profiles新建一个iOS App Development的provisioning profile并下载打开 成功后会出现在xcode的preferences中自身account的view details目录下的Provisioning Profiles中
6获取本机token
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
[[UIApplication sharedApplication] registerUserNotificationSettings:[UIUserNotificationSettings settingsForTypes:UIUserNotificationTypeAlert|UIUserNotificationTypeBadge|UIUserNotificationTypeSound categories:nil]];
[[UIApplication sharedApplication] registerForRemoteNotifications];
return YES;
}
- (void)application:(UIApplication*)application didRegisterForRemoteNotificationsWithDeviceToken:(NSData*)deviceToken
{
NSLog(@"My token is: %@", deviceToken);
}
7 填入工具Easy APNs Peovider
并按教程使用
最后
以上就是虚幻黄蜂最近收集整理的关于APNs(英文全称:Apple Push Notification service)Demo与实践的全部内容,更多相关APNs(英文全称:Apple内容请搜索靠谱客的其他文章。
发表评论 取消回复