Expo Facebook login crashes in iOS standalone app

iOS standalone app is crashing on click of Facebook button. It is working perfectly in dev environment and in Android standalone app.

Expo diagnostics:

  expo: ^42.0.0 => 42.0.1
  react: 16.13.1 => 16.13.1
  react-dom: 16.13.1 => 16.13.1
  react-native: 0.63.4 => 0.63.4
  react-native-web: ~0.13.12 => 0.13.18
  react-navigation: ^4.4.3 => 4.4.4
  Expo Workflow: bare

Expo Facebook version:
“expo-facebook”: “~11.3.1”

Error:
Presenting view controllers on detached view controllers is discouraged <RNSScreen: 0x7fd135c525d0>.
FBSDKLog: *** <activateApp, FBSDKAppEvents> is not called on the main thread. This can lead to errors.
FBSDKLog: *** <instanceRestore:, FBSDKTimeSpentData> is not called on the main thread. This can lead to errors.
*** Terminating app due to uncaught exception ‘NSInvalidArgumentException’, reason: ‘*** -[__NSPlaceholderDictionary initWithObjects:forKeys:count:]: attempt to insert nil object from objects[2]’
*** First throw call stack:
(
0 CoreFoundation 0x000000011bb8ae6e __exceptionPreprocess + 350
1 libobjc.A.dylib 0x000000011b0689b2 objc_exception_throw + 48
2 CoreFoundation 0x000000011bc1d9d1 _CFThrowFormattedException + 194
3 CoreFoundation 0x000000011bc28426 -[__NSPlaceholderDictionary initWithObjects:forKeys:count:].cold.4 + 38
4 CoreFoundation 0x000000011bbe96e7 -[__NSPlaceholderDictionary initWithObjects:forKeys:count:] + 247
5 CoreFoundation 0x000000011bb86d71 +[NSDictionary dictionaryWithObjects:forKeys:count:] + 49
6 xxxxxxxxx 0x000000010ebc5d39 __67-[EXFacebook logInWithReadPermissionsWithConfig:resolver:rejecter:]_block_invoke + 670
7 libdispatch.dylib 0x000000011d6b4951 _dispatch_call_block_and_release + 12
8 libdispatch.dylib 0x000000011d6b58cb _dispatch_client_callout + 8
9 libdispatch.dylib 0x000000011d6c1cdb _dispatch_main_queue_callback_4CF + 1042
10 CoreFoundation 0x000000011baee869 CFRUNLOOP_IS_SERVICING_THE_MAIN_DISPATCH_QUEUE + 9
11 CoreFoundation 0x000000011bae93b9 __CFRunLoopRun + 2041
12 CoreFoundation 0x000000011bae88a4 CFRunLoopRunSpecific + 404
13 GraphicsServices 0x000000011e95fbbe GSEventRunModal + 139
14 UIKitCore 0x00000001270a4964 UIApplicationMain + 1605
15 xxxx 0x000000010ead7fd0 main + 80
16 libdyld.dylib 0x000000011d73a1fd start + 1
17 ??? 0x0000000000000001 0x0 + 1
)
libc++abi.dylib: terminating with uncaught exception of type NSException

app.json file:

{

 "expo": {

"name": "xxxx",

"icon": "./assets/icons/ios.png",

"version": "1.0.1",

"sdkVersion":"42.0.0",

"slug": "xxx",

"privacy": "public",

"facebookAppId": "xxx",

"facebookDisplayName": "xxx",

"facebookScheme": "xxx",

"facebookAdvertiserIDCollectionEnabled": true,

"facebookAutoLogAppEventsEnabled": true,

"facebookAutoInitEnabled": true,

"assetBundlePatterns": [

  "**/*"

],

"ios": {

  "supportsTablet": true,

  "bundleIdentifier": "xxx",

  "googleServicesFile": "./GoogleService-Info.plist",

  "buildNumber": "0.1.1",

  "config": {

    "googleSignIn": {

      "reservedClientId": "com.googleusercontent.apps.651971123174-4o03smnbsq4gmp4qcgtalj7ik49g590g"

    }

  }

},

"android": {

  "package": "xxx",

  "versionCode": 2,

  "permissions": [

    "READ_EXTERNAL_STORAGE",

    "WRITE_EXTERNAL_STORAGE"

  ],

  "config": {

    "googleSignIn": {

      "apiKey": "xxx",

      "certificateHash": "xxx"

    }

  },

  "adaptiveIcon": {

    "foregroundImage": "./assets/icons/android.png",

    "backgroundColor": "#FFF"

  }

}

}

}

What functions does the button you are clicking call? You may want to check your Facebook app’s developer dashboard

Thank you @charliecruzan for the quick response. I am calling a function which has the following code

try {

       await Facebook.initializeAsync({

            appId: "xxx",appName:"xxx"

        });

        

        const {

            type,

            token

        } = await Facebook.logInWithReadPermissionsAsync({

            permissions: ['public_profile', 'email'],

            behavior: 'web'

        });

I have checked my Facebook developer dashboard and the details like App id, app name and all are correct.

But my Facebook app is not live, it is in development mode.

behavior is no longer a supported option for logInWithReadPermissionsAsync: Facebook - Expo Documentation

Thank you @charliecruzan. I will remove the behavior and will get back to you after testing.

I have removed the behavior option and tested in the simulator. I am still getting a crash.

are you sure the issue is with logInWithReadPermissionsAsync? what if you remove that and only call the init function? You should debug this the same way you debug any other issue in your app- remove pieces to isolate the offending call and then investigate why that call is failing

Yes @charliecruzan the problem is with logInWithReadPermissionsAsync. I have removed logInWithReadPermissionsAsync() and just tested with initializeAsync(), there is no crash. Then I tested running only with initializeAsync() and logInWithReadPermissionsAsync(). It worked fine in Expo Go but app is getting crashed on click of facebook button in iOS simulator.

Thank you @charliecruzan. I Found out the issue, I have added the following in my Info.plist and the crash disappeared.


<key>NSUserTrackingUsageDescription</key>

    <string>This identifier will be used to deliver personalized ads to you.</string>

    <key>LSApplicationQueriesSchemes</key>

<array>

  <string>fbapi</string>

  <string>fbapi20130214</string>

  <string>fbapi20130410</string>

  <string>fbapi20130702</string>

  <string>fbapi20131010</string>

  <string>fbapi20131219</string>

  <string>fbapi20140410</string>

  <string>fbapi20140116</string>

  <string>fbapi20150313</string>

  <string>fbapi20150629</string>

  <string>fbapi20160328</string>

  <string>fbauth</string>

  <string>fb-messenger-share-api</string>

  <string>fbauth2</string>

  <string>fbshareextension</string>

</array>

    <key>CFBundleURLTypes</key>

<array>

  <dict>

  <key>CFBundleURLSchemes</key>

  <array>

    <string>xxxx</string>

  </array>

  </dict>

</array>

<key>FacebookAppID</key>

<string>xxxx</string>

<key>FacebookDisplayName</key>

<string>xxxx</string>
1 Like

This topic was automatically closed 20 days after the last reply. New replies are no longer allowed.