Ich richte ein React Native-Projekt mit dem FBSDK für den Login-Zweck.FBSDK: Kann nicht lesen loginwithreadpermissions von undefined
Hier ist, was ich bisher getan habe:
- I
npm install react-native-fbsdk --save
- Ich lief
react-native link
lief
- ich jeden Schritt erwähnt verfolgt wird: https://developers.facebook.com/docs/facebook-login/ios/
- ich mit diesem Video geprüft double: https://www.youtube.com/watch?v=rAXVKapP5cM
Allerdings bekomme ich immer noch diesen roten Bildschirm e rror:
Cannot read property logInWithReadPermissions of undefined
bei FBLoginManager.js, Linie 77 (https://github.com/facebook/react-native-fbsdk/blob/master/js/FBLoginManager.js)
Hier ist mein AppDelegate.m Inhalt:
#import "AppDelegate.h"
#import <FBSDKCoreKit/FBSDKCoreKit.h>
#import <React/RCTBundleURLProvider.h>
#import <React/RCTRootView.h>
@implementation AppDelegate
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
NSURL *jsCodeLocation;
jsCodeLocation = [[RCTBundleURLProvider sharedSettings] jsBundleURLForBundleRoot:@"index.ios" fallbackResource:nil];
RCTRootView *rootView = [[RCTRootView alloc] initWithBundleURL:jsCodeLocation
moduleName:@"PegaseBuzzApp"
initialProperties:nil
launchOptions:launchOptions];
rootView.backgroundColor = [[UIColor alloc] initWithRed:1.0f green:1.0f blue:1.0f alpha:1];
[[FBSDKApplicationDelegate sharedInstance] application:application
didFinishLaunchingWithOptions:launchOptions];
self.window = [[UIWindow alloc] initWithFrame:[UIScreen mainScreen].bounds];
UIViewController *rootViewController = [UIViewController new];
rootViewController.view = rootView;
self.window.rootViewController = rootViewController;
[self.window makeKeyAndVisible];
return YES;
}
- (void)applicationDidBecomeActive:(UIApplication *)application {
[FBSDKAppEvents activateApp];
}
- (BOOL)application:(UIApplication *)application
openURL:(NSURL *)url
sourceApplication:(NSString *)sourceApplication
annotation:(id)annotation {
return [[FBSDKApplicationDelegate sharedInstance] application:application
openURL:url
sourceApplication:sourceApplication
annotation:annotation];
}
@end
Hier ist meine verknüpften Frameworks und Binärdateien:
BEARBEITEN: an meinem Projekt:
const FBSDK = require('react-native-fbsdk');
const {
LoginManager,
} = FBSDK;
Plus-:
_onFBButtonPress() {
LoginManager.logInWithReadPermissions(['public_profile']).then(
function(result) {
if (result.isCancelled) {
alert('Login cancelled');
} else {
alert('Login success with permissions: '
+result.grantedPermissions.toString());
}
},
function(error) {
alert('Login fail with error: ' + error);
}
);
}
Und:
<Button onPress={() => this._onFBButtonPress()} buttonStyle={'buttonFb'} labelStyle={'buttonFbText'} label={I18n.t('Login.btnConnectFB')}></Button>
Was ich vermisse?
Können Sie Code aus "FBLoginManager.js" bitte hinzufügen? – bennygenel
Hallo, ich habe es nur in der Frage hinzugefügt: https://github.com/facebook/react-native-fbsdk/blob/master/js/FBLoginManager.js – enguerranws
Ohh Es tut mir leid, ich dachte, Sie haben eine Datei namens ' 'FBLoginManager.js' auch. Verwenden Sie fbsdk irgendwo in Ihrem Projekt oder fügen Sie einfach die Bibliothek hinzu? – bennygenel