Facebook Applinks - Pass user JSON data to al_applink_data

Can I transfer user data to al_applink_data using Facebook apps?

I can extract this JSON example, but I do not see a place where you can add your user data to it. If this is not possible, my only solution is to parse the resulting URL, but that doesn't look bulletproof.

 { "target_url": "https://www.example.com/abc.html", "extras": { "fb_app_id": [YOUR_FACEBOOK_APP_ID], "fb_access_token": "[ACCESS_TOKEN']", "fb_expires_in": "3600" }, "referer_app_link": { "url": "[FACEBOOK_APP_BACK_LINK]", "app_name": "Facebook" } } 
+5
source share
2 answers

Data analysis

My solution is by creating user data for target_url.

 NSDictionary *dictionary = @{ @"target_url" : @"YOUR_VALUE"}; NSData *jsonData = [NSJSONSerialization dataWithJSONObject:dictionary options:0 error:nil]; NSString *jsonString = [[NSString alloc] initWithData:jsonData encoding:NSUTF8StringEncoding]; 

Then add your Facebook app link id using al_applink_data in the FB Graph Object dictionary.

 [NSString stringWithFormat:@"https://fb.me/FB_LINK_ID?al_applink_data=%@", jsonString] 

What is it.!!

Retrieving a Callback URL

 if([[call appLinkData] targetURL] != nil) { NSURL *targetUrl = [[call appLinkData] targetURL]; //Actual URL NSString *urlString = [[targetUrl absoluteString] stringByRemovingPercentEncoding]; URLParser *parser = [[URLParser alloc] initWithURLString:urlString]; //Fetching value for 'al_applink_data' NSString *appLinkData = [parser valueForVariable:@"al_applink_data"]; NSData *objectData = [appLinkData dataUsingEncoding:NSUTF8StringEncoding]; //Dictionary with 'target_key' key and its value. NSDictionary *json = [NSJSONSerialization JSONObjectWithData:objectData options:NSJSONReadingMutableContainers error:nil]; NSLog(@"%@", json); } 

URL parsing link: URLParser

Thanks.

+2
source

The "Additional" card is designed to transfer arbitrary metadata. What type of user data do you need? Passing user data using the "extra" blob requires the caller to know something about your application (so that they can actually add data).

0
source

Source: https://habr.com/ru/post/1214743/


All Articles