Search code examples
swiftdeep-linkingapplinksbranch.io

Examples of Facebook AppInvites with Branch.io in Swift


Branch has great examples of how to create their deep links with AppLinks in Swift but I can't find any examples of how to create Facebook's AppInvites in Swift. Has anyone done this yet?


Solution

  • Branch for works following the solution here: Swift implementation of FBSDKAppInviteDialogDelegate not working

    Generate the Branch URL and present the share dialog from the callback there.

    var inviteDialog: FBSDKAppInviteDialog = FBSDKAppInviteDialog()
    
    Branch.getInstance().getShortURLWithParams(params, andChannel: "facebook", andFeature: "app_invite", andCallback: { (branchUrl: String?, error: NSError?) -> Void in
    
                    if error == nil {
    
                    var inviteContent: FBSDKAppInviteContent = FBSDKAppInviteContent()
    
                    inviteContent.appLinkURL = NSURL(string: branchUrl!)!
    
                    inviteDialog.content = inviteContent
                    inviteDialog.delegate = self
                    inviteDialog.show()
                }
            })