2
我使用FBDialogs
打開Facebook Messenger
(如果用戶已將其安裝在設備上)發送個人消息。不過,我不能在我的應用程序中預選好友(使者總是給我一個列表並提示我在那裏選擇)。我可以在新的FBDialogs中預選好友嗎?
我使用presentMessageDialogWithParams:clientState:handler
:接收FBLinkShareParams
object。
FBLinkShareParams朋友陣列
NSString的數組或
FBGraphUsers
在後標記。如果使用NSString,則這些值必須表示要標記的用戶的ID。
但是,當我發送FBGraphUsers
他們不預先選擇在Messenger應用程序。他們應該嗎?或者這只是一個「標記朋友」功能?
我的代碼:
NSMutableArray *inviteFriends = [[NSMutableArray alloc] init];
FBRequest* friendsRequest = [FBRequest requestForMyFriends];
[friendsRequest startWithCompletionHandler: ^(FBRequestConnection *connection,
NSDictionary* result,
NSError *error) {
NSArray* friends = [result objectForKey:@"data"];
NSLog(@"Found: %i friends", friends.count);
for (NSDictionary<FBGraphUser>* friend in friends) {
if ([friend.name isEqualToString:@"XXX"]) {
NSLog(@"I have a friend named %@ with id %@", friend.name, friend.id);
[inviteFriends addObject:friend];
}
}
FBLinkShareParams *params = [[FBLinkShareParams alloc] init];
params.link = [NSURL URLWithString:@"https://developers.facebook.com/docs/ios/share/"];
params.name = @"Message Dialog Tutorial";
params.caption = @"Build great social apps that engage your friends.";
params.picture = [NSURL URLWithString:@"http://i.imgur.com/g3Qc1HN.png"];
params.description = @"Send links from your app using the iOS SDK.";
params.friends = inviteFriends;
// If the Facebook app is installed and we can present the share dialog
if ([FBDialogs canPresentMessageDialogWithParams:params]) {
[FBDialogs presentMessageDialogWithParams:params clientState:nil handler:^(FBAppCall *call, NSDictionary *results, NSError *error) {
//
}];
}
}];
從那時起有什麼變化? – squixy