3
需要幫助的人,目前使用指數和訪問Exponent.Facebook.logInWithReadPermissionsAsync進行身份驗證。任何人都有指導建立該項目。我無法找到iOS文件夾,因爲在facebook sdk的指令中,我需要在項目中添加少量庫。這裏是我main.js:Facebook登錄使用指數反應本地
import Expo from 'expo';
import React from 'react';
import { StyleSheet, Text, View } from 'react-native';
import { Button } from 'react-native-elements';
class App extends React.Component {
authenticate = (token) => {
const provider = firebase.auth.FacebookAuthProvider;
const credential = provider.credential(token);
return firebase.auth().signInWithCredential(credential);
}
login = async() => {
const ADD_ID = 273131576444313
const options = {
permissions: ['public_profile', 'email'],
}
const {type, token} = await Expo.Facebook.logInWithReadPermissionsAsync(ADD_ID, options)
if (type === 'success') {
const response = await fetch(`https://graph.facebook.com/me?access_token=${token}`)
console.log(await response.json());
this.authenticate(token);
}
}
render() {
return (
<View style={styles.container}>
<Text>Open up main.js to start working on your app!</Text>
<Button
raised
onPress={this.login}
icon={{name: 'cached'}}
title='RAISED WITH ICON' />
</View>
);
}
}
const styles = StyleSheet.create({
container: {
flex: 1,
backgroundColor: '#fff',
alignItems: 'center',
justifyContent: 'center',
},
});
Expo.registerRootComponent(App);
`
感謝現在的工作..:d –
你可能需要編輯你的APP ID隨機數BTW。 –
@RuiePena除了'expo sdk'這段代碼外,還有其他什麼步驟?我得到這個錯誤'無效密鑰散列。密鑰散列83490ksksjklsjjskj =不匹配任何存儲的密鑰散列......' –