Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import firebase from 'firebase';
- const config = {
- apiKey: 'API_KEY',
- authDomain: '****',
- databaseURL: '****',
- storageBucket: '****'
- };
- firebase.initializeApp(config);
- // 中略
- const loginWithFb = () => {
- return Facebook.logInWithReadPermissionsAsync('APP_ID', {
- permissions: ['public_profile']
- });
- };
- // ログインボタンのonPressにbind
- async onPress() {
- const { type, token } = await loginWithFb();
- if (type === 'success') {
- const credential = firebase.auth.FacebookAuthProvider.credential(token);
- firebase.auth().signInWithCredential(credential).catch((error) => {
- console.log(error);
- });
- }
- }
- componentDidMount() {
- const auth = firebase.auth.FacebookAuthProvider;
- console.log(auth);
- // undefined
- }
- // ちゃんと保存される
- firebase.database().ref('users/' + 1).set({
- name: 'hoge'
- });
- // firebase_をチェーンに追加
- const credential = firebase.firebase_.auth.FacebookAuthProvider.credential(token);
- firebase.auth().signInWithCredential(credential)
- firebase.auth().signOut();
Add Comment
Please, Sign In to add comment