Click Aurora push to achieve the jump, click Aurora push to jump

Source: Internet
Author: User

Click Aurora push to achieve the jump, click Aurora push to jump

To be honest, Aurora push has been used for several times, but every development has implemented simple display functions. A recently claimed app requires only display in the background, you also need to click the notification bar to jump to the corresponding details interface, so you thought it was very easy to start, and it was also very embarrassing, I thought I was okay (I used an iPhone with IOS 10 or above at the time ). However, in the final test phase, various problems may occur and debugging may not work. briefly summarize the problems that occurred at that time (however, the prerequisite is that they have been integrated according to the requirements of the Aurora official documentation, in addition, it is normal to send a message notification on the Aurora console)

1) Different Agent methods are used to display and click notifications in the background on mobile phones of different systems.

For example, in the iOS8 system, this method is used to display notifications and click notifications.

-(Void) application :( UIApplication *) application didReceiveRemoteNotification :( NSDictionary *) userInfo
FetchCompletionHandler :( void
(^) (UIBackgroundFetchResult) completionHandler

For example, in the iOS10 system, the following method is used to display the notification.

-(Void) jpushnotifcenter center :( unusernotifcenter center *) center didReceiveNotificationResponse :( UNNotificationResponse *) response withCompletionHandler :( void (^) () completionHandler

2) The frontend and backend will also affect calling different proxy methods.

3) if you think this is the last problem, you will be wrong. This cannot be further summarized.

I believe that many people still do not understand it here. Here, we try to rest assured that we can skip the previous steps directly. If you want to click Aurora push to go to the jump details page, focus on the following figure! The point is coming! The point is coming!

  

The figure above shows a webpage link that I gave to Aurora's technical staff after asking me a question. It's really sad to see that, and I am in a twinkling of an eye. It is imperative to immediately contact the background of our project to determine whether the content-available field is added to the push, and print the log and read it, there is no content-available field in Aurora's background push, but our php background adds this field to our iOS side, and the background also replies to me. Here, I will tell you that you must never believe what the background says and cannot change this field. With the help of Aurora technicians, I will copy various solutions, even the code sample is provided to the background, and finally solved this problem for me. Finally, we can see that the printed log does not have the content-available field, and finally we can see the dawn. Do not think this is over. You are wrong. You must pay attention to the front and back ends of the app. You can also see the picture above, in the following method, you must add a front-end judgment to implement the jump logic without the front-end. Finally, I took various tests on iOS8, iOS9, iOS10, and iOS11 mobile phones and finally got normal. I just wanted to say that I liked this figure too much!

Below I paste the Aurora source code (including integration) related to the project, so you can check it at will.

-(BOOL) application :( UIApplication *) application didfinishlaunchingwitexceptions :( NSDictionary *) launchOptions {...... omit do not write // Required registration notification our project only supports devices above iOS7 # if _ IPHONE_ OS _VERSION_MAX_ALLOWED> _ IPHONE_7_1 if ([[UIDevice currentDevice]. systemVersion floatValue]> = 10.0) {JPUSHRegisterEntity * entity = [[JPUSHRegisterEntity alloc] init]; entity. types = UNAuthorizationOptionAlert | UNAuthorization OptionBadge | UNAuthorizationOptionSound; [JPUSHService registerForRemoteNotificationConfig: entity delegate: self];} else if ([[UIDevice currentDevice]. systemVersion floatValue]> = 8.0) {// categories [JPUSHService catalog :( UIUserNotificationTypeBadge | UIUserNotificationTypeSound | canonical) categories: nil];} else {// categories nil [JPUSHService regi Optional :( strong | UIRemoteNotificationTypeSound | strong) # else // categories nil categories: nil]; [JPUSHService labels :( strong | UIRemoteNotificationTypeSound | sound) # endif // Required categories: nil];} [JPUSHService setupWithOption: launchOptions appKey :@ "Channels" channel: @ "AppStore" apsForProduction: YES advertisingIdentifier: nil]; // required for custom messages // nsicationicationcenter * defaultCenter = [nsicationicationcenter defacenter center]; // [defacenter center addObserver: self selector: @ selector (networkDidReceiveMessage :) name: kJPFNetworkDidReceiveMessageNotification object: nil]; // The registration id block interface is added in version 2.1.9. [JPUSHService registrationIDCompletionHandler: ^ (int resCode, NSString * registrationID) {if (resCode = 0) {NSLog (@ "registrationID obtained successfully: % @", registrationID ); NSUserDefaults * defaults = [NSUserDefaults standardUserDefaults]; [defaults setObject: registrationID forKey: JPushRegistrationID]; [defaults synchronize];} else {NSLog (@ "registrationID acquisition failed, code: % d ", resCode) ;}}]; ...... omit do not write} // deviceTo obtained by pushing Aurora Ken is sent to SDK-(void) application :( UIApplication *) application token :( NSData *) deviceToken {[JPUSHService registerDeviceToken: deviceToken];}-(void) application :( UIApplication *) application didReceiveRemoteNotification :( NSDictionary *) userInfo {// Required NSLog (@ "iOS6 ????? "); [JPUSHService handleRemoteNotification: userInfo];}-(void) application :( UIApplication *) application metadata :( NSDictionary *) userInfofetchCompletionHandler :( void (^) (UIBackgroundFetchResult )) completionHandler {// IOS 7 Support Required if (application. applicationState! = UIApplicationStateActive) {// not on the foreground. You must judge [self didJpushJumpToDetail: userInfo];} [JPUSHService handleRemoteNotification: userInfo]; completionHandler (UIBackgroundFetchResultNewData );} // for IOS 10, click here for notification-(void) jpushnotifcenter center :( UNUserNotificationCenter *) center didReceiveNotificationResponse :( UNNotificationResponse *) response withCompletionHandler :( void (^ )()) completionHandler {NSLog (@ "proxy method for processing message notifications in the background after iOS10"); // Required NSDictionary * userInfo = response. notification. request. content. userInfo; [self didJpushJumpToDetail: userInfo]; if ([response. notification. request. trigger isKindOfClass: [UNPushNotificationTrigger class]) {[JPUSHService handleRemoteNotification: userInfo];} completionHandler (); // The system requires this method to be executed} // click the notification to jump to the corresponding details page-(void) didJpushJumpToDetail :( NSDictionary *) userInfo {NSLog (@ "userInfo = % @", userInfo); int t = [[userInfo objectForKey: @ "type"] intValue]; if (t = 2) {// 1: Instant Q & A 2: problem square NSString * type = [NSString stringWithFormat: @ "% d", t]; if ([userInfo objectForKey: @ "qid"] & [userInfo objectForKey: @ "waitType"]) {// & [userInfo objectForKey: @ "rid"] NSString * qid = [NSString stringWithFormat: @ "% d", [[userInfo objectForKey: @ "qid"] intValue]; NSString * rid = [NSString stringWithFormat: @ "% d", [[userInfo objectForKey: @ "rid"] intValue]; NSString * waitType = [userInfo objectForKey: @ "waitType"]; // zhuiwen ques [[nsicationicationcenter defaultCenter] postNotificationName: @ "icationicationgotovc" object: nil userInfo: @ {@ "t": type, @ "qid": qid, @ "waitType": waitType, @ "rid": rid}] ;}} else if (t = 1) {NSString * type = [NSString stringWithFormat: @ "% d", t]; if ([userInfo objectForKey: @ "qid"] & [userInfo objectForKey: @ "uid"] & [userInfo objectForKey: @ "qtype"]) {NSString * qid = [NSString stringWithFormat: @ "% d", [[userInfo objectForKey: @ "qid"] intValue]; NSString * uid = [NSString stringWithFormat: @ "% d", [[userInfo objectForKey: @ "uid"] intValue]; NSString * qtype = [NSString stringWithFormat: @ "% d", [[userInfo objectForKey: @ "qtype"] intValue]; [[NSNotificationCenter defacenter center] postNotificationName: @ "notificationGotoVc" object: nil userInfo :@{@ "t": type, @ "qid": qid, @ "uid": uid, @ "qtype": qtype}] ;}}- (void) jpushNotificationCenter :( UNUserNotificationCenter *) center willPresentNotification :( UNNotification *) notification withCompletionHandler :( void (^) (NSInteger )) completionHandler {NSLog (@ "New iOS10: proxy method for handling notifications received by the frontend"); // Required NSDictionary * userInfo = notification. request. content. userInfo; if ([notification. request. trigger isKindOfClass: [UNPushNotificationTrigger class]) {[JPUSHService handleRemoteNotification: userInfo];} else {// local push acceptance when the application is on the frontend} // Note ::: if the following line is commented out, the app will not display the top notification on the foreground. If the comment is removed, the notification will be displayed on the top, depending on the project requirements, we require that you do not display the // completionHandler (UNNotificationPresentationOptionAlert); // you need to execute this method and select whether to remind the user. You can set the Badge, Sound, and Alert types}

 

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.