可能的未置信的承诺拒绝(ID:1)

发布于 2025-02-09 03:48:55 字数 1052 浏览 3 评论 0原文

我试图使用React Native的Expo使用Google API Auth,当我尝试登录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)
}

错误:

​:错误:iOS上没有方法或属性expo-app-auth.authasync,您确定已正确链接了所有本机依赖关系吗?]

I was trying to use the Google API auth from expo in react native and when I trying to log to the api , I getting the next error :

code :

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)
}

error :

enter image description here

and this command :

[Unhandled promise rejection: Error: The method or property expo-app-auth.authAsync is not available on ios, are you sure you've linked all the native dependencies properly?]

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。
列表为空,暂无数据
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文