How to invite friends to my application via facebook iOS SDK and Graph API

后端 未结 8 449
攒了一身酷
攒了一身酷 2021-02-01 17:55

I\'m writing an iPhone application.

I want to give the user the option to invite friends to start using my application via Facebook.

More specifically I want to

相关标签:
8条回答
  • 2021-02-01 18:36

    You can do something like this:

    Facebook* facebook = 
       [[Facebook alloc] initWithAppId:@"YOUR_FACEBOOK_APP_ID" andDelegate:self];
    
    NSMutableDictionary* params = [NSMutableDictionary dictionaryWithObjectsAndKeys:
                                           @"My Title", @"title",
                                           @"Come check out my app.",  @"message",
                                           @"FACEBOOK_USER_ID", @"to",
                                           nil]; 
    
    [facebook dialog:@"apprequests" andParams:params andDelegate:self];
    

    You can see the list of possible parameters at this page (scroll down): http://developers.facebook.com/docs/reference/dialogs/requests/

    0 讨论(0)
  • 2021-02-01 18:38

    To send facebook app invites, you need to first add details of your app here.. https://developers.facebook.com/quickstarts/?platform=app-links-host

    In Swift 2.2, XCode 7.3 and FBSDK 4.1

    1. import FBSDKShareKit import FBSDKCoreKit import FBSDKLoginKit

    2. Add FBSDKAppInviteDialogDelegate with your ViewController class.

      func appInviteDialog(appInviteDialog: FBSDKAppInviteDialog!, didCompleteWithResults results: [NSObject : AnyObject]!) {
          print("Initiation sent")
      
      }
      func appInviteDialog(appInviteDialog: FBSDKAppInviteDialog!, didFailWithError error: NSError!) {
          print("\(error)")
      }
      
    3.     let content = FBSDKAppInviteContent();
          content.appLinkURL = NSURL(string: "fb link that you get in above developers facebook url"); //"https:// fb.me/1775107252721102" in my case
          FBSDKAppInviteDialog.showFromViewController(self, withContent: content, delegate: self);
      
    0 讨论(0)
提交回复
热议问题