Firebase 전화 인증 오류:토큰이 잘못되었습니다. nativeToJ.오류
사용 중firebase
이 문서로 폰 인증 네이티브 앱을 반응시켜, 나는 그것을 몇몇 다른 장치에서 테스트했습니다.때때로 전화기auth
작동하고 때때로 이 오류를 발생시킵니다.
Firebase 전화 인증 오류:토큰이 잘못되었습니다. nativeToJ.오류
저는 소방서의 문서를 검토했고 이 오류를 이해하려고 노력했습니다.다음은 제 코드 조각입니다.
confirmPhone = async(phoneNumber) => {
const phoneWithAreaCode = phoneNumber.replace(/^0+/, '+972');
return new Promise((res, rej) => {
firebase.auth().verifyPhoneNumber(phoneWithAreaCode)
.on('state_changed', async(phoneAuthSnapshot) => {
switch (phoneAuthSnapshot.state) {
case firebase.auth.PhoneAuthState.AUTO_VERIFIED:
UserStore.setVerificationId(phoneAuthSnapshot.verificationId)
await this.confirmCode(phoneAuthSnapshot.verificationId, phoneAuthSnapshot.code, phoneAuthSnapshot)
res(phoneAuthSnapshot)
break
case firebase.auth.PhoneAuthState.CODE_SENT:
UserStore.setVerificationId(phoneAuthSnapshot.verificationId)
res(phoneAuthSnapshot)
break
case firebase.auth.PhoneAuthState.AUTO_VERIFY_TIMEOUT:
UserStore.setVerificationId(phoneAuthSnapshot.verificationId)
UserStore.setErrorCodeAuthentication('SMS code has expired')
res(phoneAuthSnapshot)
case firebase.auth.PhoneAuthState.ERROR:
console.log(phoneAuthSnapshot.error.code)
if (phoneAuthSnapshot.error) {
this.showMessageErrorByCode(phoneAuthSnapshot.error.code)
}
rej(phoneAuthSnapshot)
break
}
})
})
}
confirmCode = async(verificationId, code, phoneAuthSnapshot) => {
console.log(verificationId, code);
try {
const credential = await firebase.auth.PhoneAuthProvider.credential(verificationId, code)
UserStore.setCodeInput(code)
UserStore.setUserCredentials(credential)
AppStore.setAlreadyVerifiedAuto(true)
await this.authenticate(credential)
return credential
} catch (e) {
console.log(e)
this.showMessageErrorByCode(e.error.code)
// throw new Error(e)
}
}
showMessageErrorByCode(errorcode) {
switch (errorcode) {
case 'auth/invalid-phone-number':
UserStore.setErrorCodeAuthentication('Please enter valid phone number');
break;
case 'auth/unknown':
{
UserStore.setErrorCodeAuthentication('User blocked by firebase');
break;
}
case 'auth/session-expired':
{
UserStore.setErrorCodeAuthentication('SMS code has expired');
break;
}
case 'auth/invalid-verification-code':
{
UserStore.setErrorCodeAuthentication('Code verification not correct');
break;
}
default:
UserStore.setErrorCodeAuthentication('other error');
}
}
authenticate = async(credential) => {
await firebase.auth().signInAndRetrieveDataWithCredential(credential)
}
//...
다음을 확인합니다.
- 올바른 번들 ID
- 올바른 Google-Info.plist
- 올바른 aps-환경 값
- 인증서 대신 APNS 인증 키(p8) 업로드
도움이 되길 바랍니다.
파이어베이스에 접속하려는 앱의 번들 ID가 파이어베이스 콘솔에 등록된 번들 ID와 일치하지 않을 경우 발생할 수 있다고 생각합니다.
언급URL : https://stackoverflow.com/questions/50390534/firebase-phone-auth-error-invalid-token-at-nativetojserror
'programing' 카테고리의 다른 글
$ 또는 $elemMatch의 문 (0) | 2023.07.13 |
---|---|
SQL LIKE 문에서 변수 사용 (0) | 2023.07.13 |
개체의 필드를 콘솔에 덤프하려면 어떻게 해야 합니까? (0) | 2023.07.13 |
PLSQL 기호 "=>"의 의미 (0) | 2023.07.13 |
깃쇼 라인을 추가하고 라인을 변경하고 라인을 제거하는 방법이 있습니까? (0) | 2023.07.13 |