thebergamo / react-native-fbsdk-next

MIT License
692 stars 166 forks source link

App Crash when trying to login #581

Closed arnsa closed 22 hours ago

arnsa commented 2 days ago

🐛 Bug Report

I've followed all of the instructions (checked like 5 times) for installing this library, but every time I call LoginManager.logInWithPermissions my app simply crashes, on both iOS and Android. If I try to use LoginButton instead, same happens on iOS when I click on the button and on Android it crashes without me even clicking anything.

To Reproduce

Simply follow installation instructions and try to login to Facebook using either LoginManager.logInWithPermissions or LoginButton.

Expected Behavior

App doesn't crash and I'm able to login.

Environment

System: OS: macOS 15.1 CPU: (11) arm64 Apple M3 Pro Memory: 134.78 MB / 18.00 GB Shell: version: "5.9" path: /bin/zsh Binaries: Node: version: 18.14.0 path: /usr/local/bin/node Yarn: Not Found npm: version: 10.8.2 path: /usr/local/bin/npm Watchman: version: 2024.10.28.00 path: /opt/homebrew/bin/watchman Managers: CocoaPods: version: 1.16.2 path: /opt/homebrew/bin/pod SDKs: iOS SDK: Platforms:

mikehardy commented 2 days ago

And your crash traces are....

arnsa commented 2 days ago

Damn it I'm sorry. Here it is:

libc++abi: terminating due to uncaught exception of type facebook::jsi::JSError: Exception in HostFunction: *** is not registered as a URL scheme. Please add it in your Info.plist

Error: Exception in HostFunction: *** is not registered as a URL scheme. Please add it in your Info.plist

And the weird thing is that IT IS registered in Info.plist file. Here're the contents below:

<?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>CFBundleURLTypes</key>
    <array>
        <dict>
        <key>CFBundleURLSchemes</key>
        <array>
                <string>***</string>
        </array>
        </dict>
    </array>
    <key>FacebookAppID</key>
    <string>***</string>
    <key>FacebookClientToken</key>
    <string>***</string>
    <key>FacebookDisplayName</key>
    <string>***</string>
    <key>LSApplicationQueriesSchemes</key>
    <array>
        <string>fbapi</string>
        <string>fb-messenger-share-api</string>
    </array>
</dict>
</plist>

And Android... is working now, I don't know how, but it is 🤷‍♂️

mikehardy commented 2 days ago

Crashes on login, appears to be missing fbauth2 in Info.plist, 🤔

https://github.com/thebergamo/react-native-fbsdk-next/blob/6f1d77214d6e5032afb058eb3574c5e160448eb0/refresh-example.sh#L106

Everything that script does is what needs to be done for a working integration - triple check I guess?

arnsa commented 2 days ago

Unfortunately, app still crashes on login with the same logs. Here's updated Info.plist (I've included a little bit more info this time):

<key>CFBundleURLTypes</key>
    <array>
        <dict>
            <key>CFBundleURLSchemes</key>
            <array>
                <string>***</string>
            </array>
        </dict>
        <dict>
            <key>CFBundleTypeRole</key>
            <string>Editor</string>
            <key>CFBundleURLSchemes</key>
            <array>
                <string>***</string>
            </array>
        </dict>
    </array>
    <key>CFBundleVersion</key>
    <string>$(CURRENT_PROJECT_VERSION)</string>
    <key>FacebookAppID</key>
    <string>***</string>
    <key>FacebookClientToken</key>
    <string>***</string>
    <key>FacebookDisplayName</key>
    <string>Nomadenics</string>
    <key>LSApplicationCategoryType</key>
    <string></string>
    <key>LSApplicationQueriesSchemes</key>
    <array>
        <string>fbapi</string>
        <string>fbauth2</string>
        <string>fb-messenger-share-api</string>
    </array>
mikehardy commented 2 days ago

apologies - that was just something I saw quickly All I can say is that this (login) is probably the overwhelming number one reason everyone uses this library. It's the entire reason I use it, and then I just maintain it because...no one else is and I need login to work? If login didn't work I'd be right on it, and I'd fix it.

But login works for me and (based on no other reports...) everyone else so I have to see this is an integration error. Something important in either config or build+run steps is missing and it's probably project-specific

I won't have time to help any more, but - if you discover something wrong in the library and raise a PR I'll happily merge and release it

arnsa commented 1 day ago

@mikehardy all good, I understand. I'll try to debug over this week and I'll update this thread with my findings

arnsa commented 22 hours ago

@mikehardy I've finally figured it out. The value that I had inside of CFBundleURLSchemes array was my FB app id, but it has to be prefixed with fb and mine wasn't 🙃🙃 that's what was causing the crash.

Thank you for your time, I'm closing the issue