0

Is it possible at the time didFinishLaunchingWithOptions is invoked for me to know how the app was launched?

My app can be launched either by the user directly or by clicking on a url in an SMS.

When the app is launched it connects to a server and I'm starting that connection asynchronously in didFinishLaunchingWithOptions.

If the app is launched by clicking on its icon it connects to the server to see if there is anything for it to download. But if it is launched via a URL in an SMS then there is some data appended to the url which must be transmitted to the server.

However when the app is launched via a URL then openURL:url sourceApplication:sourceApplication annotation:annotation (which is how I obtain the url payload) is called AFTER didFinishLaunchingWithOptions.

Is it possible at the time didFinishLaunchingWithOptions is invoked for me to know how the app was launched? So that I know if via the user I will start the connection, otherwise if via a URL I won't and will wait until openURL::: gets called and do it then.

1 Answer 1

1

In the options dictionary, you will have the UIApplicationLaunchOptionsURLKey which is the URL that caused your app to be launched. And you also have the UIApplicationLaunchOptionsSourceApplicationKey which tells you which application tried to open that URL.

Both of those should be populated in the case that your app was launched from the SMS.

I hope that helps.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.