1. If APNs attempts to deliver a notification but the device is offline, the notification is stored for a limited period of time, and delivered to the device when it becomes available.api
假如用戶手機不在線。可能沒有信號或者關機吧。APNs會存儲轉發。等用戶在線時再發送app
2.Only one recent notification for a particular application is stored. If multiple notifications are sent while the device is offline, each new notification causes the prior notification to be discarded. This behavior of keeping only the newest notification is referred to as coalescing notifications.ide
假設用戶不在線,通知會合並,僅僅會保留最新的一條。post
假如你給用戶發了兩條通知,但用戶反饋說。僅僅收到了一條,那麼很是多是用戶當時不在線,APNs的合併策略生效。僅僅保留了近期一條this
3.If the device remains offline for a long time, any notifications that were being stored for it are discardedcode
4.The maximum size allowed for a notification payload is 256 bytes; Apple Push Notification Service refuses any notification that exceeds this limit.orm
這個很是重要。payload。就是最後生成的那段Json。不得超過256字節。token
假設超過了,建議去掉一些不需要的參數,把alert,就是提示信息的字數下降接口
5.don’t repeatedly open and close connections. APNs treats rapid connection and disconnection as a denial-of-service attack.ip
6.If you send a notification that is accepted by APNs, nothing is returned.
發送成功的木有返回,僅僅有發送失敗的纔會返回
7.If you send a notification that is malformed or otherwise unintelligible, APNs returns an error-response packet and closes the connection. Any notifications that you sent after the malformed notification using the same connection are discarded, and must be resent.
這條很是重要,假設有error-response,那麼這條以後的通知都需要重發。有很是多開源的庫。在發蘋果通知時都沒有檢測error-response,假設你不當心用了。那麼用戶很是可能反饋「怎麼沒有通知啊」
8.The notification identifier in the error response indicates the last notification that was successfully sent(實際狀況不是,實際上返回的是出錯的那條通知的ID). Any notifications you sent after it have been discarded and must be resent.When you receive this status code, stop using this connection and open a new connection.
這是對上一條的補充。假設出錯了,需要關閉當前的鏈接,並且又一次鏈接再發。error-response中返回的通知ID。可以幫助咱們找出哪條出錯了,這樣就能知道哪些需要重發了
9.When a push notification cannot be delivered because the intended app does not exist on the device, the feedback service adds that device’s token to its list.
APNS的feedback service會返回那些已經卸載的設備的token--device_token。存儲這些token。下次就不用再給他們發了,可以節省點資源。需要注意的是:feedback的接口讀取一次,APNS就會清空它的列表。下次再讀取時,返回的就是這兩次讀取之間這段時間新產生的device_token。
僅僅有把這些搞清楚。才方便咱們理解蘋果推送的規則,知道本身推送上的一些不足之處