How to invite Facebook friends to my iOS application in Swift?

572 Views Asked by At

I am developping an iOS application using Swift 4.

I need that the user can invite his Facebook friends to use this application.

I tried this code :

 func inviteFacebookFriends(){

    let dialog = FBSDKAppInviteDialog()
    let content:FBSDKAppInviteContent = FBSDKAppInviteContent()
    content.appLinkURL = URL(string: "https://example/fbid")
    content.appInvitePreviewImageURL = URL(string: "http://www.queness.com/resources/images/png/apple_ex.png")
    dialog.content = content
    dialog.delegate = self
    do {
        try dialog.validate()
    }
    catch {
        print(error)
    }

    dialog.show()
}

But nothing happened, there's no dialog appears.

please help me to solve this issue.

1

There are 1 best solutions below

0
AnthoPak On

Facebook invite is no longer allowed by Facebook SDK. There's no way to use FBSDKAppInviteDialog anymore.

With the release of the Facebook SDK version 4.28.0, App Invites is deprecated. It will be supported until February 5, 2018.

From Facebook docs

You will have to find an other way than Facebook to invite friends.