ios的push實現

來源:互聯網
上載者:User

認證什麼的下面兩個參考連結寫的非常不錯:
 

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


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

 

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.