I've been looking for an equivalent Swift code sample for Facebook friend invite for iOS apps. But I can't find them.
I understand that there is the Objective-C version on Facebook page https://developers.facebook.com/docs/app-invites/ios. However, because I started off with Swift, I find it difficult to translate.
Could someone point me to a source? Thank you.
the code working :
-In viewDidLoad :
let content = FBSDKAppInviteContent()
content.appLinkURL = NSURL(string: "https://test/myapplink")
content.appInvitePreviewImageURL = NSURL(string: "https://test/myapplink")
// Old Way, now depreciated :
//FBSDKAppInviteDialog.showFromViewController(self, withContent: content, delegate: self)
//New way :
FBSDKAppInviteDialog.showFromViewController(self, withContent: content, delegate: self)
// Do any additional setup after loading the view.
-In your viewController to conform the protocol delegate:
extension InviteFriendsViewController: FBSDKAppInviteDialogDelegate{
func appInviteDialog(appInviteDialog: FBSDKAppInviteDialog!, didCompleteWithResults results: [NSObject : AnyObject]!) {
//TODO
}
func appInviteDialog(appInviteDialog: FBSDKAppInviteDialog!, didFailWithError error: NSError!) {
//TODO
}
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With