我正在尝试使用以下方法使用 facebook SDK 从我的 iOS 本机应用程序向 Facebook 朋友发送应用程序邀请。
-(IBAction)ShowFiendDialog:(id)sender
{
NSDictionary *parameters = @{@"to":@""};
[FBWebDialogs presentRequestsDialogModallyWithSession:FBSession.activeSession
message:@"my message"
title:@"my title"
parameters:parameters
handler:^(FBWebDialogResult result, NSURL *resultURL, NSError *error)
{
if(error)
{
NSLog(@"Some errorr: %@", [error description]);
UIAlertView *alrt = [[UIAlertView alloc] initWithTitle:@"Invitiation Sending Failed" message:@"Unable to send inviation at this Moment, please make sure your are connected with internet" delegate:nil cancelButtonTitle:@"OK" otherButtonTitles: nil];
[alrt show];
//[alrt release];
}
else
{
if (![resultURL query])
{
return;
}
NSDictionary *params = [self parseURLParams:[resultURL query]];
NSMutableArray *recipientIDs = [[NSMutableArray alloc] init];
for (NSString *paramKey in params)
{
if ([paramKey hasPrefix:@"to["])
{
[recipientIDs addObject:[params objectForKey:paramKey]];
}
}
if ([params objectForKey:@"request"])
{
NSLog(@"Request ID: %@", [params objectForKey:@"request"]);
}
if ([recipientIDs count] > 0)
{
//[self showMessage:@"Sent request successfully."];
//NSLog(@"Recipient ID(s): %@", recipientIDs);
UIAlertView *alrt = [[UIAlertView alloc] initWithTitle:@"Success!" message:@"Invitation(s) sent successfuly!" delegate:nil cancelButtonTitle:@"OK" otherButtonTitles: nil];
[alrt show];
//[alrt release];
}
}
}friendCache:nil];
}
- (NSDictionary *)parseURLParams:(NSString *)query
{
NSArray *pairs = [query componentsSeparatedByString:@"&"];
NSMutableDictionary *params = [[NSMutableDictionary alloc] init];
for (NSString *pair in pairs)
{
NSArray *kv = [pair componentsSeparatedByString:@"="];
[params setObject:[[kv objectAtIndex:1] stringByReplacingPercentEscapesUsingEncoding:NSUTF8StringEncoding]
forKey:[[kv objectAtIndex:0] stringByReplacingPercentEscapesUsingEncoding:NSUTF8StringEncoding]];
}
return params;
}
使用上面的代码,我得到了 Prompt all my friends' list 并且在检查了多个或单个朋友之后,该请求已成功发送。但是当我的朋友在网络或 facebook 原生应用程序中打开 facebook 时,不会收到任何通知或消息。我找不到代码中的错误在哪里。
请帮助我。我的错误在哪里,我该如何解决?