iOS消息推送整体流程
2014-04-17 10:42
316 查看
具体实现
一、获取推送服务认证书
该认证书 是用于服务器与APNS服务器SSL 连接时的认证,而获取p12的前提是获取APNS Assistant。
1. 在apple开发中心生成 App ID(如PushDemo),注意:Bundle Indentifier值格式必须为反向域名格式,如com.bluestar.PushDemo;
2. 单击App ID 的后面的 Configure;
3. 在新的页面中,勾选Enable Push Notification Services , 而后点击Configure ,随后出现APNs Assistant,APNs助手会引导生成你的程序与APNs服务器进行SSL连接的认证书App ID specific Client SSL certificate[注释:一般文件名为“aps_developer_identity.cer” 可修改]
4. APNs助手会引导你保存SSL certificate到你的硬盘,保存好后双击,安装到你的keychain;
5. 执行完以上四步,可以点击Done,关闭APNs助手;
6. 启动Keychain Access程序,查看刚才安装的认证,name 为apple Development/Production push Services。。。
导出--即获得Certificates.p12 保存好给Provider 服务器使用;
二、IOS应用程序开启推送服务
1. iPhone provisioning 以开启了PUSH功能App ID (如前述PushDemo)生成相应的provisioning,并下载;
2. 以前述App ID(PushDemo),创建应用程序,并指定Bundle Indentifier为注册时使用的Bundle Indentifier (本例为com.bluestar.PushDemo);
3. iPhone需要用到的方法函数如下:
//注册启用 push
[[UIApplication sharedApplication] registerForRemoteNotificationTypes:(UIRemoteNotificationTypeAlert | UIRemoteNotificationTypeBadge /*|UIRemoteNotificationTypeSound*/)];
//用该判断 程序是不是通过push消息启动的
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
//iPhone 从APNs服务器获取deviceToken后激活该方法
- (void)application:(UIApplication *)app didRegisterForRemoteNotificationsWithDeviceToken:(NSData *)deviceToken
//注册push功能失败 后 返回错误信息,执行相应的处理
- (void)application:(UIApplication *)app didFailToRegisterForRemoteNotificationsWithError:(NSError *)err
附录:使用OpenSSL转换证书格式
1. 将aps_developer_identity.cer转换成 aps_developer_identity.pem格式。
openssl x509 -in aps_developer_identity.cer -inform DER -out aps_developer_identity.pem -outform PEM
2. 将Certificates.p12格式的私钥转换成pem,需要设置4次密码,密码都设置为:abc123。
openssl pkcs12 -nocerts -out aps_developer_key.pem -in Certificates.p12
3. 用certificate和the key 创建PKCS#12格式的文件。
openssl pkcs12 -export -in aps_developer_identity.pem -inkey aps_developer_key.pem -certfile PushTest.certSigningRequest -name "aps_developer_identity" -out aps_developer_identity.p12
一、获取推送服务认证书
该认证书 是用于服务器与APNS服务器SSL 连接时的认证,而获取p12的前提是获取APNS Assistant。
1. 在apple开发中心生成 App ID(如PushDemo),注意:Bundle Indentifier值格式必须为反向域名格式,如com.bluestar.PushDemo;
2. 单击App ID 的后面的 Configure;
3. 在新的页面中,勾选Enable Push Notification Services , 而后点击Configure ,随后出现APNs Assistant,APNs助手会引导生成你的程序与APNs服务器进行SSL连接的认证书App ID specific Client SSL certificate[注释:一般文件名为“aps_developer_identity.cer” 可修改]
4. APNs助手会引导你保存SSL certificate到你的硬盘,保存好后双击,安装到你的keychain;
5. 执行完以上四步,可以点击Done,关闭APNs助手;
6. 启动Keychain Access程序,查看刚才安装的认证,name 为apple Development/Production push Services。。。
导出--即获得Certificates.p12 保存好给Provider 服务器使用;
二、IOS应用程序开启推送服务
1. iPhone provisioning 以开启了PUSH功能App ID (如前述PushDemo)生成相应的provisioning,并下载;
2. 以前述App ID(PushDemo),创建应用程序,并指定Bundle Indentifier为注册时使用的Bundle Indentifier (本例为com.bluestar.PushDemo);
3. iPhone需要用到的方法函数如下:
//注册启用 push
[[UIApplication sharedApplication] registerForRemoteNotificationTypes:(UIRemoteNotificationTypeAlert | UIRemoteNotificationTypeBadge /*|UIRemoteNotificationTypeSound*/)];
//用该判断 程序是不是通过push消息启动的
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
//iPhone 从APNs服务器获取deviceToken后激活该方法
- (void)application:(UIApplication *)app didRegisterForRemoteNotificationsWithDeviceToken:(NSData *)deviceToken
//注册push功能失败 后 返回错误信息,执行相应的处理
- (void)application:(UIApplication *)app didFailToRegisterForRemoteNotificationsWithError:(NSError *)err
附录:使用OpenSSL转换证书格式
1. 将aps_developer_identity.cer转换成 aps_developer_identity.pem格式。
openssl x509 -in aps_developer_identity.cer -inform DER -out aps_developer_identity.pem -outform PEM
2. 将Certificates.p12格式的私钥转换成pem,需要设置4次密码,密码都设置为:abc123。
openssl pkcs12 -nocerts -out aps_developer_key.pem -in Certificates.p12
3. 用certificate和the key 创建PKCS#12格式的文件。
openssl pkcs12 -export -in aps_developer_identity.pem -inkey aps_developer_key.pem -certfile PushTest.certSigningRequest -name "aps_developer_identity" -out aps_developer_identity.p12
相关文章推荐
- iOS—接收到APNs远程推送消息时的处理流程
- iOS中swift3.0集成友盟消息推送流程
- iOS消息推送大致流程
- IOS消息推送流程
- iOS 简述消息推送流程
- IOS开发 消息推送机制和流程以及客户端和服务器代码
- ios 消息推送流程 转载
- iOS6.0 消息推送的原理与实现
- IOS消息推送之APNS
- iOS开发如何实现消息推送机制
- iOS远程消息推送(信鸽推送平台)
- IOS远程消息推送
- iOS消息推送机制的实现
- 基于APNs最新HTTP/2接口实现iOS的高性能消息推送(服务端篇)
- iOS 【极光推送】第一次打开app,收不到推送消息
- iOS 消息推送通知
- ios开发: APNS消息推送实现
- iOS开发,推送消息 steps
- IOS消息推送之APNS
- ios的消息推送,Java实现的