The difference between iOS6 and iOS7 is that repeated push is implemented.-(void) application: didReceiveRemoteNotification: fetchCompletionHandl, ios6 install ios7 Software
If you already know the basic knowledge of push, this article only addresses some adaptation and compatibility issues. If you do not know much about push, refer to the following article.
1. [Comprehensive Analysis of iOS push] (1) Overview of push
2. [Comprehensive Analysis of iOS push] (2) generate a push certificate to generate a Provisioning Profile
3. [iOS push Comprehensive Analysis] (3) A simple demo and test the push
4. Add the push code to the iOS Program
========================================================== ======
The client must handle the following three situations:
1. The client is on the frontend. Usually pop-up window ● iOS6-(void) application: didReceiveRemoteNotification: called
● IOS7-(void) application: didReceiveRemoteNotification: fetchCompletionHandler: called
Therefore, to be compatible with iOS6. the common practice is to call-(void) application: didReceiveRemoteNotification: fetchCompletionHandler: In-(void) application: didReceiveRemoteNotification: method.
● The push Processing Module checks whether the program is active [UIApplication sharedApplication]. applicationState = UIApplicationStateActive.
Then determine whether a dialog box is required.
2. The client is in the background, but it is still alive. The principle is roughly the same as that of the first one. Check whether the handling box is displayed.
3. When the client is killed, the message is pushed in, and the client is triggered by sliding (CLICKING) the message. ● IOS 6 call-(void) application: didfinishlaunchingwitexceptions: With launchDictionary, which contains push messages
You need to take a simple look and get the real content [launchOptions objectForKey: UIApplicationLaunchOptionsRemoteNotificationKey]
● Two methods are called after iOS 7:
-(Void) application: didfinishlaunchingwitexceptions:
-(Void) application: didReceiveRemoteNotification: fetchCompletionHandler:
In this way, there is a pitfall. If it is later than iOS 7, the same push message may be processed again.
[Solution]: since only iOS7 and above will call-(void) application: didReceiveRemoteNotification: fetchCompletionHandler: method.
To be compatible with iOS6, only iOS6 is processed in-(void) application: didfinishlaunchingwitexceptions.
4. The current APP has a startup graph process. If the push message is sent, the APP is in the killed state, and a startup diagram is assumed after the message is started.
In this example, push is directly processed after the APP is pulled by push, without a box.
[Solution] the first method is to save the push message, and then display the push content after the startup diagram is complete. Note that the push module will be used after the startup diagram is complete.
[UIApplication sharedApplication]. applicationState = UIApplicationStateActive is not easy to use, because the APP should be active at this time and you need to pop up the box. Therefore, the push module must support an interface that forces no dialog box.
Copyright Disclaimer: This article is an original article by the blogger and cannot be reproduced without the permission of the blogger.