iOS Facebook sdk 邀请给朋友 Reqest 已发送,但未收到朋友的通知



我正在尝试使用以下方法使用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;
}

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

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

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

相关内容

  • 没有找到相关文章

最新更新