Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to test UILocalNotification in didFinishLaunchingWithOptions

I would like to test how my app behaves when the app is quit and the user taps a notification in notification center so that my app is launched. In - didFinishLaunchingWithOptions you can check for the key UILocalNotification *notification = [launchOptions objectForKey:UIApplicationLaunchOptionsLocalNotificationKey]; but how can I debug this?

If i start running the app in Xcode then I quit the app it will lose the connection to Xcode.

like image 814
Peter Warbo Avatar asked Jan 15 '13 10:01

Peter Warbo


1 Answers

If you set your Xcode Scheme to launched manually (Edit Scheme > Run > Info), then you can stop running your app after you've scheduled your UILocalNotification.

Then if you run your application again, it won't launch until you launch it from the simulator/device.

Then you could wait for the notification to fire and click the notification which then launches your app (manually!). That way you can debug that UILocalNotification from the launchOptions of application:didFinishLaunchingWithOptions:

Just note that for debugging, you'll probably want to schedule your UILocalNotification for a date about 10 seconds or so in the future, it's always a pain to debug time related stuff.

Good luck.

like image 160
Daniel Avatar answered Nov 17 '22 15:11

Daniel