我想邀請Facebook的用戶嘗試我的iOS應用程序(這不是在商店,還沒有完成它)。從Facebook的iOS應用程序邀請Facebook用戶:邀請沒有被髮送
我使用Facebook的API來驗證用戶,然後嘗試使用下面的代碼:
- (void)shareWithFriends:(id)sender
{
UIAlertView *alert = [[UIAlertView alloc]
initWithTitle:@"Invite Friends"
message:@"If you enjoy using this app, would you mind taking a moment to invite a few friends that you think will also like it?"
delegate:self
cancelButtonTitle:@"No Thanks"
otherButtonTitles:@"Tell Friends!", nil];
[alert show];
}
- (void)alertView:(UIAlertView *)alertView
didDismissWithButtonIndex:(NSInteger)buttonIndex {
if (buttonIndex == 0) {
// User has clicked on the No Thanks button, do not ask again
NSLog(@"Chitty user says he doesn't wanna share");
} else if (buttonIndex == 1) {
// User has clicked on the Tell Friends button
[self performSelector:@selector(sendRequest) withObject:nil afterDelay:0.5];
}
}
- (void)sendRequest {
// Display the requests dialog
NSMutableDictionary* params = [NSMutableDictionary dictionaryWithObjectsAndKeys:nil];
[FBWebDialogs presentRequestsDialogModallyWithSession:nil
message:[NSString stringWithFormat:@"Try this app, brah!"]
title:nil
parameters:params
handler:^(FBWebDialogResult result, NSURL *resultURL, NSError *error) {
if (error) {
// Case A: Error launching the dialog or sending request.
NSLog(@"Error sending request.");
} else {
if (result == FBWebDialogResultDialogNotCompleted) {
// Case B: User clicked the "x" icon
NSLog(@"User canceled request.");
} else {
NSLog(@"Request Sent.");
}
}}];
}
然而,當我選擇的用戶我想發送的邀請到誰,然後點擊發送。什麼都沒發生。我確實收到了「請求已發送」。通過NSLog,但我的朋友沒有收到它。
任何想法?