我试图在 React Native 中使用来自 expo 的 Google API 身份验证,当我尝试登录 api 时,出现下一个错误:
代码:
import React, { createContext,useContext } from 'react'
import * as Google from 'expo-google-app-auth';
const AuthContext = createContext({})
const config = {
androidClientId : 'APIKey',
iosClientId: 'APIKey',
scope: ["profile", "email"],
premissions : ["public_profile", "email","gender","location"],
}
export const AuthProvider = ({ children }) => {
const signInWithGoogle = async() => {
Google.logInAsync(config).then(async (logInResults) => {
if (logInResults.type === 'success') {
// login...
}
});
};
return (
<AuthContext.Provider
value={{
user:null,
signInWithGoogle
}}
>
{children}
</AuthContext.Provider>
)
}
export default function useAuth (){
return useContext(AuthContext)
}
错误:
这个命令:
[未处理的承诺拒绝:错误:方法或属性 expo-app-auth.authAsync 在 ios 上不可用,您确定已正确链接所有本机依赖项吗?]
如果您使用 expo go 应用程序,这将不起作用 https://community.auth0.com/t/react-native-auth0-possible-unhandled-promise-rejection/94992/3