iOS Huawei App Linking - Deferred deep linking

371 views Asked by At

TL;DR; Deep linking with the app installed works, however deferred deep linking doesn't worked.

I m trying to implement the Huawei solution for App Linking.

The version of the App Linking that I use is:

pod 'AGConnectAppLinking', '~> 1.6.1.300'

Currently if the user tap the Huawei short link with the app installed the app opens and redirect the user successfully inside the app based on the deep link.

Unfortunately the deferred deep linking scenario doesn't work.

  1. I open the Huawei link and I click the download button.
  2. When the app opens for the first time I'm showing the popup for pasting content.
  3. The content in the clipboard is something like that agc_click_id=47XXXXXXXXX.
  4. But nothing happens.

In AppDelegate.m, I already implement the following code which is work like a charm when the user has already the app and taps the deep linking.

- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
    [AlphaGlobals.sharedGlobals application:application didFinishLaunchingWithOptions:launchOptions];
    
    [AGCInstance startUp];
    
    [[AGCAppLinking sharedInstance] handleAppLinking:^(AGCResolvedLink * _Nullable link, NSError * _Nullable error) {
        if (link) {
            NSString *deepLink = link.deepLink;
            NSLog(@"Deeplink = %@", deepLink);
        }
    }];
    
    return YES;
}
-(BOOL)application:(UIApplication *)application continueUserActivity:(NSUserActivity *)userActivity restorationHandler:(void (^)(NSArray<id<UIUserActivityRestoring>> * _Nullable))restorationHandler {
   BOOL isAppLinking = [[AGCAppLinking sharedInstance] continueUserActivity:userActivity];
   return isAppLinking

}

Am I missing something for Deferred deep linking?

1

There are 1 answers

4
zhangxaochen On
//MARK:AGCAppLinking
        AGCAppLinking.instance().handle { (link, error) in
            
            if self.linkTempVC != nil {
                let deepLink = link?.deepLink
                if let r = deepLink!.range(of: "PhotoPlaza://ios/", options: .backwards) {
                    let photoID = String(deepLink![r.upperBound...])
                    linkPhotoID = photoID
                    let vc = DetailViewController()
                    self.linkTempVC!.navigationController?.viewControllers.last?.navigationController?.pushViewController(vc, animated: true)
                }
            }
        }

You are referring to the deferred deep link, which needs to be implemented by using your own code: after the deep link is obtained from didFinishLaunchingWithOptions, and you can customize a page based on the deep link information.