我正在制作一个简单的Expo应用程序,试图在其中实现Google和Facebook登录。我已经实现了Facebook登录,并已在iOS和Android上进行了测试。
但是我尝试使用Google登录,但只能在Android Simulator上使用。它不适用于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登录文件
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);
}
};
答案 0 :(得分:0)
固定为
behavior : 'web'
const result = await Expo.Google.logInAsync({ iosClientId: '-------------.apps.googleusercontent.com', androidClientId: '--------.apps.googleusercontent.com', behavior: 'web', scopes: ['profile', 'email'], });