简体   繁体   中英

application:didFinishLaunchingWithOptions is not being called

I'm working with push notifications. I read through Apple's programming guide that in case of Remote or Local notifications, application:didFinishLaunchingWithOptions is called and hold the payload in the launchOptions. From there in case of notifications I can respond to the push. I'm testing push on two devices. One that issues the push and the second receives it. I ran the app on both devices and i kept one turned on and the second exited the app to home screen and closed the phone to wait for a notification (i didn't close the app on xcode though). I issues a push and i received it on the receiver device, however using NSLog, it seems that application:didFinishLaunchWithOptions is not being called when the push is opened and only once at application first start. I didn't provide code because there no much added to test that other than the push which is working fine. What could be wrong? is that the right way to respond to notifications opened when the app is in the background?

If you just close the app by pressing the home button the application does not actually launch again so application:didFinishLaunchWithOptions won't be called the second time

Instead, what will be called is - (void)applicationWillEnterForeground:(UIApplication *)application and - (void)applicationDidBecomeActive:(UIApplication *)application so i'd recommend handling whatever is necessary in applicationDidBecomeActive as that method is called when opening the app & coming back into the foreground.

如果您的应用程序在推送通知到达时在后台(或前台)运行,则获取通知有效负载的方法是application:didReceiveRemoteNotification:

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM