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

后端 未结 8 450
攒了一身酷
攒了一身酷 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: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);
      

提交回复
热议问题