facebookarchive / react-native-fbsdk

A React Native wrapper around the Facebook SDKs for Android and iOS. Provides access to Facebook login, sharing, graph requests, app events etc.
https://developers.facebook.com/docs/react-native
Other
2.99k stars 910 forks source link

fbXXXXXXXXXXX is not registered as a URL scheme #707

Open manhquyen opened 4 years ago

manhquyen commented 4 years ago

Simulator Screen Shot - iPhone 8 - 2020-02-11 at 21 03 07

I check facebook Application ID is correct but still error

To Reproduce

Expected Behavior

Here are some tips for providing a minimal example: https://stackoverflow.com/help/mcve.

Environment

react-native: 0.59.9 react-native-fbsdk: 0.8.0

gmertk commented 4 years ago

Probably your info.plist is wrong. Make sure it is like

<key>CFBundleURLTypes</key>
<array>
  <dict>
    <key>CFBundleURLSchemes</key>
    <array>
      <string>fb{your-app-id}</string>
    </array>
  </dict>
</array>
<key>FacebookAppID</key>
<string>{your-app-id}</string>
<key>FacebookDisplayName</key>
<string>{your-app-name}</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>fbauth2</string>
  <string>fbshareextension</string>
</array>
aurostudio commented 4 years ago

@gmertk -- Why did you close this ticket? I am getting the same issue which used to work 2 months ago.

I have same configuration in Info.plist as yours.

aurostudio commented 4 years ago

@manhquyen -- Did you resolve this issue?

@gmertk -- it still happens to the latest version. Please reopen this.

0soltys commented 4 years ago

@aurostudio @manhquyen I guess that you use Facebook SDK along with Google SDK(ex. Google SignIn) This is only required if you have multiple listeners for openURL - for instance if you have both Google and Facebook OAuth.

it's working for me: in AppDelegate.m

- (BOOL)application:(UIApplication *)app
            openURL:(NSURL *)url
            options:(NSDictionary<UIApplicationOpenURLOptionsKey,id> *)options
{

  if ([RCTLinkingManager application:app openURL:url options:options]) {
    return YES;
  }

  return NO;
}

replace with

#import <FBSDKCoreKit/FBSDKCoreKit.h>
#import <RNGoogleSignin/RNGoogleSignin.h>

- (BOOL)application:(UIApplication *)app
            openURL:(NSURL *)url
            options:(NSDictionary<UIApplicationOpenURLOptionsKey,id> *)options
{
  if ([[FBSDKApplicationDelegate sharedInstance] application:app openURL:url options:options]) {
    return YES;
  }

  if ([RNGoogleSignin application:app openURL:url options:options]) {
    return YES;
  }

  if ([RCTLinkingManager application:app openURL:url options:options]) {
    return YES;
  }

  return NO;
}
JoshuaPerk commented 4 years ago

@soltysaleksandr I don't have the Google SDK in my project and am still having the same issue as @manhquyen and @aurostudio. Did either of you resolve?

@gmertk This seems to be a valid issue with the latest SDK in React.

JoshuaPerk commented 4 years ago

I think I may have actually figured out the causation (though I'm too new to React Native, Xcode, and in my case, Ionic Capacitor apps to understand the "why").

Almost all of the official documentation point to making sure the CFBundleURLSchemes entry in the plist is set properly, but a few posts around the net point to creating/updating the URL types[URL Schemes][fb-APP-ID]. I added this entry and am able to proceed past the previous error.

jkol36 commented 4 years ago
fb{your-app-id}

this isn't correct. You need to add fbXXXXXXXXX as a url scheme. Open info.plist in xcode, expand url types. Hit the plus button. That will create a new item. Set the value to fbxxxxxx and set the url identifier to facebook. This will fix it.

wentao3970 commented 3 years ago

Nice solution @jkol36 It works for me!