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?
I don't think it has anything to do with wifi or not. You should get a better phone I reckon.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.