我已經實現Facebook的新的4.0 SDK程式邀請對話於iOS按:https://developers.facebook.com/docs/app-invites/iosFacebook應用邀請FBSDKAppInviteDialog不會針對測試用戶在iOS模擬器
我在模擬器上進行測試它。
當我用我真實的Facebook帳戶登錄時,「應用邀請」對話框出現,我看到我的所有朋友。爲了測試通知,但我想用Facebook的測試用戶,因爲這是該指南建議:
We have internal logic that determines whether a push notification is sent to the client. If we detect that the person has installed the app, we may not trigger a push notification. The best way to test push notifications is to use test users .
然而,當我登錄的測試用戶對我的應用程序,並嘗試打開它失敗的對話框以下錯誤:
Error in invite Error Domain=com.facebook.sdk.core Code=2 "The operation couldn’t be completed. (com.facebook.sdk.core error 2.)" UserInfo=0x7f989d8cbe00 {com.facebook.sdk:FBSDKErrorDeveloperMessageKey=Invalid method_results., com.facebook.sdk:FBSDKErrorArgumentNameKey=method_results}
如果我嘗試與實際手機上的相同測試用戶,它工作正常。看來這個問題只發生在模擬器上。
更新,提高我使用的代碼:
var inviteDialog : FBSDKAppInviteDialog = FBSDKAppInviteDialog()
if (inviteDialog.canShow()) {
let appLinkUrl : NSURL = NSURL(string: "https://fb.me/1616988365211522")!
let previewImageUrl : NSURL = NSURL(string: "http://upload.wikimedia.org/wikipedia/commons/4/4f/Polistes_May_2013-2.jpg")!
var inviteContent : FBSDKAppInviteContent = FBSDKAppInviteContent()
inviteContent.previewImageURL = previewImageUrl
inviteContent.appLinkURL = appLinkUrl
inviteDialog.content = inviteContent
inviteDialog.delegate = self
inviteDialog.show()
}
別處....
func appInviteDialog(appInviteDialog: FBSDKAppInviteDialog!, didCompleteWithResults results: [NSObject : AnyObject]!) {
// nothing to do here
println("Completed App Invite with results: \(results)")
}
func appInviteDialog(appInviteDialog: FBSDKAppInviteDialog!, didFailWithError error: NSError!) {
// don't know enough about the errors to let the user know
println("Error in App Invite: \(error)")
}
注意,這是我的應用程序的測試版本。 Apple App Store ID不是我的應用程序(顯然),但由於我的應用程序尚未在商店中,所以我需要添加一些內容以供測試。
請使用您正在使用的完整代碼示例和應用鏈接URL編輯您的問題。我已經測試了這一點,並按預期工作。 – corvuszero
@corvuszero我在模擬器中獲得好友列表,在選擇好友後,我看到邀請發送完成的過程,但我的好友沒有在他的Facebook帳戶上收到任何通知。可能是這個問題?在開發應用程序中沒有得到通知? – Hiren
@corvuszero我添加了我正在使用的代碼以及用於測試的應用鏈接網址。 – jeffjv