当我进入主屏幕时,应用程序使用Facebook登录SDK崩溃 [英] App crashes using Facebook Login SDK when I go to the home screen

查看:1276
本文介绍了当我进入主屏幕时,应用程序使用Facebook登录SDK崩溃的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我最初下载了FBSDK的4.10版,并将它们放在我的应用程序中,方法是将它们放在frameworks文件夹中。意识到这些不会随着时间的推移而更新,我完全删除它们并尝试将它们作为pod添加到我的项目中。 pod已成功安装,我已在我的桥接头文件中正确导入它们,并且没有其他问题。 pods更新安装版本4.11,这让我有些头痛。

I originally downloaded the FBSDK's version 4.10 and integrated them into my application by placing them in the frameworks folder. Realizing that these would not get updated over time, I removed them completely and tried to add them as pods to my project. The pods installed successfully, I have imported them correctly in my bridging header file, and there were no other issues. The pods update installed version 4.11 which has caused me some headache.

我正在使用FBSDKLoginKit将用户登录到他们的帐户并从中检索信息。我能够收到一个包含用户信息的字典就好了。然后我将此信息传递给带有segue的下一个ViewController。在此之后的任何时候,如果我按下iPhone或模拟器上的主页按钮,应用程序将崩溃。我得到的错误是

I am using the FBSDKLoginKit to log a user into their account and retrieve information from that. I am able to get back a dictionary with the users information just fine. I then pass this information to the next ViewController with a segue. At any point after this, if I press the home button on my iPhone or simulator, the app will crash. The error I get is

*** Terminating app due to uncaught exception 'NSInvalidArgumentException',
reason: '*** -[__NSPlaceholderDictionary initWithObjects:forKeys:count:]: 
attempt to insert nil object from objects[3]'

如果我让用户通过facebook登录,转到新视图控制器,展开到上一个视图控制器,然后再次尝试登录,也会发生此异常。我曾尝试在第二个屏幕上检索相关信息后将用户注销,但错误仍然存​​在。

This exception also occurs if I let the user log in through facebook, segue to the new view controller, unwind to the previous view controller, and then attempt to log in again. I have attempted to log the user out once retrieving their pertinent information on the second screen, but the error still persists.

我看到一个类似的问题询问解决方案 是FBSDKLoginKit将检索到的字典写入变量,如果它检索到的字典有nil值,则会抛出此错误。

I have seen a similar question asked where the "solution" was that the FBSDKLoginKit writes the retrieved dictionary to a variable and if the dictionary it has retrieved back has nil values, it throws this error.

在发生之前我能做些什么才能抓住这个?有没有人找到工作?

Is there anything I can do to catch this before it happens? Has anyone found a work around?

当我按下主页时,这是模拟器的输出:

Here is my output from the simulator when I press home:

*** First throw call stack:
(
0   CoreFoundation                      0x0000000106f03d85 __exceptionPreprocess + 165
1   libobjc.A.dylib                     0x000000010643edeb objc_exception_throw + 48
2   CoreFoundation                      0x0000000106e0023e -[__NSPlaceholderDictionary initWithObjects:forKeys:count:] + 318
3   CoreFoundation                      0x0000000106e125bb +[NSDictionary dictionaryWithObjects:forKeys:count:] + 59
4   APPNAME                               0x0000000101607a1e -[FBSDKTimeSpentData instanceSuspend] + 622
5   APPNAME                                0x000000010160766b +[FBSDKTimeSpentData suspend] + 59
6   APPNAME                                0x00000001015b5986 -[FBSDKAppEvents applicationMovingFromActiveStateOrTerminating] + 262
7   CoreFoundation                      0x0000000106ecdc8c __CFNOTIFICATIONCENTER_IS_CALLING_OUT_TO_AN_OBSERVER__ + 12
8   CoreFoundation                      0x0000000106ecd9cb _CFXRegistrationPost + 427
9   CoreFoundation                      0x0000000106ecd732 ___CFXNotificationPost_block_invoke + 50
10  CoreFoundation                      0x0000000106f161e2 -[_CFXNotificationRegistrar find:object:observer:enumerator:] + 1986
11  CoreFoundation                      0x0000000106dc5679 _CFXNotificationPost + 633
12  Foundation                          0x000000010372ccd9 -[NSNotificationCenter postNotificationName:object:userInfo:] + 66
13  UIKit                               0x0000000104a685ad -[UIApplication _deactivateForReason:notify:] + 629
14  UIKit                               0x0000000104a6f1f1 __61-[UIApplication _sceneSettingsPreLifecycleEventDiffInspector]_block_invoke + 104
15  FrontBoardServices                  0x0000000108f88d6c __52-[FBSSettingsDiffInspector inspectDiff:withContext:]_block_invoke27 + 213
16  Foundation                          0x000000010377d5bb __NSIndexSetEnumerate + 1016
17  BaseBoard                           0x000000010901ba8c -[BSSettingsDiff inspectChangesWithBlock:] + 116
18  FrontBoardServices                  0x0000000108f83e4a -[FBSSettingsDiff inspectOtherChangesWithBlock:] + 92
19  FrontBoardServices                  0x0000000108f88b2f -[FBSSettingsDiffInspector inspectDiff:withContext:] + 317
20  UIKit                               0x0000000104a70880 __70-[UIApplication scene:didUpdateWithDiff:transitionContext:completion:]_block_invoke + 127
21  UIKit                               0x0000000104a7052d -[UIApplication scene:didUpdateWithDiff:transitionContext:completion:] + 843
22  FrontBoardServices                  0x0000000108f978c8 __FBSSERIALQUEUE_IS_CALLING_OUT_TO_A_BLOCK__ + 24
23  FrontBoardServices                  0x0000000108f97741 -[FBSSerialQueue _performNext] + 178
24  FrontBoardServices                  0x0000000108f97aca -[FBSSerialQueue _performNextFromRunLoopSource] + 45
25  CoreFoundation                      0x0000000106e29301 __CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE0_PERFORM_FUNCTION__ + 17
26  CoreFoundation                      0x0000000106e1f22c __CFRunLoopDoSources0 + 556
27  CoreFoundation                      0x0000000106e1e6e3 __CFRunLoopRun + 867
28  CoreFoundation                      0x0000000106e1e0f8 CFRunLoopRunSpecific + 488
29  GraphicsServices                    0x0000000108ae7ad2 GSEventRunModal + 161
30  UIKit                               0x0000000104a72f09 UIApplicationMain + 171
31  APPNAME                                0x00000001013a26d2 main + 114
32  libdyld.dylib                       0x0000000107b0d92d start + 1
33  ???                                 0x0000000000000001 0x0 + 1


libc ++ abi.dylib:以未捕获的异常终止类型NSException

) libc++abi.dylib: terminating with uncaught exception of type NSException

逐步运行我的代码我发现在方法期间发生错误:

Running my code step by step I find that the error occurs during the method:

fbLoginManager.logInWithReadPermissions(permissionsNeeded, fromViewController: self) { (result, error) -> Void in 
//crashes before it enters this block    
//my code here
}

在我甚至可以检查错误值之前它崩溃了。我将尝试通过步入fbsdk方法检查值并更新

It crashes before I can even check the error value. I will attempt to check the values by stepping into the fbsdk methods and update

第二次在此屏幕上按OK时,它会崩溃。我该怎么调试呢?这个动作不在我的应用程序中,它在浏览器中,所以我不知道从哪里开始..

As soon as I press OK on this screen for the second time it crashes. How can I debug this? The action isn't in my app, its in the browser so I'm not sure where to go from here..

推荐答案

我最近遇到过这个问题,我通过在 Appdelegate.m 中添加这段代码解决了这个问题。

I have came across this issues recently, and i solved it by adding this piece of code in Appdelegate.m.

- (void)applicationDidBecomeActive:(UIApplication *)application {    

    [FBSDKAppEvents activateApp];
}

对于Swift 3版本:

For Swift 3 version:

func applicationDidBecomeActive(_ application: UIApplication) {

    FBSDKAppEvents.activateApp()
}

这篇关于当我进入主屏幕时,应用程序使用Facebook登录SDK崩溃的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆