在iOS 11.3之前我的应用程序运行正常,但在ios 11.3发布后,来自facebook的新用户无法登录我的应用程序。但现有用户仍然可以使用他们的fb帐户通过Facebook登录。 我也是新的React本地人可以请任何人帮助我。这是我的Facebook登录代码:
export const fbLogin = () => async dispatch => {
dispatch({ type: LOADING_TRUE });
LoginManager.logInWithReadPermissions([
'public_profile',
'user_birthday',
'email',
'user_photos'
]).then(
result => {
if (result.isCancelled) {
console.log('cancelled');
dispatch({ type: ERROR_HANDLER });
} else {
AccessToken.getCurrentAccessToken().then(data => {
const token = data.accessToken;
fetch(
'https://graph.facebook.com/v2.8/me?fields=id,name,email,gender,birthday&access_token=' +
token
)
.then(response => response.json())
.then(json => {
let userData = json;
let id = userData.id;
const fbProfilePic = `https://graph.facebook.com/${id}/picture?height=150`;
dispatch({
type: GET_PROFILE_PICTURE,
payload: fbProfilePic
});
const credential = firebase.auth.FacebookAuthProvider.credential(
token
);
firebase
.auth()
.signInWithCredential(credential)
.then(user => {
console.log('firebase facebook login!');
let currentUser = firebase.auth().currentUser;
if (currentUser !== null) {
const name = currentUser.displayName;
const email = currentUser.email;
const uid = currentUser.uid;
const birthday = json.birthday;
const gender =
json.gender === Languages.common.male_en
? Languages.common.male
: Languages.common.female;
userData.gender = gender;
let userDetails;
const db = firebase.firestore();
const docRef = db.collection('users').doc(uid);
docRef
.get()
.then(doc => {
if (doc.exists) {
// more than 2 times login
dispatch({
type: GET_USER_DATA,
payload: doc.data()
});
} else {
// first log in
const dateCreated = Moment()
.format('YYYY-MM-DD hh:mm:ss')
.toString();
userDetails = docRef.set({
name,
email,
birthday,
gender,
dateCreated,
uri: fbProfilePic
});
dispatch({
type: GET_USER_DATA,
payload: userData
});
}
})
.catch(error => {
dispatch({
type: ERROR_HANDLER,
payload: error
});
});
Actions.checkInHistory();
}
})
.catch(error => {
dispatch({
type: ERROR_HANDLER,
payload: `Error: ${error}`
});
});
})
.catch(err => {
dispatch({
type: ERROR_HANDLER,
payload: err
});
});
});
}
},
error => {
dispatch({
type: ERROR_HANDLER,
payload: error
});
}
);
};
此错误来自我的上一个错误处理程序
答案 0 :(得分:0)
我不知道发生了什么,但当我在LoginManager.logOut()
新Facebook之前放LoginManager.logInWithReadPermissions()
时,用户现在可以登录我的应用了。