Search code examples
iosobjective-cios9ios-universal-links

Universal Links while app is not running


I am implementing Universal Links in my app. Every things works for me, except when the app is not running in the background. In that case how i can open a specific page in my app? iOS launches my app but i am not getting any callback in

- (BOOL)application:(UIApplication *)application continueUserActivity:(NSUserActivity *)userActivity restorationHandler:(void (^)(NSArray *))restorationHandler
in this function neither i am getting any url with this line

NSURL *launchURL = [launchOptions valueForKey:UIApplicationLaunchOptionsURLKey]; inside

- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions this function.

Does anybody have an idea how i can get the url which caused to launch my application.

Thanks


Solution

  • When you open a Universal Link with your app

     - (BOOL)application:(UIApplication *)app
            openURL:(NSURL *)url
            options:(NSDictionary<NSString *,
                             id> *)options
    

    is called with the Universal Link as a parameter and options if it is the case. Check apple docs for details.