Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Conditions when didFinishLaunchingWithOptions get called by the IOS

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.

like image 304
clint Avatar asked Sep 26 '12 10:09

clint


People also ask

What happen if I return false in didFinishLaunchingWithOptions?

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.

When Applicationwillenterforeground is called?

applicationWillResignActive is called when system is asking for permissions. (in iOS 10).

What is the use of application willFinishLaunchingWithOptions and application didFinishLaunchingWithOptions?

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.

What is didFinishLaunchingWithOptions?

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.


2 Answers

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.

like image 58
i.AsifNoor Avatar answered Oct 28 '22 04:10

i.AsifNoor


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.

like image 30
Marco Pace Avatar answered Oct 28 '22 05:10

Marco Pace