いつもお世話になっています。
React Nativeでアプリ開発を始めた初心者です。
最近はReact Nativeのエラー赤画面が夢にまで出てくるようになりました(汗)
今、Facebook認証を実現したいと思って、昨日react-native-firebaseドキュメントをみながら、こちらやってみたのですが、どうもやり方を混乱してしまい、せっかく親切な方にすぐにご回答いただいたのですが(本当にありがとうございます!)
下記のURLをみながらやり直してみました。
https://codeburst.io/react-native-app-with-facebook-sdk-login-and-firebase-storage-606744701207
こちらは公式のドキュメントと異なり、react-native-facebook-loginを使っているみたいです。
ですが、やはり途中でエラーから抜けられなくなってしまいました。
エラー
シュミレーター上
ExceptionsManager.js:65 RNFirebase core module was not found natively on iOS, ensure you have correctly included the RNFirebase pod in your projects `Podfile` and have run `pod install`.
Xcode上
ld: warning: object file (/Users/shyamada/Library/Developer/Xcode/DerivedData/fbutton-hhjdppbukqrtchehuzbsjrzuqglf/Build/Products/Debug-iphonesimulator/libPods-fbutton.a(Pods-fbutton-dummy.o)) was built for newer iOS version (9.0) than being linked (8.0) ld: framework not found FBSDKLoginKit for architecture x86_64 clang: error: linker command failed with exit code 1 (use -v to see invocation)
ターミナル上
** BUILD FAILED ** The following build commands failed: Ld build/Build/Products/Debug-iphonesimulator/fbutton.app/fbutton normal x86_64 (1 failure) Installing build/Build/Products/Debug-iphonesimulator/fbutton.app An error was encountered processing the command (domain=NSPOSIXErrorDomain, code=22): Failed to install the requested application The bundle identifier of the application could not be determined. Ensure that the application's Info.plist contains a value for CFBundleIdentifier. Print: Entry, ":CFBundleIdentifier", Does Not Exist Command failed: /usr/libexec/PlistBuddy -c Print:CFBundleIdentifier build/Build/Products/Debug-iphonesimulator/fbutton.app/Info.plist Print: Entry, ":CFBundleIdentifier", Does Not Exist
ソースコード
公式にしたがって、Firebaseの設定をしたのちに下記のコードを書きました。
Podfile
# Uncomment the next line to define a global platform for your project platform :ios, '9.0' target 'fbutton' do # Uncomment the next line if you're using Swift or would like to use dynamic frameworks # Pods for fbutton # Required by RNFirebase pod 'Firebase/Core' pod 'Firebase/Auth' end
App.js
import React, { Component } from 'react'; import { StyleSheet, Text, View, Button } from 'react-native'; import { handleFbLogin } from './src/lib/auth'; export default class App extends Component<{}> { render() { return ( <View style={styles.container}> <Button onPress={handleFbLogin} title="Sign in with facebook" color="#3c50e8" /> </View> ); } } const styles = StyleSheet.create({ container: { flex: 1, justifyContent: 'center', alignItems: 'center', backgroundColor: '#F5FCFF', } });
config/auth.js
import { FBLoginManager } from 'react-native-facebook-login'; const Facebook = { login: (permissions) => { return new Promise((resolve, reject) => { FBLoginManager.loginWithPermissions(permissions || ['email'], (error, data) => { if (!error) { resolve(data.credentials.token); } else { reject(error); } }); }); }, logout: () => { return new Promise((resolve, reject) => { FBLoginManager.logout((error, data) => { if (!error) { resolve(true); } else { reject(error); } }); }); } } const Auth = { Facebook }; export default Auth;
config/firebase.js
import RNFirebase from 'react-native-firebase' const configurationOptions = { debug: true } const firebase = RNFirebase.initializeApp() export default firebase;
constants/index.js
export const fbLoginPermissions = ['email'];
lib/auth/index.js
import { fbLoginPermissions } from '../../constants/index'; import firebase from '../../config/firebase'; import Auth from '../../config/auth'; export const handleFbLogin = () => ( Auth.Facebook.login(fbLoginPermissions) .then((token) => { firebase.auth() .signInWithCredential(firebase.auth.FacebookAuthProvider.credential(token)) }) .catch((err) => this.onError && this.onError(err)) );
試してみたこと
StackOverflowなどみながら
pod install、pod update、pod outdateはそれぞれ何度も繰り返しました
Podfileのuser_frameworks!コメントアウトもしてみましたが効果なしです(涙)
回答1件
あなたの回答
tips
プレビュー
バッドをするには、ログインかつ
こちらの条件を満たす必要があります。
2019/03/02 05:45 編集
2019/03/09 05:16