2025-02-15

證書什麼的下面兩個參考鏈接寫的非常不錯:
 

需要註意的是,警告通知其實是自己彈出來的,具體的流程如下:


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

 

發佈留言

發佈留言必須填寫的電子郵件地址不會公開。 必填欄位標示為 *