2017-03-31 72 views
0

我試圖利用Facebook應用程式邀請,通過使用本指南: Facebook App Invites iOS和我的代碼如下:iOS版Facebook應用邀請只能通過WiFi

@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)「) 
} 

然而,這隻能顯示好友列表共享當它通過Wi-Fi並且在3G/LTE上無法使用時,對話窗口就會關閉並進入錯誤方法。有沒有辦法讓它始終工作,不僅在Wi-Fi上?或者這是一個Facebook錯誤?

回答

0

我不認爲它與WiFi有什麼關係。你應該得到一個我認爲更好的電話。

+0

它與手機無關,因爲這意味着我有6個以上有缺陷的手機,而且之前用戶回覆了他發生的情況,但他刪除了他的答案。 – Raykud

相關問題