简体   繁体   English

application:didFinishLaunchingWithOptions没有被调用

[英]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. 我通读了Apple的编程指南,以了解在发出远程或本地通知的情况下,将调用application:didFinishLaunchingWithOptions并将有效负载保存在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). 我在两台设备上都运行了该应用程序,第二台设备保持打开状态,第二台设备退出到主屏幕,然后关闭了手机以等待通知(尽管我没有在xcode上关闭该应用程序)。 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. 我发出了一个推送,并且在接收器设备上收到了推送,但是使用NSLog时,似乎在打开推送时未调用application:didFinishLaunchWithOptions,并且在应用程序首次启动时仅调用了一次。 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 如果仅通过按主屏幕按钮关闭应用程序,则该应用程序实际上不会再次启动,因此第二次将不会调用application:didFinishLaunchWithOptions

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. 相反,将被称为- (void)applicationWillEnterForeground:(UIApplication *)application- (void)applicationDidBecomeActive:(UIApplication *)application因此我建议处理applicationDidBecomeActive必要的任何事情,因为打开应用程序时会调用该方法&回到前台。

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

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 application:didFinishLaunchingWithOptions:在iPad上没有被调用 - application:didFinishLaunchingWithOptions: not getting called on iPad iOS - 在 didFinishLaunchingWithOptions 委托之前调用 viewDidLoad? - iOS - viewDidLoad is being called BEFORE the didFinishLaunchingWithOptions delegate? 私有函数 didFinishLaunchingWithOptions 没有被调用? (斯威夫特 3) - Private func didFinishLaunchingWithOptions not being called? (Swift 3) application(_ application: UIApplication, didFinishLaunchingWithOptions) 未在启动时调用 - application(_ application: UIApplication, didFinishLaunchingWithOptions) not called on start up URL方案:application:didFinishLaunchingWithOptions :,未调用handleOpenURL - URL schemes: application:didFinishLaunchingWithOptions:, handleOpenURL not called 远程通知“ application:didFinishLaunchingWithOptions:”方法未调用 - Remote Notification 'application:didFinishLaunchingWithOptions:' method not called 在什么情况下调用了application:didFinishLaunchingWithOptions :? - In what case that application:didFinishLaunchingWithOptions: been called? application:didFinishLaunchingWithOptions:在应用崩溃时被调用的方法 - application:didFinishLaunchingWithOptions: method getting called on app crash 应用程序 openURL 在 didFinishLaunchingWithOptions 几秒钟后被调用 - Application openURL gets called a few seconds after didFinishLaunchingWithOptions 我的RootViewController的viewDidLoad被application:didFinishLaunchingWithOptions:和applicationDidBecomeActive调用: - viewDidLoad of my RootViewController gets called by application:didFinishLaunchingWithOptions: and applicationDidBecomeActive:
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM