1

It's working fine when the app is running and in the background. But when the app is installed, but not launched at that time, it's simply opening the app but not redirecting to the respective screen. Please help me to get out of this situation iOS deployment target is iOS9.3.I am running the application on iPhone7 iOS 13.4. Here is my code:

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

    FIRDynamicLink *dynamicLink = [[FIRDynamicLinks dynamicLinks] dynamicLinkFromCustomSchemeURL:url];
    if (dynamicLink != nil) {
    [self handleIncomingDynamicLink:dynamicLink];
    return YES;
    }

    return FALSE;
}


    - (BOOL)application:(UIApplication *)application continueUserActivity:(NSUserActivity *)userActivity restorationHandler:(void (^)(NSArray *restorableObjects))restorationHandler {

    NSURL *incomingURL = userActivity.webpageURL;

    if (incomingURL) {
        NSLog(@"Incoming URL is %@:", incomingURL);
        BOOL linkHandled = [[FIRDynamicLinks dynamicLinks]handleUniversalLink:incomingURL completion:^(FIRDynamicLink * _Nullable dynamicLink, NSError * _Nullable error) {

            if (error != nil) {
                NSLog(@"Found an error: \(error?.localizedDescription ?? nil)");
                return ;
            }
            else {
                if (dynamicLink) {
                    [self handleIncomingDynamicLink:dynamicLink];
                }
                else {

                }
            }
        }];

        if (linkHandled) {
            return true;
        }
        else {
            // if handling universal link from any other resources. May be do other things from the incoming url
            return false;
        }
    }

    return false;
}
H. de Jonge
  • 878
  • 7
  • 25
tapashR
  • 11
  • 3

1 Answers1

0

Deep link implementation - You should handle the navigation in handleDynamicLink method.

func application(_ app: UIApplication, open url: URL, options: [UIApplicationOpenURLOptionsKey : Any] = [:]) -> Bool {

    if let dynamicLink = DynamicLinks.dynamicLinks().dynamicLink(fromCustomSchemeURL: url) {
        if let url = dynamicLink.url{
            handleDynamicLink(dynamicLink)
        }
        return true
    }
}

func application(_ application: UIApplication, continue userActivity: NSUserActivity, restorationHandler: @escaping ([Any]?) -> Void) -> Bool {

    guard let incomingUrl = userActivity.webpageURL else { return false }
    let links = DynamicLinks.dynamicLinks()
    let handled = links.handleUniversalLink(incomingUrl) { (dynamicLink, error) in

        if let url = dynamicLink?.url{
            handleDynamicLink(dynamicLink)
        }
    }
    return handled
}
Catherine
  • 199
  • 6
  • That I have done. What happens when the app is not launched? Any of these two methods is not triggering. That's my concern. Please advise. – tapashR Apr 02 '20 at 08:08
  • Have you check on tapping the link again, after installing the app and without launching ? – Catherine Apr 02 '20 at 09:11
  • Can you just debug the firebase deep link, just add " ?d=1 " at the end of your deep link. example "example.page.link/suffix?d=1" – Catherine Apr 02 '20 at 09:26