Facebook for Flutter App Crashes on IOS and works fine on Android

5k Views Asked by At

App for unknown Reasons Crashes on pressing on facebook login button for IOS but it's working perfectly on android for unknown reasons ,, if anyone faced this problem please tell how to you solved it

here is the error

*** First throw call stack:
(
    0   CoreFoundation                      0x000000010ad5229b __exceptionPreprocess + 331
    1   libobjc.A.dylib                     0x000000010a2ee735 objc_exception_throw + 48
    2   FBSDKCoreKit                        0x0000000107cee01e +[FBSDKInternalUtility validateURLSchemes] + 398
    3   FBSDKLoginKit                       0x0000000107df490e -[FBSDKLoginManager logInParametersWithPermissions:serverConfiguration:] + 110
    4   FBSDKLoginKit                       0x0000000107df53d7 -[FBSDKLoginManager logInWithBehavior:] + 103
    5   FBSDKLoginKit                       0x0000000107df5157 -[FBSDKLoginManager logInWithPermissions:handler:] + 391
    6   FBSDKLoginKit                       0x0000000107df2deb -[FBSDKLoginManager logInWithReadPermissions:fromViewController:handler:] + 395
    7   flutter_facebook_login <…>
Lost connection to device.`

Info.plist

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
    <dict>
        <key>CFBundleDevelopmentRegion</key>
        <string>en</string>
        <key>CFBundleExecutable</key>
        <string>$(EXECUTABLE_NAME)</string>
        <key>CFBundleIdentifier</key>
        <string>$(PRODUCT_BUNDLE_IDENTIFIER)</string>
        <key>CFBundleInfoDictionaryVersion</key>
        <string>6.0</string>
        <key>CFBundleName</key>
        <string>fbTestingApp</string>
        <key>CFBundlePackageType</key>
        <string>APPL</string>
        <key>CFBundleShortVersionString</key>
        <string>$(FLUTTER_BUILD_NAME)</string>
        <key>CFBundleSignature</key>
        <string>????</string>
        <key>CFBundleVersion</key>
        <string>$(FLUTTER_BUILD_NUMBER)</string>
        <key>LSRequiresIPhoneOS</key>
        <true />
        <key>UILaunchStoryboardName</key>
        <string>LaunchScreen</string>
        <key>UIMainStoryboardFile</key>
        <string>Main</string>
        <key>UISupportedInterfaceOrientations</key>
        <array>
            <string>UIInterfaceOrientationPortrait</string>
            <string>UIInterfaceOrientationLandscapeLeft</string>
            <string>UIInterfaceOrientationLandscapeRight</string>
        </array>
        <key>UISupportedInterfaceOrientations~ipad</key>
        <array>
            <string>UIInterfaceOrientationPortrait</string>
            <string>UIInterfaceOrientationPortraitUpsideDown</string>
            <string>UIInterfaceOrientationLandscapeLeft</string>
            <string>UIInterfaceOrientationLandscapeRight</string>
        </array>
        <key>UIViewControllerBasedStatusBarAppearance</key>
        <false />

        <!-- Facebook Login configuration -->
        <key>CFBundleURLTypes</key>
        <array>
            <dict>
                <key>CFBundleURLSchemes</key>
                <array>
                    <string>fb2443122242373229</string>
                </array>
            </dict>
        </array>
        <key>FacebookAppID</key>
        <string>2443122242373229</string>
        <key>FacebookDisplayName</key>
        <string>fbTestingApp</string>

        <key>LSApplicationQueriesSchemes</key>
        <array>
            <string>fbapi</string>
            <string>fb-messenger-share-api</string>
            <string>fbauth2</string>
            <string>fbshareextension</string>
        </array>
        <!-- End of Facebook Login configuration -->

        <!-- Google Sign-in Section -->
        <key>CFBundleURLTypes</key>
        <array>
            <dict>
                <key>CFBundleTypeRole</key>
                <string>Editor</string>
                <key>CFBundleURLSchemes</key>
                <array>
                    <string>com.googleusercontent.apps.572121212121-axxxxp6vaaaadc06aaaaaacd4d7lbnc</string>
                </array>
            </dict>
        </array>
        <!-- End of the Google Sign-in Section -->
    </dict>
</plist>

anyone faced similar problem ?!

Github Issue Link (https://github.com/roughike/flutter_facebook_login/issues/64)

3

There are 3 best solutions below

3
On BEST ANSWER

okay, it was a miss in pinfo file. it should be :

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
    <dict>
        <key>CFBundleDevelopmentRegion</key>
        <string>en</string>
        <key>CFBundleExecutable</key>
        <string>$(EXECUTABLE_NAME)</string>
        <key>CFBundleIdentifier</key>
        <string>$(PRODUCT_BUNDLE_IDENTIFIER)</string>
        <key>CFBundleInfoDictionaryVersion</key>
        <string>6.0</string>
        <key>CFBundleName</key>
        <string>fbTestingApp</string>
        <key>CFBundlePackageType</key>
        <string>APPL</string>
        <key>CFBundleShortVersionString</key>
        <string>$(FLUTTER_BUILD_NAME)</string>
        <key>CFBundleSignature</key>
        <string>????</string>
        <key>CFBundleVersion</key>
        <string>$(FLUTTER_BUILD_NUMBER)</string>
        <key>LSRequiresIPhoneOS</key>
        <true />
        <key>UILaunchStoryboardName</key>
        <string>LaunchScreen</string>
        <key>UIMainStoryboardFile</key>
        <string>Main</string>
        <key>UISupportedInterfaceOrientations</key>
        <array>
            <string>UIInterfaceOrientationPortrait</string>
            <string>UIInterfaceOrientationLandscapeLeft</string>
            <string>UIInterfaceOrientationLandscapeRight</string>
        </array>
        <key>UISupportedInterfaceOrientations~ipad</key>
        <array>
            <string>UIInterfaceOrientationPortrait</string>
          <string>UIInterfaceOrientationPortraitUpsideDown</string>
            <string>UIInterfaceOrientationLandscapeLeft</string>
            <string>UIInterfaceOrientationLandscapeRight</string>
        </array>
        <key>UIViewControllerBasedStatusBarAppearance</key>
        <false />

        <!-- FACEBOOK&GOOGLE CONFIG START HERE -->
        <key>CFBundleURLTypes</key>
        <array>
            <dict>
                <key>CFBundleURLSchemes</key>
                <array>
                    <string>fb2443122242373229</string>
                </array>
            </dict>

            <dict>
                <key>CFBundleTypeRole</key>
                <string>Editor</string>
                <key>CFBundleURLSchemes</key>
                <array>
                    <string>com.googleusercontent.apps.572121212121-axxxxp6vaaaadc06aaaaaacd4d7lbnc</string>
                </array>
            </dict>
        </array>

        <key>FacebookAppID</key>
        <string>2443122242373229</string>

        <key>FacebookClientToken</key>
        <string>CLIENT-TOKEN</string>

        <key>FacebookDisplayName</key>
        <string>fbTestingApp</string>

        <key>LSApplicationQueriesSchemes</key>
        <array>
            <string>fbapi</string>
            <string>fb-messenger-share-api</string>
            <string>fbauth2</string>
            <string>fbshareextension</string>
        </array>
        <!-- FACEBOOK&GOOGLE CONFIG END HERE -->
    </dict>
</plist>

I found that "CFBundleURLTypes" is called twice and I should merge them

1
On

Also make sure that you added FacebookClientToken right after FacebookAppID.

...
<key>FacebookAppID</key>
<string>{your-app-id}</string>
<key>FacebookClientToken</key>
<string>CLIENT-TOKEN</string>
...

Then, replace CLIENT-TOKEN with the value found under Settings > Advanced > Client Token in your App Dashboard.

2
On

I got this error because I had the plist entry as FacebookAppId, but needed FacebookAppID. Capitalize the last letter.