ios push notification 使用

來源:互聯網
上載者:User

push notification 使用:

 

參考資源:

http://tiny4cocoa.com/thread-1406-1-1.html

http://bbs.ldci.com.cn/read.php?tid-19971.html

http://www.cocoachina.com/bbs/read.php?tid-3770-keyword-apns.html

http://code.google.com/p/apns-python-wrapper/

http://urbanairship.com/

http://urbanairship.com/docs/getting_started_ios_push.html 

用戶端:

程式上的準備:device token 需要傳給provider

- (void)applicationDidFinishLaunching:(UIApplication *)application {

[window addSubview:viewController.view];

[window makeKeyAndVisible];

NSLog(@"Registering for push notifications...");

[[UIApplication sharedApplication]

registerForRemoteNotificationTypes:

(UIRemoteNotificationTypeAlert |

UIRemoteNotificationTypeBadge |

UIRemoteNotificationTypeSound)];

application.applicationIconBadgeNumber = 0; //程式開啟,設定UIRemoteNotificationTypeBadge標識為0

}

 

- (void)application:(UIApplication *)app didRegisterForRemoteNotificationsWithDeviceToken:(NSData *)deviceToken {

NSString *str = [NSString

stringWithFormat:@"Device Token=%@",deviceToken];

NSLog(str);

}

 

必須有App ID, 且已經開啟notification功能。provision必須重建立立(在 App開啟notification功能後)。刪除原有的provision,匯入新的。

 

伺服器上的準備:

 

利用這個庫,可以簡單的構建一個伺服器:

http://code.google.com/p/apns-python-wrapper/

測試如下:

 

#!/usr/bin/env python

from APNSWrapper import *

import binascii

deviceToken = binascii.unhexlify('12f53d1bf554d0a01bd7c4f233a668e5878d99f229a76338fd7477f7f381c371');

wrapper = APNSNotificationWrapper('ck.pem', True)

message = APNSNotification()

message.token(deviceToken)

message.alert("Very simple alert")

message.badge(5)

message.sound()

wrapper.append(message)

wrapper.notify()


也可以使用第三方的伺服器:

http://urbanairship.com/

 

 

相關文章

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在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.