首页
学习
活动
专区
圈层
工具
发布
首页
学习
活动
专区
圈层
工具
MCP广场
社区首页 >问答首页 >为什么我在使用ionic 3 cordova原生插件的verifyPhoneNumber方法时收不到OTP短信?

为什么我在使用ionic 3 cordova原生插件的verifyPhoneNumber方法时收不到OTP短信?
EN

Stack Overflow用户
提问于 2018-07-18 22:44:06
回答 1查看 719关注 0票数 0

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

当我调用verifyPhoneNumber()...It时,控制我的verificationId。

代码示例:

代码语言:javascript
运行
复制
this.firebase.verifyPhoneNumber(phoneNumber,60)
    .then(
        function (verificationId) {
            console.log(verificationId)
            return verificationId;
        }
    )

控制台输出:

代码语言:javascript
运行
复制
Object {
    instantVerification: false, 
    verificationId:  "here verification id"
}

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

有什么帮助吗?

EN

回答 1

Stack Overflow用户

发布于 2018-07-18 23:06:44

正如我在文档中看到的那样,他们说在发送短信之前,你需要使用你的凭证登录。也许你在你的示例代码之前做了这件事,如果你不这样做,你就用这个代替你的代码:

代码语言:javascript
运行
复制
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);
});
票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/51404945

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档