iOS 远程推送
2015-10-02 16:30
441 查看
(http://img.blog.csdn.net/20151002162027055)
iOS远程通知:
1、后台推送通知到苹果服务器(APNS)
2、苹果服务器(APNS)把通知发送到苹果手机端
3、手机接收通知
1)、后台推送通知到苹果服务器(APNS)
下载一个APNS的证书, 用PHP写的后台 是.pem文件 如果是java/.net.p12
1、下载APNS证书:一个应用必须要有一个与他对应的证书bundleID
(1)申请APNS证书的时候 需要填写一个appID与app的bundleID对应
https://developer.apple.com/
这个证书可以通过我们前面生成的两个文件中得到。
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、将p12格式的私钥转换成pem
openssl pkcs12 -nocerts -out Push_Noenc.pem -in Push.p12
3、创建p12文件
openssl pkcs12 -export -in aps_developer_identity.pem -inkey Push_Noenc.pem -certfile Push.certSigningRequest -name “aps_developer_identity” -out aps_developer_identity.p12
这样我们就得到了在.net或java等后台应用程序中使用的证书文件:aps_developer_identity.p12
二、苹果服务器(APNS)把通知发送到苹果手机端
需要提供给后台服务器一个deviceToken号 以及通知的内容一同发送给苹果服务器
iOS添加代码如下:
三、手机接收通知
1、注册通知
if ([[[UIDevice currentDevice] systemVersion] floatValue] >= 8.0) {
添加到didFinishLaunchingWithOptions
2、应用程序内部 提示通知
当接受到远程通知 就会自动调用
-(void)application:(UIApplication )application didReceiveRemoteNotification:(NSDictionary )userInfo{
userInfo 包含了 具体通知的内容
}
全部搞定之后 还需设置XCode
这个证书可以通过我们前面生成的两个文件中得到。
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、将p12格式的私钥转换成pem
openssl pkcs12 -nocerts -out Push_Noenc.pem -in Push.p12
3、创建p12文件
openssl pkcs12 -export -in aps_developer_identity.pem -inkey Push_Noenc.pem -certfile Push.certSigningRequest -name “aps_developer_identity” -out aps_developer_identity.p12
这样我们就得到了在.net或java等后台应用程序中使用的证书文件:aps_developer_identity.p12
iOS远程通知:
1、后台推送通知到苹果服务器(APNS)
2、苹果服务器(APNS)把通知发送到苹果手机端
3、手机接收通知
1)、后台推送通知到苹果服务器(APNS)
下载一个APNS的证书, 用PHP写的后台 是.pem文件 如果是java/.net.p12
1、下载APNS证书:一个应用必须要有一个与他对应的证书bundleID
(1)申请APNS证书的时候 需要填写一个appID与app的bundleID对应
https://developer.apple.com/
这个证书可以通过我们前面生成的两个文件中得到。
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、将p12格式的私钥转换成pem
openssl pkcs12 -nocerts -out Push_Noenc.pem -in Push.p12
3、创建p12文件
openssl pkcs12 -export -in aps_developer_identity.pem -inkey Push_Noenc.pem -certfile Push.certSigningRequest -name “aps_developer_identity” -out aps_developer_identity.p12
这样我们就得到了在.net或java等后台应用程序中使用的证书文件:aps_developer_identity.p12
二、苹果服务器(APNS)把通知发送到苹果手机端
需要提供给后台服务器一个deviceToken号 以及通知的内容一同发送给苹果服务器
iOS添加代码如下:
三、手机接收通知
1、注册通知
if ([[[UIDevice currentDevice] systemVersion] floatValue] >= 8.0) {
UIMutableUserNotificationCategory *categorys = [[UIMutableUserNotificationCategory alloc]init]; categorys.identifier=@"Bruce.com.Where"; UIUserNotificationSettings *userNotifiSetting = [UIUserNotificationSettings settingsForTypes:(UIUserNotificationTypeAlert|UIUserNotificationTypeBadge|UIUserNotificationTypeSound) categories:[NSSet setWithObjects:categorys,nil]]; [[UIApplication sharedApplication] registerUserNotificationSettings:userNotifiSetting]; [[UIApplication sharedApplication] registerForRemoteNotifications]; }else { //注册远程推送 [[UIApplication sharedApplication] registerForRemoteNotificationTypes:(UIRemoteNotificationTypeBadge | UIRemoteNotificationTypeSound | UIRemoteNotificationTypeAlert)]; }
添加到didFinishLaunchingWithOptions
2、应用程序内部 提示通知
当接受到远程通知 就会自动调用
-(void)application:(UIApplication )application didReceiveRemoteNotification:(NSDictionary )userInfo{
userInfo 包含了 具体通知的内容
}
全部搞定之后 还需设置XCode
这个证书可以通过我们前面生成的两个文件中得到。
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、将p12格式的私钥转换成pem
openssl pkcs12 -nocerts -out Push_Noenc.pem -in Push.p12
3、创建p12文件
openssl pkcs12 -export -in aps_developer_identity.pem -inkey Push_Noenc.pem -certfile Push.certSigningRequest -name “aps_developer_identity” -out aps_developer_identity.p12
这样我们就得到了在.net或java等后台应用程序中使用的证书文件:aps_developer_identity.p12
相关文章推荐
- ios动画
- mac Xcode/iOS license
- IOS视图切换
- iOS 多线程的使用(GCD)
- iOS 多线程的使用(Operation)
- iOS 多线程实例(自定义NSOperation并传值(block,notification))
- iOS 多线程实例(NSThread售票窗口的模拟)
- iOS开发TTS技术即文本转语音
- iOS多线程使用实例(异步下载图片的时候不会阻塞主线程的执行)
- iOS导航栏的颜色和电池颜色的修改
- IOS—静态方法(类方法)和实例方法
- IOS实时预览自定义控件效果
- iOS编程规范
- iOS动力效果
- IOS使用自带的API绘制一个加载进度的圆圈
- IOS对象关系映射(ORM)之coreData框架的学习——(三)对使用步骤进行方法封装
- iOS pragma mark要使用
- Xcode 5 + iOS 7免证书(iDP)真机调试与生成IPA全攻略
- XCode6.0 的iOS免证书真机测试方法
- [IOS]Xcode7免开发者帐号真机调试运行程序