Can anybody tell me in what all scenarios does the delegate function didFinishLaunchingWithOptions gets called by the IOS apart from when app is launched for the first time. I launched the app into the device with XCode and removed the connectivity and then tried sending messages to the device through wifi. I then noticed that didFinishLaunchingWithOptions got called few number of times. Why is this happening and what are the conditions when this function gets called. I am not able to figure out all the scenarios. Thanks in advance.
false if the app cannot handle the URL resource or continue a user activity, otherwise return true . The return value is ignored if the app is launched as a result of a remote notification.
applicationWillResignActive is called when system is asking for permissions. (in iOS 10).
application:didFinishLaunchingWithOptions:Tells the delegate that the launch process is almost done and the app is almost ready to run. So after having the event application:willFinishLaunchingWithOptions, the next event application:didFinishLaunchingWithOptions will be fired.
application:didFinishLaunchingWithOptions: is part of the UIApplicationDelegate protocol, which is responsible with handling different changes over your application state. You can find out more about this method and about the app delegate protocol in the Apple documentation from here.
Your question, can anybody tell me in what all scenarios does the delegate function didFinishLaunchingWithOptions gets called by the IOS ?
If app is killed or in terminated state and user receives a local notification or remote push notification, and user taps notification, then didFinishLaunchingWithOptions gets called first in both cases.
didFinishLaunchingWithOptions also gets called when you are monitoring location changes using "startMonitoringSignificantLocationChanges". From Apple
If you start this service and your app is subsequently terminated, the system automatically relaunches the app into the background if a new event arrives. In such a case, the options dictionary passed to the application(:willFinishLaunchingWithOptions:) and application(:didFinishLaunchingWithOptions:) methods of your app delegate contains the key location to indicate that your app was launched because of a location event.
From Apple documentation:
You should use this method (and the corresponding application:willFinishLaunchingWithOptions: method) to complete your app’s initialization and make any final tweaks. This method is called after state restoration has occurred but before your app’s window and other UI have been presented. At some point after this method returns, the system calls another of your app delegate’s methods to move the app to the active (foreground) state or the background state.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With