Search code examples
iosobjective-cfacebookfacebook-graph-apiapplinks

Facebook AppLink & iOS: can't retrieve custom deep link URL query parameters


I am trying to create a referral program with Facebook's App Invite feature. This requires me to create a dynamic App Link for Facebook to handle and send the user a deep link containing referral query parameters.

When I send an App Invite, I thus include an appinviteuserid query parameter in the URL:

            FBSDKAppInviteContent *content =[[FBSDKAppInviteContent alloc] init];
            NSString* urlString = [NSString stringWithFormat:@"http://eduquest.fr/?appinviteuserid=%@", userId];
            content.appLinkURL = [NSURL URLWithString:urlString];
            [FBSDKAppInviteDialog showFromViewController:self.viewController withContent:content delegate:self];

On my website, I have applinks <meta> tags that are filled according to the appinviteuserid parameter, using a PHP script. So the URL http://eduquest.fr/?appinviteuserid=134 gives:

<meta property="og:url" content="http://eduquest.fr?appinviteuserid=134">
<meta property="og:type" content="website">
<meta property="og:image" content="http://eduquest.fr/img/logo01.png">
<meta property="fb:app_id" content="1569329799983803">
<meta property="al:ios:url" content="eduquestbac://invite?fbinviteuserid=134&refid=0">
<meta property="al:ios:app_store_id" content="984500808">
<meta property="al:ios:app_name" content="EduQuest Bac 2016">
<meta property="al:web:should_fallback" content="false">
<meta property="al:web:url" content="http://eduquest.fr">

Then, a user clicking on the app invite link should be deep linked to the App Store or into the app. Normally, I should find the following input URL: eduquestbac://invite?fbinviteuserid=134&refid=0

But instead, I get a URL that does not have my query parameters.

- (BOOL)application:(UIApplication *)application
        openURL:(NSURL *)url

sourceApplication:(NSString *)sourceApplication annotation:(id)annotation {

// App Links FB

BFURL *parsedUrl = [BFURL URLWithInboundURL:url sourceApplication:sourceApplication];

if ([parsedUrl appLinkData]) {
    NSDictionary* appLinkData = [parsedUrl appLinkData];
    if (appLinkData)
    {
        NSString *facebookReferrerUserId = parsedUrl.inputQueryParameters[@"fbinviteuserid"];
        NSString* referralId = parsedUrl.inputQueryParameters[@"refid"];
// Both these are NSNull

I have tried using the deep link itself without going through Facebook App Links and I can retrieve the data fine, so the issue is related to my implementation of App Links.

Thank you for your help


Solution

  • After using a new build to test the App Invite feature, things worked as expected.