標籤:os io art for re c
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.
假如使用者手機不線上,可能沒有訊號或者關機吧,APNs會儲存轉寄,等使用者線上時再發送
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.
如果使用者不線上,通知會合并,只會保留最新的一條。假如你給使用者發了兩條通知,但使用者反饋說,只收到了一條,那麼很可能是使用者當時不線上,APNs的合并策略生效,只保留了最近一條
3.If the device remains offline for a long time, any notifications that were being stored for it are discarded
4.The maximum size allowed for a notification payload is 256 bytes; Apple Push Notification Service refuses any notification that exceeds this limit.
這個很重要,payload,就是最後產生的那段Json,不得超過256位元組。如果超過了,建議去掉一些不需要的參數,把alert,就是提示資訊的字數減少
5.don’t repeatedly open and close connections. APNs treats rapid connection and disconnection as a denial-of-service attack.
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。
只有把這些搞清楚,才方便我們理解蘋果推送的規則,知道自己推送上的一些不足之處