iOS 기본 앱에서 아래의 방법으로 Facebook SDK를 사용하여 Facebook 친구에게 App에 대한 초대장을 보내려고합니다.iOS Facebook sdk 친구 초대 Reqest 친구에게 Notificaton을받지 못함
-(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;
}
위의 코드를 사용하여 모든 친구의 목록을 표시하고 여러 명 또는 단일 친구를 확인한 후 해당 요청이 성공적으로 전송되었습니다. 하지만 내 친구들이 웹이나 페이스 북의 네이티브 앱에서 페이스 북을 열면 알림이나 메시지가 수신되지 않습니다. 코드에서 실수가있는 부분을 찾을 수 없습니다.
도와주세요. 내 실수는 어디에서 어떻게 해결할 수 있습니까?
이 링크를 사용하면 작동합니다. http://stackoverflow.com/questions/11796445/facebook-app-requests-arent-shown-on-ios-devices –