English | 简体中文 | 繁體中文 | Русский язык | Français | Español | Português | Deutsch | 日本語 | 한국어 | Italiano | بالعربية
There are three scenarios for remote message push processing: the app is not running, the app is running in the foreground, and the app is running in the background. Below, we will introduce the relevant process and steps to handle the three scenarios.
1.Process
(1Register notifications
Firstly, it is to register for remote message push notifications, and it should be noted that iOS8And the registration method in the system has changed since then (the certificate settings and push permissions also need to be enabled). The purpose of this step is to allow the app to receive remote message push notifications.
(2Binding deviceToken
The deviceToken is like an identifier for the device, and the server uses this identifier to push messages.
① After the user agrees to the app receiving remote message push notifications, the phone will send a request to APNs to obtain the deviceToken;
② APNs will receive the request and send the corresponding deviceToken to the phone according to its respective process and algorithm;
③ The phone will then pass the deviceToken to the app;
④ The app will then send the deviceToken to the background server for storage.
The background server will then send push messages to APNs based on the deviceToken, and APNs will push the messages to the corresponding devices based on the deviceToken. The device will then launch the app and display the push messages.
(3Push processing for remote push messages
When a remote push message is received, tapping on the message often involves some targeted processing or workflow, the most common being page jumps, etc., which will not be expanded here. Below, we will introduce the steps to handle push notifications received in different scenarios.
2.Process flow of push messages in different scenarios
(1
The
(2
A notification will appear on the screen, and if you tap on the message to enter the app, the app will call the
(3) when the app is in the closed and exited state and receives a push
The same notification reminder will appear on the screen, open the message to enter the app, and the 'didFinishLaunchingWithOptions' method in the launchOptions corresponds to the 'UIApplicationLaunchOptionsRemoteNotificationKey' part will no longer be empty. The content contained is the push content, and the handling can be done accordingly.
3. Other
(1) remote message push situation when the network is poor
If the phone is not connected to the Internet, APNs will have a QoS feature to save messages for a short time, and then push them when the phone is online. Of course, if the offline time is too long, the messages will not be received. But in actual discovery, it seems that when the network is poor, messages are generally not received.
If the phone is offline when the server pushes multiple messages, even if it goes online immediately, it will only receive the latest one
(2) push content format
The content of the push has a fixed format and length, including title (iOS8.2added later), body, sound, etc. If there is no corresponding sound file set locally, the sound value is default, and the default prompt sound will ring when receiving the push, and the length limit of the push message is256bytes (iOS8This restriction is expanded to2kb), please refer to the 'Notification Payload' section in Local and Remote Notification Programming Guide.
This article has been organized into 'iOS Push Tutorial', welcome to learn and read.
That's all for the content of this article. I hope it will be helpful to everyone's learning, and I also hope everyone will support the Naying Tutorial more.
Statement: The content of this article is from the Internet, and the copyright belongs to the original author. The content is contributed and uploaded by Internet users, and this website does not own the copyright, has not been edited by humans, and does not bear relevant legal liabilities. If you find any content suspected of copyright infringement, please send an email to: notice#w3Please send an email to codebox.com (replace # with @ when sending emails) to report any infringement, and provide relevant evidence. Once verified, this site will immediately delete the infringing content.