0

I'm trying to use Facebook App Invites by using this guide: Facebook App Invites iOS and my code is as follows:

@IBAction func tapInviteFriends() {
    if AccessToken.current?.authenticationToken == nil {
        AccessToken.current = AccessToken.init(authenticationToken: stringValue(object: UserDefaults.standard.string(forKey: “facebookToken”)))
    }

    let inviteDialog:FBSDKAppInviteDialog = FBSDKAppInviteDialog()

    if(inviteDialog.canShow()){
        let appLinkUrl:URL = URL(string: "https://fb<dot>me/1358637537516578")!
        let previewImageUrl:URL = URL(string: "http://is4.mzstatic.com/image/thumb/Purple122/v4/e6/a2/1a/e6a21ada-b51a-17fe-4522-6618f864cc80/source/175x175bb.jpg")!

        let inviteContent:FBSDKAppInviteContent = FBSDKAppInviteContent()
        inviteContent.appLinkURL = appLinkUrl
        inviteContent.appInvitePreviewImageURL = previewImageUrl
        inviteContent.destination = .facebook

        inviteDialog.content = inviteContent
        inviteDialog.delegate = self
        inviteDialog.fromViewController = self

        inviteDialog.show()
    }

}

func appInviteDialog(_ appInviteDialog: FBSDKAppInviteDialog!, didCompleteWithResults results: [AnyHashable : Any]!) {
    if results != nil{
        let resultObject = NSDictionary(dictionary: results)
        if let didCancel = resultObject.value(forKey: “completionGesture”)
        {
            if (didCancel as AnyObject).caseInsensitiveCompare(“Cancel”) == ComparisonResult.orderedSame
            {
                print(“User Canceled invitation dialog”)
            }
        }
    }
}

func appInviteDialog(_ appInviteDialog: FBSDKAppInviteDialog!, didFailWithError error: Error!) {
    print(“Error tool place in appInviteDialog \(error)“)
}

however this only shows the friend list to share when its over Wi-Fi and when its on 3G/LTE doesn't work and the dialog window just closes and goes to the error method. is there a way to make it always work not only when on Wi-Fi? or is this a Facebook error?

Raykud
  • 2,488
  • 3
  • 21
  • 41

1 Answers1

0

I don't think it has anything to do with wifi or not. You should get a better phone I reckon.

Dayo Choul
  • 861
  • 2
  • 9
  • 23
  • It has nothing to do with the phone as that would mean I have 6+ defective phones, moreover a user previously replied the same happened to him however he deleted his answer. – Raykud May 03 '17 at 18:00