![](/img/trans.png)
[英]How to Use Firebase Phone Authentication without recaptcha in React Native
[英]React Native Firebase Phone Authentication null values on legit phone number
verify = async () => {
this.isProcessing = true
this.isRegistering = true
const phoneNumber = `${this.currentUser.phoneDialCode}${this.currentUser.phoneNumber}`
// Get reference to the currently signed-in user
this.prevUser = firebase.auth().currentUser
console.log('prev user', this.prevUser)
await firebase.auth().signInWithPhoneNumber(phoneNumber)
.then(async (results) => {
this.isProcessing = false
this.verificationCode = results
console.log('=================================')
console.log('RESULTS', this.verificationCode)
console.log('=================================')
if (!this.verificationCode.verificationId) {
this.triggerAlert(
'Error',
'Phone number might have been blocked because of too much use.',
() => true,
)
await firebase.auth().verifyPhoneNumber(phoneNumber).then((res) => {
console.log('ver phon', res)
})
}
console.log('=================================')
console.log('Current User', firebase.auth().currentUser)
console.log('=================================')
}).catch((error) => {
this.isProcessing = false
this.loginOldUser()
// this.prevUser = new User()
this.triggerAlert(
'Error',
'Phone number format might not be correct. Please check again.',
() => true,
)
this.isPhoneVerified = false
this.currentUser.phoneFlag = ''
this.currentUser.phoneCode = ''
this.currentUser.phoneDialCode = ''
this.currentUser.phoneNumber = ''
})
}
因此,出於某種原因,在多次使用我的電話號碼后,它不再僅返回正確的值 null。 我有一段時間沒有使用它們,所以我不確定有什么問題。 我正在嘗試測試代碼的重新發送,這就是我不使用白名單號碼的原因。
我添加了驗證電話號碼只是為了看看它是否能讓我更深入地了解我的問題。
對這些有什么想法嗎? 謝謝!
既然你說:
多次使用我的電話號碼后,它不再返回正確的值,只有 null
我的第一個想法是你被節流了。
來自關於向用戶手機發送驗證碼的 Firebase 文檔:
為防止濫用,Firebase 對一段時間內可以發送到單個電話號碼的 SMS 消息數量實施了限制。 如果超過此限制,電話號碼驗證請求可能會受到限制。 如果您在開發過程中遇到此問題,請使用其他電話號碼進行測試,或稍后重試該請求。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.