There are three remote message push processing scenarios: The app is not running, the app is running in the foreground, and the app is running in the background, below is a description of the related process and three scenarios
1. Process
(1) Registration notice
The first is to register a remote message push, and it is necessary to note that the registration method changes in the IOS8 and later systems (and the certificate settings and push permissions need to be turned on). The purpose of this step is to allow the app to receive remote message push.
(2) Binding Devicetoken
Devicetoken is equivalent to a device identification, the server based on this identity for message push.
① when the user agrees that the app receives the remote message push, the hand takes the opportunity to initiate a request to APNs to obtain the Devicetoken;
②apns receives the request, according to its corresponding flow and the algorithm sends the corresponding devicetoken to the handset;
③ mobile phone will be passed to the Devicetoken app;
④app then send the Devicetoken to the backend server for saving.
After the background server is based on Devicetoken send push message to Apns,apns and then according to Devicetoken will be pushed to the corresponding equipment, equipment, and then evoke the app, show the push from the message.
(3) Processing for remote push messages
Remote push message sent over, the point of the message will often have some targeted processing or flow, the most common is the jump page, etc., here no longer expand, the following will be introduced under different scenarios received after the push processing steps.
2. The process of pushing messages under different scenarios
(1) The app receives a push when it runs in the foreground
The "Didreceiveremotenotification" method is invoked, and the data pushed is in the userinfo for processing.
(2) When app exits to background state, it receives push
Notice on the screen will appear, if the point to open the message into the App,app run to the foreground will call the "Didreceiveremotenotification" method, which is why to distinguish between the reasons for the ApplicationState, Because both are handled through this step.
(3) The app is in the off state when it receives a push
The same screen on the notice reminder, click on the message into the app, start "Didfinishlaunchingwithoptions" The launchoptions corresponding to the Uiapplicationlaunchoptionsremotenotificationkey part of the method is no longer empty and contains the push content, which is for processing.
3. Other
(1) Remote message push when network condition is bad
If the phone is not on the net, APNs will have a QoS for the message to save a very short time, such as mobile phone in the net to push over, of course, offline time is long, the message will not be received, but in reality it seems that the network is not good when generally received.
If the mobile phone is offline, the server pushed more than one message, the instant on-line received the message, will only receive the latest one
(2) content format for push
Push the content has a fixed format and length, including title (added after iOS8.2), body, sound, etc., if the local does not set the corresponding sound file, sound value for default, received when the push sounded is the default beep, And the length of the push message is limited to 256 bytes (this limit is magnified to 2kb in iOS8), specifically referring to the Notification payload section of the local and Remote Notification Programming Guide.
This article has been organized into the "iOS push Tutorial", welcome to learn to read.
The above is the entire content of this article, I hope to help you learn, but also hope that we support the cloud habitat community.