undefined is not an object (evaluating 'firebase.auth.FacebookAuthProvider.credential')
When using:
const credential = firebase.auth.FacebookAuthProvider.credential(token)
Android (I don't know if works on ios)
React 16.0.0, RN 0.50.0
RNFirebase 3.3.1
or what version of RNFirebase is for RN 0.50.0 ?
Can I see how you're importing / defining firebase please?
I fix it downgrading to 3.0.6, using the same code:
On JS:
import RNFirebase from 'react-native-firebase'
const configurationOptions = {
debug: false,
persistence: true
}
const firebase = RNFirebase.initializeApp(configurationOptions)
On build.gradle
classpath 'com.google.gms:google-services:3.1.0'
On app/build.gradle
compile(project(':react-native-firebase')) {
transitive = false
}
compile 'com.google.firebase:firebase-core:11.8.0'
compile 'com.google.android.gms:play-services-base:11.8.0'
compile 'com.google.firebase:firebase-analytics:11.8.0'
compile 'com.google.firebase:firebase-auth:11.8.0'
compile 'com.google.firebase:firebase-config:11.8.0'
compile "com.google.firebase:firebase-crash:11.8.0"
compile 'com.google.firebase:firebase-database:11.8.0'
compile 'com.google.firebase:firebase-perf:11.8.0'
compile 'com.google.firebase:firebase-storage:11.8.0'
On setting.gradle
include ':react-native-firebase'
project(':react-native-firebase').projectDir = new File(rootProject.projectDir, '../node_modules/react-native-firebase/android')
On MainApplication.java
import io.invertase.firebase.RNFirebasePackage;
import io.invertase.firebase.auth.RNFirebaseAuthPackage;
import io.invertase.firebase.config.RNFirebaseRemoteConfigPackage;
import io.invertase.firebase.database.RNFirebaseDatabasePackage;
import io.invertase.firebase.perf.RNFirebasePerformancePackage;
import io.invertase.firebase.storage.RNFirebaseStoragePackage;
...
public class MainApplication extends Application implements ReactApplication {
...
@Override
protected List<ReactPackage> getPackages() {
return Arrays.<ReactPackage>asList(
new MainReactPackage(),
...
new RNFirebasePackage(),
new RNFirebaseAuthPackage(),
new RNFirebaseRemoteConfigPackage(),
new RNFirebaseDatabasePackage(),
new RNFirebasePerformancePackage(),
new RNFirebaseStoragePackage()
...
@BonnieMilian you're trying to access the FacebookAuthProvider on an initialised app instance which is no longer possible. It was an oversight from our point and a discrepancy against the Firebase JS SDK.
You'll need to access the FacebookAuthProvider on the standard firebase import:
import firebase from 'react-native-firebase';
firebase.auth.FacebookAuthProvider.credential();
@BonnieMilian Use import firebase from 'react-native-firebase'; directly instead of creating RNfirebase. This worked for me.
Most helpful comment
@BonnieMilian you're trying to access the FacebookAuthProvider on an initialised app instance which is no longer possible. It was an oversight from our point and a discrepancy against the Firebase JS SDK.
You'll need to access the FacebookAuthProvider on the standard firebase import: