Notes on Aurora push

Source: Internet
Author: User

Notes on Aurora push

Principle: Push is a persistent connection established on all Apple devices connected to an Apple Server. The concept of persistent connections is relative to short connections, persistent connections can send messages to clients, ensuring the timeliness of data. Send messages to clients through persistent connections between Apple devices and Apple's APNS servers. First, the Apple App needs to register the notification, and then sends the device's UDID and the app's boundle id together to the Apple Server. After the Apple Server obtains these two items, generate a device token and return it to the application server. The application server then saves the token. The application server needs to configure the APNS push certificate. When pushing the certificate, go to the background to query the deviceToken of the target device, and send the message and deviceToken together to the Apple Server.

 

Certificate: certificates can be divided into development certificates and production certificates. In my project, Aurora push and license are used.

 

Summary in the development process: first, it is common to integrate Aurora push, register registionid, and so on. Then I do this, which is divided into how the application receives the push at the front-end, when the application is in the background (that is, switching to the desktop, but does not kill the application), how does one receive the push? When the application is not started (double-click the home Key and remove the application from the background) what should I do if I receive the push.

Exit status of program not started:

At this time, the system receives the PUSH message, and calls either by clicking the PUSH message to start the application or by clicking the application icon to start the application.

  - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:  

This method is used to start the program. The difference between the two is that clicking push message to start the application will pass the pushed message userInfo through the launchOptions parameter.

  if (launchOptions) {

  NSDictionary *dicUserInfo = [launchOptions objectForKey:UIApplicationLaunchOptionsRemoteNotificationKey];

  }

This parameter can be used to determine whether the application is started by clicking push messages. LaunchOptions has several keys:

  • UIApplicationLaunchOptionsRemoteNotificationKey returns a remotely pushed userInfo dictionary type parameter;
  • UIApplicationLaunchOptionsLocalNotificationKey returns a UILocalNotificat
    Ion object;

However, if you click the application icon to start the program, you cannot push details. If you want to click the icon to start the program, you can only cache this message on your own server, write an interface. After the interface is started. applicationIconBadgeNumber can get the number of notifications, and the didfinishilaunchiingwitexceptions method can call this interface and perform related processing to make corresponding results.

 

The app receives the push at the front end and the app receives the push at the backend:

Here I will talk about it together. You can get the notification details when you click the application icon or when the notification banners are started, all of which can be obtained in the uerInfo parameter.

  - (void)application:(UIApplication *)application didReceiveRemoteNotification: (NSDictionary *)userInfo fetchCompletionHandler:(void (^)(UIBackgroundFetchResult result))completionHandler NS_AVAILABLE_IOS(7_0) __TVOS_PROHIBITED;

  - (void)application:(UIApplication *)application didReceiveRemoteNotification:(NSDictionary *)userInfo NS_AVAILABLE_IOS(3_0) __TVOS_PROHIBITED;

  

The above is the new method added after ios 7. If the above method is implemented, the following will be overwritten and will not be executed. This method has the following features: when the program runs on the foreground and receives a remote push, this method is called immediately. However, if the program is suspended in the background, the method is not executed when the message is received (when the PUSH message is not clicked). If you want to execute some code when you need to receive the message, you can add it to the aps dictionary when the server sends the message to APNS.

Apn = {content-available = 1;}

This field will immediately execute the above method when the application receives the PUSH message when it is suspended in the background. Of course, when you click push message again, it will be executed again (these two cases can be differentiated based on the applicationState attribute), and the following method will only push messages after clicking, or the application is called only when the message is received by the application at the front-end. If you want to receive push messages when the application is running on the frontend, I want the application to run on the frontend and receive push messages, the local notification does not have a banner prompt. If you want this prompt, you can customize a view for display.

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.