【问题标题】:Invite facebook users from iOS application in facebook: invitation is not being sent从 Facebook 中的 iOS 应用程序邀请 facebook 用户:未发送邀请
【发布时间】:2013-04-14 19:27:06
【问题描述】:

我正在尝试邀请 Facebook 中的用户试用我的 iOS 应用(尚未上架,尚未完成)。

我使用 facebook API 对用户进行身份验证,然后尝试使用以下代码:

- (void)shareWithFriends:(id)sender
{
    UIAlertView *alert = [[UIAlertView alloc]
                          initWithTitle:@"Invite Friends"
                          message:@"If you enjoy using this app, would you mind taking a moment to invite a few friends that you think will also like it?"
                          delegate:self
                          cancelButtonTitle:@"No Thanks"
                          otherButtonTitles:@"Tell Friends!", nil];
    [alert show];
}

- (void)alertView:(UIAlertView *)alertView
didDismissWithButtonIndex:(NSInteger)buttonIndex {
    if (buttonIndex == 0) {
        // User has clicked on the No Thanks button, do not ask again
        NSLog(@"Chitty user says he doesn't wanna share");
    } else if (buttonIndex == 1) {
        // User has clicked on the Tell Friends button
        [self performSelector:@selector(sendRequest) withObject:nil afterDelay:0.5];
    }
}

- (void)sendRequest {
    // Display the requests dialog

    NSMutableDictionary* params = [NSMutableDictionary dictionaryWithObjectsAndKeys:nil];
    [FBWebDialogs presentRequestsDialogModallyWithSession:nil
                                                  message:[NSString stringWithFormat:@"Try this app, brah!"]
                                                    title:nil
                                               parameters:params
                                                  handler:^(FBWebDialogResult result, NSURL *resultURL, NSError *error) {
                                                      if (error) {
                                                          // Case A: Error launching the dialog or sending request.
                                                          NSLog(@"Error sending request.");
                                                      } else {
                                                          if (result == FBWebDialogResultDialogNotCompleted) {
                                                              // Case B: User clicked the "x" icon
                                                              NSLog(@"User canceled request.");
                                                          } else {
                                                              NSLog(@"Request Sent.");
                                                          }
                                                      }}];


}

但是,当我选择要向其发送邀请的用户然后点击发送时。什么都没发生。我确实收到“请求已发送”。通过 NSLog 但我的朋友没有收到它。

有什么想法吗?

【问题讨论】:

    标签: ios xcode facebook


    【解决方案1】:

    你怎么知道你的请求没有到达其他用户? 您必须知道他们不会收到任何通知,他们可以通过 this 链接访问它:

    您的应用中必须有一个 Facebook 应用作为带有画布页面的平台。然后用户会收到通知。

    【讨论】:

      【解决方案2】:

      这始终取决于您的应用所在的平台。例如:如果您有一个只能在手机上使用的应用程序,受邀的朋友只会在他们的手机上看到请求,而不是在 facebook.com 上。如果您在 facebook.com 上也有画布应用,它也会出现在 facebook.com 上。

      您可以在有关应用程序发送的请求的“接收体验”[1] 的文档中了解更多信息。

      [1]https://developers.facebook.com/docs/games/requests/v2.0#receive

      【讨论】:

        【解决方案3】:

        我注意到通知消息只出现在 Android/iOS 的 Facebook 应用程序中,但是网络用户看不到它,我希望它不是 Facebook 的实现?此外,为了确保您的邀请成功发送,您必须解析 resultURL 查询。

        NSDictionary *parameters = @{@"to":@""};
        
        [FBWebDialogs presentRequestsDialogModallyWithSession:nil
                                                              message:SL_FB_INVITE_DESCRIPTION
                                                                title:SL_FB_INVITE_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] autorelease];
                         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] autorelease];
            for (NSString *pair in pairs)
            {
                NSArray *kv = [pair componentsSeparatedByString:@"="];
        
                [params setObject:[[kv objectAtIndex:1] stringByReplacingPercentEscapesUsingEncoding:NSUTF8StringEncoding]
                           forKey:[[kv objectAtIndex:0] stringByReplacingPercentEscapesUsingEncoding:NSUTF8StringEncoding]];
            }
        
            return params;
        }
        

        【讨论】:

          【解决方案4】:

          你什么时候填充参数?

          我知道如果您发送一个空白的 Facebook 用户名作为收件人,FB API 会发送一个已完成的操作

          【讨论】:

            猜你喜欢
            • 2012-12-02
            • 1970-01-01
            • 1970-01-01
            • 1970-01-01
            • 2013-02-26
            • 1970-01-01
            • 1970-01-01
            • 1970-01-01
            • 1970-01-01
            相关资源
            最近更新 更多