[英]Facebook iOS SDK 3.2.1 - [NSError fberrorShouldNotifyUser]: unrecognized selector sent to instance
[英]unrecognized selector sent to instance at facebook login manager in facebook sdk 4.6 on iOS9
嗨,我剛剛將我的應用程序升級到 iOS 9 並使用 Facebook 的最新 SDK(4.6 版)進行 facebook 登錄。
我正在使用自定義登錄按鈕,因此使用 LoginManager 類。 在以前的版本中它運行良好,但現在每當我按下登錄按鈕說“無法識別的選擇器發送到實例”時,我的應用程序就會崩潰
下面是我在 GameScene 類中用於登錄的代碼。
var fbLogin = FBSDKLoginManager()
func onClickFBLogin(){
let vc = self.view?.window?.rootViewController
fbLogin.logInWithReadPermissions(["public_profile"] as [AnyObject], fromViewController: vc, handler: {(result:FBSDKLoginManagerLoginResult!, error:NSError!) -> Void in
if(error != nil){
print("Facebook login error \(error)")
} else if(result.isCancelled){
print("Facebook login cancelled")
} else{
print("facebook login successful")
if(self.isSaveMeButtonPressed){
print("facebook login successful")
}
}
})
}
該應用程序因 Xcode 上的以下日志而崩潰。
[FBSDKLoginManager logInWithReadPermissions:fromViewController:handler:]: 無法識別的選擇器發送到實例 0x7f82e51251e0
有人面臨同樣的問題嗎? 或者誰能幫我解決這個問題?
提前致謝。
更新 Facebook SDK 時出現問題。 似乎 Facebook 已經通過提供一個包文件改變了它過去在 Documents 文件夾中安裝 SDK 的方式,但現在它提供了一個無法安裝的 zip 文件。 因此,我只是替換了 ~\\Documents\\FacebookSDK 文件夾中的現有文件。 在那之后,看起來 Xcode 占用了一部分更新代碼,而有些仍然保持不變。
我從我的項目中刪除了所有框架,並重新添加了我們在 Xcode 中添加框架的通常方式。 它現在工作正常。
Facebook 應更新其有關如何更新到較新 SDK 的文檔。
對於 iOS 9,您可以向 info.plist 添加更多密鑰。 此錯誤可能與此有關。
<key>NSAppTransportSecurity</key>
<dict>
<key>NSExceptionDomains</key>
<dict>
<key>facebook.com</key>
<dict>
<key>NSIncludesSubdomains</key> <true/>
<key>NSExceptionRequiresForwardSecrecy</key> <false/>
</dict>
<key>fbcdn.net</key>
<dict>
<key>NSIncludesSubdomains</key> <true/>
<key>NSExceptionRequiresForwardSecrecy</key> <false/>
</dict>
<key>akamaihd.net</key>
<dict>
<key>NSIncludesSubdomains</key> <true/>
<key>NSExceptionRequiresForwardSecrecy</key> <false/>
</dict>
</dict>
</dict>
另一個可能的問題是從 CocoaPod 安裝 facebook Pod。 從項目中的 Podfile 中刪除 pod,運行 pod install,您將看到 facebook pod 從項目中刪除。 我使用了他們網站上的 facebook SDK 並手動導入了框架(並使用他們的說明完成了 facebook SDK 集成)。 重新編譯並再次運行您的應用程序...
這是我得到的完整錯誤:
Checklists[14748:612592] *** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[FBSDKLoginManager isAuthenticationURL:]: unrecognized selector sent to instance 0x6000002887f0'
*** First throw call stack:
(
0 CoreFoundation 0x000000010999212b __exceptionPreprocess + 171
1 libobjc.A.dylib 0x000000010a55bf41 objc_exception_throw + 48
2 CoreFoundation 0x0000000109a13024 -[NSObject(NSObject) doesNotRecognizeSelector:] + 132
3 CoreFoundation 0x0000000109914f78 ___forwarding___ + 1432
4 CoreFoundation 0x0000000109914958 _CF_forwarding_prep_0 + 120
5 FBSDKCoreKit 0x00000001096e58b3 -[FBSDKApplicationDelegate openURLWithSafariViewController:sender:fromViewController:handler:] + 355
6 Checklists 0x0000000108b513ed -[FBSDKLoginManager(Native) performBrowserLogInWithParameters:handler:] + 654
7 Checklists 0x0000000108b50450 -[FBSDKLoginManager logInWithBehavior:] + 483
8 Checklists 0x0000000108b50250 -[FBSDKLoginManager logInWithPermissions:handler:] + 312
9 Checklists 0x0000000108b4ecde -[FBSDKLoginManager logInWithReadPermissions:fromViewController:handler:] + 280
10 Checklists 0x0000000108b4b757 -[FBSDKLoginButton _buttonPressed:] + 1662
11 UIKit 0x000000010b504972 -[UIApplication sendAction:to:from:forEvent:] + 83
12 UIKit 0x000000010b683c3c -[UIControl sendAction:to:forEvent:] + 67
13 UIKit 0x000000010b683f59 -[UIControl _sendActionsForEvents:withEvent:] + 450
14 UIKit 0x000000010b682e86 -[UIControl touchesEnded:withEvent:] + 618
15 UIKit 0x000000010b57a807 -[UIWindow _sendTouchesForEvent:] + 2807
16 UIKit 0x000000010b57bf2a -[UIWindow sendEvent:] + 4124
17 UIKit 0x000000010b51f365 -[UIApplication sendEvent:] + 352
18 UIKit 0x000000010be6ba1d __dispatchPreprocessedEventFromEventQueue + 2809
19 UIKit 0x000000010be6e672 __handleEventQueueInternal + 5957
20 CoreFoundation 0x0000000109935101 __CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE0_PERFORM_FUNCTION__ + 17
21 CoreFoundation 0x00000001099d4f71 __CFRunLoopDoSource0 + 81
22 CoreFoundation 0x0000000109919a19 __CFRunLoopDoSources0 + 185
23 CoreFoundation 0x0000000109918fff __CFRunLoopRun + 1279
24 CoreFoundation 0x0000000109918889 CFRunLoopRunSpecific + 409
25 GraphicsServices 0x0000000110ae99c6 GSEventRunModal + 62
26 UIKit 0x000000010b5035d6 UIApplicationMain + 159
27 Checklists 0x0000000108b49747 main + 55
28 libdyld.dylib 0x000000010e45dd81 start + 1
29 ??? 0x0000000000000001 0x0 + 1
)
libc++abi.dylib: terminating with uncaught exception of type NSException
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.