Apple Push Notification服务
来源:互联网 发布:君子知怕 编辑:程序博客网 时间:2024/05/18 00:58
苹果的push notification服务是为了向用户推送消息的服务。可以向用户推送消息条,声音,还有badge条数。应用程序可以在任何状态下接受到push消息,包括(not running, background)。APNS为应用程序的交互提供了极大的便利。
7. 客户端实例程序
App delegate函数
- APNS的工作流程
用户第一次安装应用并启动时,会注册APNS服务,Apple的APNS服务器会向注册的app返回一个device token。这个device token是设备唯一的,不同的app收到的device token是一样的。
- 样例程序
1.打开keychain access,创建一个证书签名请求。
2. 填写信息并保存到磁盘
3.创建push APP ID,主要是要enable push功能
4.下载开发版本的push证书,这里需要上传在第二步生成的签名请求文件
5. 创建provisioning文件,包括测试device和App ID。
6. 把push的证书文件和私钥转化成pem格式,并合并成同一个文件。
openssl x509 -in aps_developer_identity.cer -inform der -out MyPushChatCert.pemopenssl pkcs12 -nocerts -out MyPushChatKey.pem -in MyPushChatKey.p12cat PushChatCert.pem PushChatKey.pem > ck.pem
7. 客户端实例程序
注册服务
[[UIApplication sharedApplication] registerForRemoteNotificationTypes: (UIRemoteNotificationTypeBadge | UIRemoteNotificationTypeSound | UIRemoteNotificationTypeAlert)];
- (void)application:(UIApplication*)application didRegisterForRemoteNotificationsWithDeviceToken:(NSData*)deviceToken { NSLog(@"My token is: %@", deviceToken); } - (void)application:(UIApplication*)application didFailToRegisterForRemoteNotificationsWithError:(NSError*)error { NSLog(@"Failed to get token, error: %@", error); }
8. 下载服务端php程序,并修改device token和pem文件
- Apple Push Notification服务
- iphone 推送服务--Apple Push Notification Service
- iphone 推送服务--Apple Push Notification Service
- iphone 推送服务--Apple Push Notification Service
- iphone 推送服务--Apple Push Notification Service
- iphone 推送服务--Apple Push Notification Service
- iphone 推送服务--Apple Push Notification Service
- iphone 推送服务--Apple Push Notification Service .
- iphone 推送服务--Apple Push Notification Service
- 生成Apple Push Notification Service服务证书
- iphone 推送服务--Apple Push Notification Service
- iphone 推送服务--Apple Push Notification Service
- iphone 推送服务--Apple Push Notification Service
- IOS 推送服务--Apple Push Notification Service
- Apple Push Notification Service(苹果推送服务)
- iphone 推送服务--Apple Push Notification Service
- iphone 推送服务--Apple Push Notification Service
- apple push notification 机制
- flex4数据绑定的深入理解
- Ant的安装
- 代码和架构的完美之旅
- j-tag 和j-link 关系
- 3D坐标系、矩阵变换、视景体与裁剪 (转载)
- Apple Push Notification服务
- c++基础题
- 工厂方法——设计模式系列
- IP网络电话与voip网络电话有何差异
- Java编程中常见异常问题集结 .
- Java 判断文件或者文件夹是否存在并创建新文件或者文件夹
- 直流电机选型过程
- D层次细节算法-大规模实时地形的绘制 (转载)
- cocos2d-x自定义五角星粒子效果