認證什麼的下面兩個參考連結寫的非常不錯:
需要注意的是,警告通知其實是自己彈出來的,具體的流程如下:
而且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