0

I am trying to handle the firebase invites when using universal links. When a user clicks on the invitation link, from the e-mail for example, the method below is called.

How to get the invitation from the url?

@available(iOS 8.0, *)
func application(application: UIApplication, continueUserActivity userActivity: NSUserActivity, restorationHandler: ([AnyObject]?) -> Void) -> Bool {

let handled = FIRDynamicLinks.dynamicLinks()?.handleUniversalLink(userActivity.webpageURL!) { (dynamiclink, error) in
  // ...
  }

return handled!
}

To get the invitation i need to call

FIRInvites.handleURL(url, sourceApplication:sourceApplication, annotation:annotation)

I think the problem lays on what to pass to application and annotation parameters. I already try passing the bundled on sourceApplication but has no effect.

Note: Methods used in firebase invitation example are not called once continueUserActivity method is added.

MiguelSlv
  • 14,067
  • 15
  • 102
  • 169

1 Answers1

0

Try this one. It's in objective c but you can concert it to swift also. Hope this help you.

- (BOOL)application:(UIApplication *)application continueUserActivity:(NSUserActivity *)userActivity restorationHandler:(void(^)(NSArray * __nullable restorableObjects))restorationHandler
{
    NSURL *url = userActivity.webpageURL;


    FIRDynamicLinks *links = [FIRDynamicLinks dynamicLinks];
    if([links matchesShortLinkFormat:url])
    {
        [links resolveShortLink:url completion:^(NSURL * _Nullable url, NSError * _Nullable error)
        {
                NSString *message =
                [NSString stringWithFormat:@"Deep link  \n:%@",
                 url];

                [[[UIAlertView alloc] initWithTitle:@"Deep-link Data"
                                            message:message
                                           delegate:nil
                                  cancelButtonTitle:@"OK"
                                  otherButtonTitles:nil] show];



        }];

        return YES;
    }
 return false;
}
Aklesh Rathaur
  • 1,837
  • 18
  • 19