Reputation: 38940
When does a custom URL get populated in launchOptions
in the AppDelegate.m
file? I've loaded my apps' custom URL in Safari and UIApplicationLaunchOptionsURLKey
is not populated.
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
NSLog(@"app launch options");
NSLog([launchOptions valueForKey:UIApplicationLaunchOptionsURLKey]);
}
Upvotes: 0
Views: 1023
Reputation: 2854
UIApplicationLaunchOptionsURLKey gets populated when you try to open the app by means of:
[[UIApplication sharedApplication] openURL:[NSURL URLWithString: @"yourapp://"]];
...and yourapp
is not running.
Then
(BOOL)application:(UIApplication *):didFinishLaunchingWithOptions:(NSDictionary *)
will get executed and NSDictionary
will get populated with two key-values
UIApplicationLaunchOptionsURLKey
and UIApplicationLaunchOptionsSourceApplicationKey
Upvotes: 2
Reputation: 21
The main entry point for any C derived program is a function called main
, and in ObjC it's called int main
. This kicks of a series of events that ultimately calls the applicationDidFinishLaunchingWithOptions:
method that ultimately leads to the user getting to see the first "screen" you want them to see.
2 things will happen after applicationDidFinishLaunchingWithOptions:
in the next series of events.
If there is a populated URL key it will use that URL key and call applicationDidBecomeActive:.
If there is not a URL key set it will then call application: openURL: sourceURL: annotation
which is where you would set it.
That does leave an issue of how it is populated for the initial call in applicationDidFinishLaunchingWithOptions:
. I believe you can set this in the info.list file.
Upvotes: 2