在Visual Studios Code中工作,我正在尝试将Google登录名添加到我的应用中

时间:2019-03-20 18:42:15

标签: visual-studio login

问题是我收到的“ api”似乎无法正常工作。我正在为ios设备构建它。我尝试查找解决方案,它们都指向.plist,而人们似乎正在将其构建在Expo上,而我不是。我没有.plist,我不太了解这意味着什么,因此,如果我可以澄清一下问题或朝着正确的方向前进,将不胜感激。

这是我的login.js代码

当我测试它时说 异常“您的应用缺少对以下URL方案的支持:

import React from "react"
import { StyleSheet, Text, View, Image, Button, TextInput} from 
"react-native"
import Home from '../screens/HomeScreen.js';
export {accountName, accountEmail};

export default class Login extends React.Component {
constructor(props) {
super(props)
this.state = {
  signedIn: false,
  name: "",
  photoUrl: "",
  email:"",
  text: ""
 }
}
signIn = async () => {
try {
  console.log('Starting Async');
  const result = await Expo.Google.logInAsync({
    iosClientId: "279541889821-0jq9s32brq52pv5u9amblv8qpah7d94u.apps.googleusercontent.com",
    scopes: ["profile", "email"],
  })
  console.log(result);
  if (result.type === "success") {
    this.setState({
      signedIn: true,
      name: result.user.name,
      photoUrl: result.user.photoUrl,  
      email: result.user.email

    })
  } else {
    console.log("cancelled")
  }
} catch (e) {
  console.log("error", e)
 }
}
 render() {
 return ( 
 <View style={styles.container}>


  <View >
    {this.state.signedIn ? (
      <LoggedInPage name={this.state.name} photoUrl={this.state.photoUrl} email={this.state.email}/>
    ) : (
      <LoginPage signIn={this.signIn} />
    )}
  </View>

 </View>

 )  
 }
}

const LoginPage = props => {
return (
<View>
    <Text style={styles.header}>Sign In With Google</Text>
    <Button title="Sign in with Google" onPress={() => props.signIn()} 
/>
</View>
 )
}

const LoggedInPage = props => {
return (
 <View>
   {/* <Text style={styles.header}>Welcome:{props.name}</Text> */}
   {/* <Image style={styles.image} source={{ uri: props.photoUrl }} />  
 */}
  <Content nameGoogle={props.name} emailGoogle={props.email}/>

  </View>
 )
}

const accountName = props => {
return (
 <View>
   <Text>{props.name}</Text>
 </View>
 )

}     const accountEmail = props => {     返回(               {props.email}                     )        }     const styles = StyleSheet.create({      容器: {        弹性:1,       backgroundColor:“#fff”,       alignItems:“居中”,       justifyContent:“中心”

},
  header: {
  fontSize: 25
},
  image: {
  marginTop: 15,
  width: 150,
  height: 150,
  borderColor: "rgba(0,0,0,0.2)",
  borderWidth: 3,
  borderRadius: 150
 }
})

任何解决此问题的见识将不胜感激。我和我的团队在此问题上停留了最长的时间。谢谢

0 个答案:

没有答案