当前位置:编程学习 > wap >>

ios的push实现

证书什么的下面两个参考链接写的非常不错:
 

需要注意的是,警告通知其实是自己弹出来的,具体的流程如下:


而且push消息有自己比较独特的json格式,apple的api说的很清楚:http://developer.apple.com/library/ios/#documentation/NetworkingInternet/Conceptual/RemoteNotificationsPG/ApplePushService/ApplePushService.html#//apple_ref/doc/uid/TP40008194-CH100-SW10
{
    "aps" : { "alert" : "Message received from Bob" },
    "acme2" : [ "bang",  "whiz" ]
}
github里面找到一个开源的apple push server:https://github.com/stefanhafeneger/PushMeBaby
使用很简单
1.将自己的cer文件(obj c上不用p12文件)导入工程
2.修改初始化语句
- (id)init {
self = [super init];
if(self != nil) {
self.deviceToken = @"94b77ce5 bca83eb2 af0b0827 a7bbs633 3efc6ffdd e4fdw20a dd8cd2d7 5222c2e2";
//设置device token,
-(void)application:(UIApplication *)application didRegisterForRemoteNotificationsWithDeviceToken:(NSData *)deviceToken获取到的
self.payload = @"{\"aps\":{\"alert\":\"This is some fancy message.\",\"badge\":1}}";
///设置alert信息
self.certificate = [[NSBundle mainBundle] pathForResource:@"aps_development" ofType:@"cer"];
//设置证书路径
}
return self;
}
3.运行

good luck

 

补充:移动开发 , IOS ,
CopyRight © 2012 站长网 编程知识问答 www.zzzyk.com All Rights Reserved
部份技术文章来自网络,