ios的push实现

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

http://luoyl.info/blog/2012/02/apple_push_notification_guide/

http://blog.sina.com.cn/s/blog_4c925dca01010tmp.html


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



而且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






  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值