iOS Facebook SDK邀请好友请求已发送,但好友没有收到通知

5
我正在尝试使用以下方法,从我的iOS原生应用程序通过Facebook SDK向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;
}

使用上述代码,我能够获取所有朋友的列表,并在选择多个或单个朋友后成功发送请求。但是当我的朋友在web或Facebook原生应用程序中打开Facebook时,他们没有收到任何通知或消息。我找不到代码错误所在。
请帮我查找错误并解决问题。

使用此链接,它将正常工作 https://dev59.com/aGbWa4cB1Zd3GeqPbeA2 - user5422736
1个回答

5

您需要在 Facebook 上配置您的应用程序,通过传递一些虚拟的 URL。我之前也遇到了同样的问题,这样做对我有用。

前往 developer.facebook.com,选择您的应用程序,选择设置,添加平台 -> 添加应用程序,在那里传递任何虚拟的 URL,并为您的应用程序添加图像,该图像将显示在应用程序详细信息屏幕中。


需要提交才能做这个吗? - Khoi Nguyen
@GấuUni 不需要提交您的应用程序来完成此操作。请记得使您的应用程序上线(默认情况下,它处于沙盒模式,不允许使用其他 FB 帐户进行测试,除非是注册的 FB 帐户)。 - Rahul Mathur
1
我已经将其公开。每个人都可以授权。我成功发送了请求。但是我的朋友在网页或移动设备上没有收到任何通知。请帮帮我。你能给我一个联系你的方式吗? - Khoi Nguyen
请问在哪里可以添加网址和图片?我没有看到相关选项。请告诉我,我也遇到了同样的问题。@nitin - Mohit

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接