2

My requirement is to handle universal links on the iOS application. But the dynamic link.url seems to be returning an error as below -

"@"error" : @"unauthorized user: username=social-app-invite methodName=/FirebaseLookupService.LookupAppsSummary protocol=loas securityLevel=integritY"

When i click on a dynamic link (https://****.app.goo.gl/****) from the notes app, my ios app will be directed to the following callback -> In this function i have the following code -

- (BOOL)application:(UIApplication *)application continueUserActivity:(NSUserActivity *)userActivity restorationHandler:(void(^)(NSArray * __nullable restorableObjects))restorationHandler
{
NSURL *incomingURL = userActivity.webpageURL;
if(incomingURL){
    BOOL handled = [[FIRDynamicLinks dynamicLinks]
                    handleUniversalLink:incomingURL
                    completion:^(FIRDynamicLink * _Nullable dynamicLink,
                                 NSError * _Nullable error) {
                        if (dynamicLink.url){`
                           **HANDLE THE DYNAMIC LINK HERE**
                        }else{
                           **CODE IS RETURNING ERROR** NSLog(@"error %@",error);
                        }
                    }];
    return handled;
}else{
    return false;
}

}

I have followed the firebase documentation correctly. Please suggest what is going wrong here?

Frank van Puffelen
  • 565,676
  • 79
  • 828
  • 807
Kavitha Pai
  • 51
  • 3
  • 11

3 Answers3

3

I also met this issue. handleUniversalLink() returned always false. In my case my link parameter contained not just a URL but also parameters. So the final dynamic link got two question marks in it.

https://app-id.app.goo.gl/?link=https://www.domain.com/resource?someParam=someValue&ibi=com.domain.appname

If I escape the inner URL (link parameter) with percent escapes, it works fine.

https://app-id.app.goo.gl/?link=https%3A%2F%2Fwww.domain.com%2Fresource%3FsomeParam%3DsomeValue&ibi=com.domain.appname

cybergen
  • 3,108
  • 1
  • 22
  • 30
  • I am trying to get an dynamic link , but handleuniversallink() always returns false and also not entered into the closure. – Protocol Feb 18 '20 at 11:32
0

Try this one.

- (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
  • I tried this, am getting myappid://google/link/ not the long dynamic link, any reason why its not returning dynamic link url. Thanks – Syed Ismail Ahamed Sep 26 '16 at 12:58
  • You can get long dynamic link in block url, what i formated in "message" string. – Aklesh Rathaur Sep 26 '16 at 13:11
  • I can get my long dynamic link in block section. – Aklesh Rathaur Sep 27 '16 at 07:10
  • Try to put same code as my answer without any change. – Aklesh Rathaur Sep 27 '16 at 07:11
  • Thanks for your input, Aklesh. But I am getting null for "url". Instead get an error for NSError. – Kavitha Pai Sep 28 '16 at 06:05
  • Error Domain=com.google.GTLJSONRPCErrorDomain Code=403 "(unauthorized user: username=social-app-invite methodName=/FirebaseLookupService.LookupAppsSummary protocol=loas securityLevel=integrity)" UserInfo={error=unauthorized user: username=social-app-invite methodName=/FirebaseLookupService.LookupAppsSummary protocol=loas securityLevel=integrity, GTLStructuredError=GSDK_GTLErrorObject 0x1642e6f0: {code:403 status?:"PERMISSION_DENIED" message:"unauthorized user: username=social-app-invite methodName=/FirebaseLookupService.LookupAppsSummary protocol=loas securityLevel=integrity" errors?:[1]} – Kavitha Pai Sep 28 '16 at 06:08
  • @KavithaPai I tried to search your error and came to the point that there is something wrong with your configuration on firebase console. Are you using same credential as on firebase console? – Aklesh Rathaur Sep 28 '16 at 06:21
  • @AkleshRathaur, The googleservice-info.plist you mean? – Kavitha Pai Sep 28 '16 at 06:23
  • Where do i need to use the same credential? – Kavitha Pai Sep 28 '16 at 06:25
  • @KavithaPai Can you send me your long and sort dynamic link? – Aklesh Rathaur Sep 28 '16 at 07:04
  • @AkleshRathaur: Long dynamic link is this -> https://brej5.app.goo.gl/?link=http://erosnow.com/tv&isi=551666302&ibi=com.erosnow.erosnow&ius=erosnowapp://tv and short one is this -> https://brej5.app.goo.gl/M4Bi – Kavitha Pai Sep 28 '16 at 07:10
  • @KavithaPai check your identifier, team id, url scheme in xcode and also in firebase console. there should be some mismatch. – Aklesh Rathaur Sep 28 '16 at 07:30
  • @AkleshRathaur: I have not added anything manually except the URI Scheme. I have downloaded the googleservice-info.plist from the firebase site and all other configurations are part of it. – Kavitha Pai Sep 28 '16 at 07:35
  • @KavithaPai I will suggest you to watch a video on youtube for firebase invite and deep link.You will definitely get your solution. – Aklesh Rathaur Sep 28 '16 at 08:12
  • okay i will do that.. But firebase invite is not required in my case. Just wondering why I am getting an error on that. – Kavitha Pai Sep 28 '16 at 08:23
  • @AkleshRathaur: I think i found something. When i try to hit my dynamic link url from here - https://developers.google.com/apis-explorer/?hl=en_US#p/firebasedynamiclinks/v1/. I get the following response - – Kavitha Pai Sep 28 '16 at 09:24
  • "code": 403, "message": "Firebase Dynamic Links API has not been used in project google.com:apisexplorerconsole before or it is disabled. Enable it by visiting https://console.developers.google.com/apis/api/firebasedynamiclinks.googleapis.com/overview?project=google.com:apisexplorerconsole then retry. If you enabled this API recently, wait a few minutes for the action to propagate to our systems and retry.", "status": "PERMISSION_DENIED", – Kavitha Pai Sep 28 '16 at 09:28
  • @KavithaPai have you enabled now? – Aklesh Rathaur Sep 28 '16 at 10:04
  • @AkleshRathaur: Yes, I have enabled dynamic linking api. Looks like it will take some number of hours to activate. Currently it is giving the same error. – Kavitha Pai Sep 28 '16 at 10:06
  • @KavithaPai Ok. Try later. – Aklesh Rathaur Sep 28 '16 at 10:07
  • Where did you create that project? on google console or firebase console – Aklesh Rathaur Sep 28 '16 at 10:08
  • I had created the project on firebase console itself. Just had to add the firbase dynamic linking api from the link here - https://console.developers.google.com/apis/api/firebasedynamiclinks.googleapis.com/overview?project= – Kavitha Pai Sep 28 '16 at 10:12
  • Ok. now you will get your solution. – Aklesh Rathaur Sep 28 '16 at 10:16
  • I will check after few hours and post in this forum if it works. – Kavitha Pai Sep 28 '16 at 10:41
  • That would be helpful to others. – Aklesh Rathaur Sep 28 '16 at 10:53
  • @AkleshRathaur: Check my answer above. I was able to get the url successfully. But now my problem is i need the uri scheme value to navigate to the respective page. Something like "myapp://some link". Currently i get the deep link url only. It navigates to the home page always. Could you please help? – Kavitha Pai Oct 05 '16 at 11:39
0

I was able to get the dynamic link url value. There was an additional check in my code as below -

if (launchOptions != nil) {
[FIROptions defaultOptions].deepLinkURLScheme = URL_SCHEME;

}

Because of this check, the URL scheme was never getting initialised and hence was erroring out.

The code that i have posted above should return the right dynamic link url.

Thanks.

Kavitha Pai
  • 51
  • 3
  • 11
  • thanks for the message. But this one is already available in firebase deeplink demo and i integrated that. May be you not that's why you were facing an error. – Aklesh Rathaur Oct 05 '16 at 11:44