原理
APNS:Apple Push Notification Service
摘錄raywenderlich.com的一張圖:
20150603145448807.jpg
- An app enables push notifications. The user has to confirm that he wishes to receive these notifications.
- The app receives a “device token”. You can think of the device token as the address that push notifications will be sent to.
- The app sends the device token to your server.
- When something of interest to your app happens, the server sends a push notification to the Apple Push Notification Service, or APNS for short.
- APNS sends the push notification to the user’s device.
Certificate(認(rèn)證)
需要將自己的app在Apple官方認(rèn)證,流程參見:parse.com/tutorial 不要被那冗長(zhǎng)的過(guò)程嚇倒哦 :)
第三方服務(wù)選型
全能型(聲稱“為App提供一站式后臺(tái)服務(wù)”)。目前覺得,沒有必要用這么全能的服務(wù),雖然這些服務(wù)都免費(fèi)。
parse.com (國(guó)外的)
leancloud.cn (國(guó)內(nèi)的)
僅推送服務(wù)。國(guó)內(nèi)有多家提供該服務(wù)的平臺(tái),讓人眼花(見評(píng)論文章 )。最終選擇了極光推送,主要因?yàn)閣ealon原來(lái)公司項(xiàng)目用的是這個(gè)。
IM消息 與 推送
極光推送等提供的服務(wù)是“向所有/部分用戶發(fā)一條通知/廣告”等,相當(dāng)于村委會(huì)“大喇叭”的作用。而融云等提供的則是即時(shí)通訊服務(wù),是“點(diǎn)對(duì)點(diǎn)”的消息,相當(dāng)于“打電話”。融云的服務(wù)似乎更復(fù)雜一些。
另外,IM消息的推送(如微信/qq那樣的收到一條消息就“叮叮咚”)也是用的APNS這條路。(簡(jiǎn)單看了一下融云的文檔,也要求上傳一個(gè)認(rèn)證的文件[跟極光推送要求上傳的文件一樣],從這一點(diǎn)可以看出來(lái)是APNS)。