Application crashes with Facebook Login SDK when I go to the home screen

I initially downloaded the FBSDK version 4.10 and integrated them into my application by placing them in the frameworks folder. Understanding that over time they will not be updated, I completely deleted them and tried to add them as modules in my project. The packages were installed successfully, I imported them correctly in my header file, and there were no other problems. Updating the modules updated version 4.11, which caused me some headache.

I use FBSDKLoginKit to log in a user to my account and get information from it. I can get a dictionary with user information just fine. Then I pass this information to the next ViewController using segue. At any time after this, if I press the home button on my iPhone or simulator, the application will crash. The error I get is this

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

This exception also occurs if I allow the user to log in via facebook, switch to the new view controller, break away from the previous view controller and then try to log in again. I tried to register the user after receiving their relevant information on the second screen, but the error still persists.

I saw a similar question, where the "solution" was that FBSDKLoginKit writes the resulting dictionary to a variable, and if the dictionary that it received back is nil, it throws this error.

Is there anything I can do to catch this before this happens? Has anyone found a job 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: termination with an uncaught exception of type NSException

Running my code step by step, I found that an error occurs during the method:

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

Failure before I can even check the meaning of the error. I will try to check the values ​​by going to fbsdk methods and updating

fbsdk permissions for browser login

As soon as I click OK on this screen a second time, it crashes. How can I debug this? The action is not in my application, it is in the browser, so I'm not sure where to go from here.

+7
ios swift fbsdk
source share
3 answers

I recently ran into these problems, and I solved it by adding this piece of code to Appdelegate.m .

 - (void)applicationDidBecomeActive:(UIApplication *)application { [FBSDKAppEvents activateApp]; } 

For Swift 3 version:

 func applicationDidBecomeActive(_ application: UIApplication) { FBSDKAppEvents.activateApp() } 
+3
source share

Update to 4.12, it fixes the problem in accordance with their release notes:

https://developers.facebook.com/docs/ios/change-log-4.x/

The part that reads:

Fixed

  • Fixed cases where AppEvents could crash due to the lack of a session identifier.
  • Fixed a bug in some cases when the expiration date of the access token was the date of the update.
+1
source share

Although this is not necessarily a complete solution, I have exhausted my debugging methods. I removed FBSDK from my podfile, performed a pod update to remove them from the project, and reinstalled FBSDK version 4.10 in my frameworks folder. I will update this question, try again when facebook releases the updated version of FBSDK.

0
source share

All Articles