iOS Facebook sdk邀请朋友请求已发送但未收到朋友通知

时间:2014-02-21 05:32:39

标签: ios facebook facebook-sharer facebook-invite

我正在尝试使用facebook SDK使用以下方法从我的iOS原生应用程序向Facebook好友发送App邀请。

-(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;
}

使用上面的代码,我得到了所有朋友的列表,在检查了多个或单个朋友后,该请求已成功发送。但是,当我的朋友在网络或Facebook本地应用程序中打开Facebook时,没有收到任何通知或消息。我无法找到代码中的错误。

请帮我解决这个问题。我的错误在哪里,我该如何解决?

1 个答案:

答案 0 :(得分:5)

你必须通过传递一些虚拟网址在Facebook上配置你的应用程序,我也面临同样的问题,这样做对我有用。 转到developer.facebook.com,选择你的应用,选择设置,AddPlatform ---> addApplication,在那里传递任何虚拟网址,还为您的应用添加图片,该图片将在应用详情scrren的通知中显示。