简体   繁体   中英

why i am not getting OTP SMS when using verifyPhoneNumber method of ionic 3 cordova native plugin?

I am using https://github.com/arnesson/cordova-plugin-firebase to implement firebase phone authentication.

When i call verifyPhoneNumber()...It console me verificationId.

Code sample :

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

Console Output:

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

But, it is not sending code to given phone number.

Any help ?

As i can read in the documentation, they said you need to sign in with you'r credential before send SMS. Maybe you do it before u'r sample code, if you don't you use this instead of you'r code :

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);
});

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM