React NativeでFacebookログインができずに困っています。
どんなやり方を試してみても、Facebookの画像すらでず赤い呪いのエラーが出てきています。。
エラー
TypeError: Cannot read property 'logInWithReadPermissions' of undefined
ソースコード
https://rnfirebase.io/docs
こちらにあるドキュメントを参考にしながら進めています。
そもそものRNfirebaseを始めるための手順(GoogleService-Info.plist、google-services.jsonなどの入れ込み)をきちんと進めました。
どうしてもダメなので、公式のコードをgit cloneしても同じところでつまずきました。。
FacebookLogin.js
JavaScript
1import { AccessToken, LoginManager } from 'react-native-fbsdk'; 2import firebase from 'react-native-firebase' 3 4// Calling the following function will open the FB login dialogue: 5const FacebookLogin = () => { 6 return LoginManager 7 .logInWithReadPermissions(['public_profile', 'email']) 8 .then((result) => { 9 if (!result.isCancelled) { 10 console.log(`Login success with permissions: ${result.grantedPermissions.toString()}`) 11 // get the access token 12 return AccessToken.getCurrentAccessToken() 13 } 14 }) 15 .then(data => { 16 if (data) { 17 // create a new firebase credential with the token 18 const credential = firebase.auth.FacebookAuthProvider.credential(data.accessToken) 19 // login with credential 20 return firebase.auth().signInWithCredential(credential) 21 } 22 }) 23 .then((currentUser) => { 24 if (currentUser) { 25 console.info(JSON.stringify(currentUser.toJSON())) 26 } 27 }) 28 .catch((error) => { 29 console.log(`Login fail with error: ${error}`) 30 }) 31} 32 33export default FacebookLogin;
App.js
JavaScript
1/** 2 * Sample React Native App 3 * https://github.com/facebook/react-native 4 * @flow 5 */ 6import React from 'react'; 7import { 8 StyleSheet, 9 View, 10 Button 11} from 'react-native'; 12import FacebookLogin from './components/FacebookLogin'; 13 14export default class App extends React.Component { 15 render() { 16 return ( 17 <View style={styles.container}> 18 <FacebookLogin /> 19 </View> 20 ); 21 } 22} 23 24const styles = StyleSheet.create({ 25 container: { 26 flex: 1, 27 justifyContent: 'center', 28 alignItems: 'center', 29 backgroundColor: '#F5FCFF', 30 } 31});
すみませんが、どうぞ宜しくお願い致します。。
お助けください。
回答1件
あなたの回答
tips
プレビュー
バッドをするには、ログインかつ
こちらの条件を満たす必要があります。
2018/02/02 00:55