解析数据
我的解决方案是为 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];
然后,在FB Graph Object字典中附加您的 Facebook 应用链接 ID 和al_applink_data
键。
[NSString stringWithFormat:@"https://fb.me/FB_LINK_ID?al_applink_data=%@", jsonString]
就是这样。!!
检索回调 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 解析参考:URLParser
谢谢。