我已经集成了facebook登录名,并且在 kitkat 以上的所有版本上都可以正常使用。 在 kitkat 中,点击Facebook登录按钮时出现奇怪的行为 加载时会将应用程序带到后台。
我用于登录的代码:
const doFacebookLogin = async dispatch => {
const { type, token } = await LoginManager.logInWithReadPermissions(["public_profile", "email", "pages_show_list"])
.then(
(result) => {
if (result.isCancelled) {
return dispatch({ type: FACEBOOK_LOGIN_CANCEL });
} else {
AccessToken.getCurrentAccessToken()
.then(async (data) => {
await setValue('fb_token', data.accessToken);
let facebookApiData = await initUser(data.accessToken);
await setValue('facebook_data', JSON.stringify(facebookApiData));
dispatch({ type: FACEBOOK_LOGIN_PROCRESSING});
// let response = await api.post('api/account/AddUser',JSON.parse('{"BrowserName":"MobileApp","BrowserVersion":"46", "Email":"'+ facebookApiData.email +'","FacebookID":"'+facebookApiData.id+'","FirstName":"'+facebookApiData.first_name+'","MiddleName":"'+facebookApiData.middle_name+'", "FullName": "'+facebookApiData.name+'", "Gender":"'+facebookApiData.gender+'","LastName":"'+facebookApiData.last_name+'", "ProfileLink":"'+facebookApiData.link+'","image":"'+facebookApiData.picture.data.url+'","Location":null}}'));
// await setValue('LoginId', response.LoginId);
return dispatch({ type: FACEBOOK_LOGIN_SUCCESS, payload: data.accessToken });
});
}
},
(error) => {
Alert.alert('Sign in error', error);
},
);
if (type === "cancel") {
return dispatch({ type: FACEBOOK_LOGIN_FAIL });
}
await setValue("fb_token", token);
return dispatch({ type: FACEBOOK_LOGIN_SUCCESS, payload: token });
};
附件截图
我正在使用的依赖项
"dependencies": {
"react": "16.4.0",
"react-native": "0.55.4",
"react-native-fbsdk": "^0.7"
},