【问题标题】:why i am not getting OTP SMS when using verifyPhoneNumber method of ionic 3 cordova native plugin?为什么我在使用 ionic 3 cordova 本机插件的 verifyPhoneNumber 方法时没有收到 OTP SMS?
【发布时间】:2018-07-18 14:44:05
【问题描述】:

我正在使用https://github.com/arnesson/cordova-plugin-firebase 来实现firebase 电话身份验证。

当我调用 verifyPhoneNumber()...它安慰我 verifyId。

代码示例:

this.firebase.verifyPhoneNumber(phoneNumber,60)
    .then(
        function (verificationId) {
            console.log(verificationId)
            return verificationId;
        }
    )

控制台输出:

Object {
    instantVerification: false, 
    verificationId:  "here verification id"
}

但是,它不会向给定的电话号码发送代码。

有什么帮助吗?

【问题讨论】:

    标签: android cordova ionic-framework ionic3 ionic-native


    【解决方案1】:

    正如我在文档中看到的,他们说您需要在发送 SMS 之前使用您的凭据登录。也许你在你的示例代码之前就这样做了,如果你不使用它而不是你的代码:

    window.FirebasePlugin.verifyPhoneNumber(number, timeOutDuration, function(credential) {
        console.log(credential);
    
        // ask user to input verificationCode:
        var code = inputField.value.toString();
    
        var verificationId = credential.verificationId;
    
        var credential = firebase.auth.PhoneAuthProvider.credential(verificationId, code);
    
        // sign in with the credential
        firebase.auth().signInWithCredential(credential);
    
        // call if credential.instantVerification was true (android only)
        firebase.auth().signInWithCustomToken(customTokenFromYourServer);
    
        // OR link to an account
        firebase.auth().currentUser.linkWithCredential(credential)
    }, function(error) {
        console.error(error);
    });
    

    【讨论】:

    • 链接在问题上。是插件的文档
    猜你喜欢
    • 2018-03-14
    • 1970-01-01
    • 2021-04-30
    • 1970-01-01
    • 2018-06-12
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2018-06-07
    相关资源
    最近更新 更多