Expo Google 登录使用 Android 模拟器但不使用 iOS
Expo Google login working with Android simulator but not with iOS
我正在制作一个简单的 Expo 应用程序,我试图在其中实现 Google 和 Facebook 登录。我已经实现了 Facebook 登录,并在 iOS 和 Android.
上进行了测试
但是我尝试使用 Google 登录,但它只适用于 Android 模拟器。它不适用于 iOS 设备和模拟器。
我的链接是正确的。但它只给我 iOS 模拟器带来的问题。此代码与 Android 模拟器一起使用,并在 andorid 设备上为我提供 google 令牌。但是在 iOS 我收到这个错误
"Your app is missing support for the following URL schemes com.googleusercontent.apps.ID-googleGivenID" was thrown while invoking loginAsync on target ExponentGoogle with params({ androidClientId = #ID-googleGivenID.apps.googleusercontent.com;
behaviour = system;
iosClientId = "#ID-googleGivenID.apps.googleusercontent.com";
scopes = (
profile,
email
)
})
App.json
{
"expo": {
"name": "InStore",
"description": "This project is really great.",
"slug": "InStore",
"privacy": "public",
"sdkVersion": "31.0.0",
"platforms": ["ios", "android"],
"version": "1.0.0",
"orientation": "portrait",
"icon": "./assets/icon.png",
"splash": {
"image": "./assets/splash.png",
"resizeMode": "contain",
"backgroundColor": "#ffffff"
},
"updates": {
"fallbackToCacheTimeout": 0
},
"assetBundlePatterns": ["**/*"],
"ios": {
"supportsTablet": true
},
"extra": {
"googleAppId": {
"ios": "#ID-googleGivenID.apps.googleusercontent.com",
"android": "#ID-googleGivenID.apps.googleusercontent.com"
}
}
}
}
Google Login File
const loginAsync = async () => {
try {
const result = await Google.logInAsync({
androidClientId: '#ID-googleGivenID.apps.googleusercontent.com',
iosClientId: '#ID-googleGivenID.apps.googleusercontent.com',
scopes: ['profile', 'email']
});
if (result.type == 'success') {
return Promise.resolve(result.accessToken);
} else {
return Promise.reject('Filed');
}
} catch (error) {
return Promise.reject(error);
}
};
已修复
behavior : 'web'
const result = await Expo.Google.logInAsync({ iosClientId: '-------------.apps.googleusercontent.com', androidClientId: '--------.apps.googleusercontent.com', behavior: 'web', scopes: ['profile', 'email'], });
我正在制作一个简单的 Expo 应用程序,我试图在其中实现 Google 和 Facebook 登录。我已经实现了 Facebook 登录,并在 iOS 和 Android.
上进行了测试但是我尝试使用 Google 登录,但它只适用于 Android 模拟器。它不适用于 iOS 设备和模拟器。
我的链接是正确的。但它只给我 iOS 模拟器带来的问题。此代码与 Android 模拟器一起使用,并在 andorid 设备上为我提供 google 令牌。但是在 iOS 我收到这个错误
"Your app is missing support for the following URL schemes com.googleusercontent.apps.ID-googleGivenID" was thrown while invoking loginAsync on target ExponentGoogle with params({ androidClientId = #ID-googleGivenID.apps.googleusercontent.com;
behaviour = system;
iosClientId = "#ID-googleGivenID.apps.googleusercontent.com";
scopes = (
profile,
email
)
})
App.json
{
"expo": {
"name": "InStore",
"description": "This project is really great.",
"slug": "InStore",
"privacy": "public",
"sdkVersion": "31.0.0",
"platforms": ["ios", "android"],
"version": "1.0.0",
"orientation": "portrait",
"icon": "./assets/icon.png",
"splash": {
"image": "./assets/splash.png",
"resizeMode": "contain",
"backgroundColor": "#ffffff"
},
"updates": {
"fallbackToCacheTimeout": 0
},
"assetBundlePatterns": ["**/*"],
"ios": {
"supportsTablet": true
},
"extra": {
"googleAppId": {
"ios": "#ID-googleGivenID.apps.googleusercontent.com",
"android": "#ID-googleGivenID.apps.googleusercontent.com"
}
}
}
}
Google Login File
const loginAsync = async () => {
try {
const result = await Google.logInAsync({
androidClientId: '#ID-googleGivenID.apps.googleusercontent.com',
iosClientId: '#ID-googleGivenID.apps.googleusercontent.com',
scopes: ['profile', 'email']
});
if (result.type == 'success') {
return Promise.resolve(result.accessToken);
} else {
return Promise.reject('Filed');
}
} catch (error) {
return Promise.reject(error);
}
};
已修复
behavior : 'web'
const result = await Expo.Google.logInAsync({ iosClientId: '-------------.apps.googleusercontent.com', androidClientId: '--------.apps.googleusercontent.com', behavior: 'web', scopes: ['profile', 'email'], });