IOS debugging apps started through UILocalNotification or RemoteNotification, uilocalnotification

Source: Internet
Author: User

IOS debugging apps started through UILocalNotification or RemoteNotification, uilocalnotification

I believe many of you have been troubled by debugging Apple's notifications, especially when the app is started through notifications !!! However, we all encountered problems. Why did Apple not think of it? We had an official solution, but we didn't know it... This time I found the answer from stackOverFlow. I have to record it !!! After iOS10, the notification framework has been completely restructured. For details, refer to the blog: UILocalNotification and APNS. First, let's talk about Apple's notification response; once the user has enabled the notification permission, the app can receive the notification. There are two scenarios to receive the notification: one is that the app has not been started, at this time, the system will set a pop-up window, sound, tag, and so on based on the notification permission. At this time, click the pop-up window, the app will start, and when it starts, in method-(BOOL) application :( UIApplication *) application didfinishlaunchingwitexceptions :( NSDictionary *) The launchOptions dictionary in launchOptions contains the notification content. You can use UIApplicati OnLaunchOptionsLocalNotificationKey or secret to get the content. Among them, UIApplicationLaunchOptionsLocalNotificationKey is used to get a UILocalNotification, And the remotenotifuserinfo is obtained through token. You need to handle it here, at this time, the app has not been started yet, so you can do nothing to jump to the page, but you can set rootViewController based on this; or set a flag here, after the rootViewController didAppear, execute attention, in this scenario, iOS10 is the same, and the data types obtained are the same! The other is that the app has been started. At this time, the system will directly call-(void) application :( UIApplication *) application didReceiveLocalNotification :( UILocalNotification *) to determine whether the app is on the frontend *) notification; or
-(Void) application :( UIApplication *) application didReceiveRemoteNotification :( NSDictionary *) userInfo;
If the two methods are not in the foreground, the system will still display a window, sound, and tag Based on the permission settings. At this time, click tag to call the above two methods. Note: in this scenario, iOS10 is followed by a new method. The processing method is different from the two methods. Please refer to meoshen's blog! Well, when we start debugging, it must be the most convenient to connect to the mobile phone for breakpoint debugging. But how can we debug the scenario that starts through notifications ??? I have asked if I can view the mobile phone log through the xcode device, but it is not convenient to directly break the breakpoint! Q: Can I directly break a breakpoint before it starts ??? The answer is: yes !!! Since this was designed by Apple, Apple certainly came up with this problem and provided a solution: on the xcode toolbar, select product-Scheme-edit scheme to the left of the editing scheme interface, select Run, and select info on the right. Then, select the following launch options: wait for executable to be launched; then close and run as before. At this time, you will find that the app is not started, but is "stuck" there, if you set a breakpoint in the didLaunch method and click the notification to start the app, you can directly break the breakpoint to the didLaunch method ~~ Then you can debug all of them as needed ~~ Success ~~ See http://stackoverflow.com/questions/1239000/debugging-app-when-launched-by-push-notification

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.