iOS Debug app launched via Uilocalnotification or remotenotification

Source: Internet
Author: User

I believe many students are worried about debugging Apple's notice, especially through the notification to start the app this function, it makes people want to cry no tears!!! However, we are all faced with the problem, Apple how may not have thought, originally had already had the official solution, but we do not know only ... This time again from the StackOverflow found the answer, must record!!! IOS10, the notification framework is completely refactored, you can refer to the blog: https://onevcat.com/2016/08/notification/here because to be compatible with iOS8, so first talk about iOS10 before the processing method Uilocalnotification and APNs How to do not say, first of all to say the Apple notification response; As long as the user opens the notification permission, then the app can receive notifications, received two kinds of scenes: One is the app has not started, At this time the system will be based on the notification of the right to set up a pop-up window, sound, mark and so on, then click on the Pop-up window, the app will start, and start, in the Method-(BOOL) Application: (UIApplication *) application Didfinishlaunchingwithoptions: (nsdictionary *) launchoptionslaunchoptionsThe contents of the notification are included in the dictionary, The content can be obtained through uiapplicationlaunchoptionslocalnotificationkey or uiapplicationlaunchoptionsremotenotificationkey; PassUiapplicationlaunchoptionslocalnotificationkeyFetch was a uilocalnotification, and by theUiapplicationlaunchoptionsremotenotificationkeyTake the remotenotification of the userinfo; Note that this time the app has not started to complete, so jump page what is not to do, it can be set according to this Rootviewcontroller , or set a tag here, Rootviewcontroller didappear after the implementation of the note, the scene iOS10 is the same, the same data type obtained! The other is the app has been started, this time to distinguish whether the app is in the foreground, if in the foreground, the system will call directly-(void) Application: (UIApplication *) application Didreceivelocalnotification: (uilocalnotification *) notification;
-(void) Application: (UIApplication *) application didreceiveremotenotification: (Nsdictionary *) UserInfo;
Two methods if not at the front desk, the system will still be based on the right to set up pop-up windows, sounds, tags, and so on, then click on the mark, will call the above two methods note: This scene iOS10 after a new method, the treatment method with these two different, please refer to the Meow blog! OK, cut to the chase when we are debugging, it must be connected to the phone breakpoint debugging the most convenient, but for the notification to start the scene, how to debug??? Have asked the device can be viewed through Xcode mobile phone log to see, but this also has no direct breakpoint to the convenience! The question is: can you make a direct breakpoint before starting??? The answer is: Can!!! This thing is Apple design, apple of course think of this problem, but also gives a solution: on the Xcode toolbar, choose Product-scheme-edit Scheme to the left of the edit scheme interface choose Run, select Info on the right, Then select on the launch option below: Wait for executable to be launched; then close, run as it is, and you will find that the app does not start, but the card is there, If you make a breakpoint in the Didlaunch method, and then click on the notification to launch the app, you can directly breakpoint to the Didlaunch method in ~ ~ and then want to how to debug all with you ~ ~ ~ You can refer to: http://stackoverflow.com/ Questions/1239000/debugging-app-when-launched-by-push-notification

iOS Debug app launched via Uilocalnotification or remotenotification

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.