我正在尝试通过AppLinks网址打开Facebook应用,它会打开用户个人资料/页面但不显示按钮“返回参考应用”,我提供“referer_app_link”数据, 我已通过此引用生成JSON http://applinks.org/documentation/#applinknavigationprotocol
NSDictionary *dict = @{
@"target_url" : @"fb://profile/USER_ID",
@"referer_app_link" : @{
@"target_url" : @"MY WEBSITE",
@"url" : @"CALLBACK URL",
@"app_name" : @"MY APP NAME",
@"app_store_id" : @"MY APP STORE ID"
}
};
NSData *data = [NSJSONSerialization dataWithJSONObject:dict options:0 error:nil];
NSString *jsonString = [[NSString alloc] initWithData:data encoding:NSUTF8StringEncoding];
jsonString = [jsonString stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding];
NSString *stringUrl = [NSString stringWithFormat:@"fb://applinks?al_applink_data=%@",jsonString];
NSLog(@"String url is %@",stringUrl);
NSURL *url = [NSURL URLWithString:stringUrl];
if([[UIApplication sharedApplication] canOpenURL:url]) {
[[UIApplication sharedApplication] openURL:url];
} else {
NSLog(@"Cant open %@",url);
}
任何想法? Facebook应该有“后退按钮”吗? 我的网址方案设置正确...
更新 NSDictionary包含所有有效值,我现在不想发布它们,但url,name,store id等都是有效的
更新#2: 从iOS 9开始,这是由iOS系统自动完成的。
答案 0 :(得分:0)
applink未连接到FB好友配置文件页面。
替代方法是使用FB IOS SDK并选择并在应用程序中显示远程用户,如下所示:(来自HelloFacebook示例应用程序的代码(随SDK提供)
- (IBAction)pickFriendsClick:(UIButton *)sender {
FBFriendPickerViewController *friendPickerController = [[FBFriendPickerViewController alloc] init];
friendPickerController.title = @"Pick Friends";
[friendPickerController loadData];
// Use the modal wrapper method to display the picker.
[friendPickerController presentModallyFromViewController:self animated:YES handler:
^(FBViewController *innerSender, BOOL donePressed) {
if (!donePressed) {
return;
}
NSString *message;
if (friendPickerController.selection.count == 0) {
message = @"<No Friends Selected>";
} else {
NSMutableString *text = [[NSMutableString alloc] init];
// we pick up the users from the selection, and create a string that we use to update the text view
// at the bottom of the display; note that self.selection is a property inherited from our base class
for (id<FBGraphUser> user in friendPickerController.selection) {
if ([text length]) {
[text appendString:@", "];
}
[text appendString:user.name];
}
message = text;
}
[[[UIAlertView alloc] initWithTitle:@"You Picked:"
message:message
delegate:nil
cancelButtonTitle:@"OK"
otherButtonTitles:nil]
show];
}];
}
注意 - 示例当前刚刚从FBGraphUser类实例中选择了name属性....
用户将拥有其他属性生日,性别等,只需在SDK中查找头文件或查找FB文档。