iOS8推送消息、註冊通知

1、ios-push-notifications

https://parse.com/tutorials/ios-push-notifications

2、iOS8推送消息的快速回復處理

http://blog.csdn.net/yujianxiang666/article/details/35260135

3、iOS8註冊通知

http://blog.csdn.net/apple_app/article/details/39228221

4、Device token的獲得和改變詳解 

Device token for an iPhone device生成之後就永遠不變嗎?

不是if a device is wiped (應該是重裝系), it will get a new device token. 

官方網站是這樣寫的: If the user restores backup data to a new device or computer, or reinstalls the operating system, the device token changes

正是因爲device有可能改變,所以建議在app start時(即在didFinishLaunchingWithOptions  裏)調用registerForRemoteNotificationTypes來獲取device token以檢查device token是否改變,如果改變了就應該把新token傳給push provider。(官方描述:An application should register every time it launches and give its provider the current token)

device token應該存儲在NSUserDefaults來達到新舊比較的目的

那麼舊device token在push provider對應的record怎麼辦?

方案1:把舊device token send to provider and request delete record

方案2:使用apns feedback service。

方案2可能更好些,因爲總是需要使用apns feedback service來處理用戶在device裏刪除app的情況。

調用registerForRemoteNotificationTypes方法後,成功註冊後,APNS就會返回一個device token,然後回調delegate methoddidRegisterForRemoteNotificationsWithDeviceToken, 如果註冊失敗,則回調delegate method didFailToRegisterForRemoteNotificationsWithError。

注意:

* 在第一次調用registerForRemoteNotificationTypes方法沒有聯網,則既不會調用didRegisterForRemoteNotificationsWithDeviceToken,也不會調用didFailToRegisterForRemoteNotificationsWithError

*第一次調用registerForRemoteNotificationTypes註冊成功後,之後即使沒有聯網,再調用registerForRemoteNotificationTypes時都會以最上一次的device token作爲參數回調didRegisterForRemoteNotificationsWithDeviceToken方法。

(官方描述) If your application has previously registered, calling registerForRemoteNotificationTypes: results in the operating system passing the device token to the delegate immediately without incurring additional overhead.

上述東東參考官方網站關於Registering for Remote Notifications的講解


發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章