【问题标题】:Inviting friends to use my ios app via Facebook邀请朋友通过 Facebook 使用我的 ios 应用程序
【发布时间】:2014-06-26 04:04:04
【问题描述】:

我刚刚开始处理一个现有项目,我应该在其中添加功能以邀请您的 Facebook 朋友使用该应用程序。它使用 Parse 的 PFFacebookUtils 进行连接,我正在尝试使用 Facebook API 来获取您的整个朋友列表,以便您可以选择他们并邀请他们下载和使用该应用程序。

由于 V2 API 这甚至可能吗?据我所知,您只能获得已经使用该应用程序的朋友列表(没用),或者您可以获得“邀请朋友”列表,但前提是它是 Facebook Canvas 游戏,这个应用程序不是。我认为通过 Facebook 邀请人们使用您的应用程序是一种很常见的功能,但 Facebook 是否已弃用此功能?我希望有人知道我不知道的事情,并且有办法实现这一点。

提前致谢!

【问题讨论】:

    标签: ios facebook facebook-graph-api


    【解决方案1】:

    您应该仍然可以对新应用使用“请求”对话框(允许用户选择将请求发送给谁),而无需特殊权限

    只有在您构建自己的界面并且需要枚举用户可以向哪些用户发送请求时才需要邀请好友 API,如果没有它,请求对话框本身应该仍然可以工作

    请求对话框的使用文档在这里https://developers.facebook.com/docs/games/requests/v2.0 iOS 特定教程有一个使用示例,涵盖了一些用例:https://developers.facebook.com/docs/games/mobile/ios-tutorial#requests 更多参考文档:https://developers.facebook.com/docs/ios/ui-controls#requestdialog

    【讨论】:

      【解决方案2】:

      您应该使用 Facebook GameRequest。 它完全由 Facebook 控制,您无需执行任何操作。您可以指定一些属性(例如请求的消息、标题、过滤器、您以后可以在受邀用户安装您的应用程序时使用的额外数据等)。您还可以实现一个委托类,并获取有关成功或失败、邀请了多少朋友等信息。

      一些基本的 iOS 用法例如:

      FBSDKGameRequestContent *gameRequestContent = [[FBSDKGameRequestContent alloc] init];
          gameRequestContent.message = @"Please come play <you_game> with me!";
          gameRequestContent.title = @"INVITE FRIENDS TO PLAY <your_game>";
          gameRequestContent.data = "some_extra_data_on_this_request"
          gameRequestContent.filters = FBSDKGameRequestFilterAppNonUsers; // filter says that only Non-App users will appear in the list
      
      // implement delegate as well:
          MyGameRequestDialogDelegate* myGameRequestDialogDelegate = [[ MyGameRequestDialogDelegate alloc] init];
      
      // show the game request dialog
          [FBSDKGameRequestDialog showWithContent:gameRequestContent delegate:myGameRequestDialogDelegate];
      

      委托类:

      @interface MyGameRequestDialogDelegate : NSObject < FBSDKGameRequestDialogDelegate >    
      
      @end
      
      @implementation MyGameRequestDialogDelegate
      
       - (void)gameRequestDialog:(FBSDKGameRequestDialog *)gameRequestDialog didCompleteWithResults:(NSDictionary *)results
       {
          NSLog(@"FBSDKGameRequest Success");
      
          NSArray* arr = [results objectForKey:@"to"];
          if (arr)
          {
             // get number of invited friends
             unsigned long count = [arr count];
          }
      }
      
      - (void)gameRequestDialogDidCancel:(FBSDKGameRequestDialog *)gameRequestDialog
      {
          NSLog(@"FBSDKGameRequest User Cancelled");
      }
      
      - (void)gameRequestDialog:(FBSDKGameRequestDialog *)gameRequestDialog
               didFailWithError:(NSError *)error
      {
          NSLog(@"FBSDKGameRequest Error: %@", error);
      }
      

      有关完整文档,请参阅: https://developers.facebook.com/docs/games/services/gamerequests/

      【讨论】:

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