I'm trying to implement Facebook login in my App (Android and IOS), I'm using Expo. I tried following the documentation here on GitHub but it's not working.
For Android I get:
ERROR Invariant Violation: requireNativeComponent: "RCTFBLoginButton" was not found in the UIManager.
And for IOS I get:
ERROR Invariant Violation: "main" has not been registered. This can happen if:
* Metro (the local dev server) is run from the wrong folder. Check if Metro is running, stop it and restart it in the current project.
* A module failed to load due to an error and `AppRegistry.registerComponent` wasn't called.
My App.json:
"expo": {
"plugins": [
[
"react-native-fbsdk-next",
{
"appID": AppID,
"clientToken": ClientToken,
"displayName": Display Name,
"advertiserIDCollectionEnabled": false,
"autoLogAppEventsEnabled": false,
"isAutoInitEnabled": true,
"iosUserTrackingPermission": "This identifier will be used to deliver personalized ads to you."
}
]
]
}
and my Facebook login component (Documentation example)
import React, { Component } from 'react';
import { Button, View } from 'react-native';
import { LoginButton, AccessToken } from 'react-native-fbsdk-next';
export function FaceBook() {
return (
<View>
<LoginButton
onLoginFinished={
(error, result) => {
if (error) {
console.log("login has error: " + result.error);
} else if (result.isCancelled) {
console.log("login is cancelled.");
} else {
AccessToken.getCurrentAccessToken().then(
(data) => {
console.log(data.accessToken.toString())
}
)
}
}
}
onLogoutFinished={() => console.log("logout.")} />
</View>
);
};
I've been stuck on this for hours researching but I can't find much
As said in this doc
This package cannot be used in the "Expo Go" app because it requires custom native code.
Your code is good, but in order to use native code
, you have to create a development build for expo with react-native-fbsdk-next
?
You have this doc that guide you through necessary steps.
This doc to get the .apk file
That's propably why he cannot find RCTFBLoginButton
, because it's not yet in the app.