Aurora Push Combat Experience

Source: Internet
Author: User

Recently the company's project added a message center function, using the Aurora push, now the project is online, share the feeling of doing this function. Bad writing, I hope you will correct me.

First step: Integrated Aurora SDK

Integrated Aurora Documentation The main step is to follow the Aurora documentation, import some system frameworks, add Aurora's. A files and polar bald files, and add code where appropriate. Add code Aurora documents are written in detail, Aurora also has cases, can refer to the case

Step two: Create an app, or Appkey

To create an app, you need to log in to your Aurora account (without registering one), create an app to the console, and fill in the appropriate information for your application. It involves the development environment and the development environment of the P12 file, which needs to go to the Apple developer platform to configure the push certificate, I have a URL http://jingyan.baidu.com/article/5d6edee20f3ae599eadeec35.html here. Push certificate is configured after downloading, the double-click will be placed in the keychain, in the keychain, select the Push Certificate right button, there is an export option, after export is the P12 file, this time you can choose. Once you've created your app, you'll get a appkey, which you'll need to use in your program's didfinishlaunchingwithoptions integrated Aurora code. The Aurora push is also integrated, and can be tested in the background of the aurora. Push is based on the program bundle ID to identify an app, so when you create an app on the Aurora and configure the certificate when the bundle ID must be consistent with the program bundle ID

Step three: Click the notification bar for page jumps

The purpose of push is to increase the user's activity, so push push to the user's mobile phone, click on the notification bar should be the corresponding page jump. Page jump design to the inside of the program, each program structure and content are different, so I do not do a detailed introduction. Let me explain how I did the page jump. First, the backend developers will give the client what fields they have pushed, what the fields represent, and what they do. When you click on the notification bar, this data will be passed over, and there are several empties.

The first program did not kill, the app in the background, and the phone system is below 10.0, click on the notification bar will call the following method, the background push data will be included in the dictionary UserInfo

-(void) Application: (uiapplication *) application didreceiveremotenotification: (nsdictionary *) UserInfo Fetchcompletionhandler: (void (^) (uibackgroundfetchresult)) Completionhandler

more than 10.0 of the system calls the following method, the background pushes the data contained in the Response. notification. Request. Content. UserInfo inside

-(void) Jpushnotificationcenter: (unusernotificationcenter *) Center

Didreceivenotificationresponse: (unnotificationresponse *) Response

Withcompletionhandler: (void (^) ()) Completionhandler

The second program did not kill, the app in the foreground, this situation we do not consider, because the app in the foreground is usually not the interface to jump

The third situation is that the program killed, click on the notification bar will call the Didfinishlaunchingwithoptions method, the background pushes the data contained in launchoptions[Uiapplicationlaunchoptionsremotenotificationkey], Launchoptions in this uiapplicationlaunchoptionsremotenotificationkey field of this dictionary

We need to do the interface jump, as well as the data display, then we must save the data, my practice is to define a simple interest model, in KVC way, to assign values to the model, the data saved to a singleton model. Then jump, you can notify the way, in the app home page to receive notifications, all in the homepage to the interface jump, because the home must be present (app login to exit this period). The method of notifying the observer is then implemented, and the page jumps according to the data of the push data model.

Speaking of which, I have to raise two more serious problems that I have encountered in the development.

1. Page jumps multiple times continuously

2. When the program kills, receive notification, click on the notification bar can not jump

The first question jumps multiple times because it notifies the observer that there is no removal. may be related to my project framework, our project framework is from the landing controller push to the Tabbar controller, which may lead to the home controller is not destroyed in time after the landing, and then landing again, the home on the registration of two notice observers, will lead to repeat the emptying of the jump, So tell the observer to remember to remove and push the data simple interest the value of the model should also be emptied after exiting the login

The second problem procedure kills the receipt of notifications, which involves the life cycle of the program. Program killed, received notification, click on the notification bar to enter the Didfinishlaunchingwithoptions this method, push the data is also stored in this method. Then the program launches into the homepage (because the program will definitely go to the homepage after killing, so here does not send the notice), on the home page we manually in the receiving push notification after the implementation of the method of the interface jump, of course, in this method needs to make judgments, Determine whether the value of one of the properties of a singleton model is empty (this value must be guaranteed to be non-empty when pushed), and then the page jumps. Otherwise, even if there is no notification, the first page to initialize also to jump the words of the problem. But!!!!! This is important, however, to invoke the method that receives the notification. This must be added, and this method should be placed in the asynchronous main thread to execute. Because the program killed after clicking the notification bar need to re-initialize the home controller, and in the Viewdidload call interface Jump method Jump, home controller has not been initialized, you need to wait until the completion of viewdidload execution to jump, so to add an asynchronous main thread, This will enable the interface to jump after the program has been killed.

Aurora Push Combat Experience

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.