sandeepdillerao / cordova-plugin-otp-auto-verification

13 stars 10 forks source link

Not working in Ionic 1 #4

Closed kvedantmahajan closed 7 years ago

kvedantmahajan commented 7 years ago

Here is what I did.

ionic plugin add cordova-plugin-otp-auto-verification

Added the code as it it from NPM

Inside my send OTP API success. No callbacks fired for success or error.

sandeepdillerao commented 7 years ago

@kushalmahajan I am using this in map its working fine. can you please share code snippet.

sandeepdillerao commented 7 years ago

@kushalmahajan install plugin from github url. dont install it by package name

eg. cordova plugin add https://github.com/sandeepdillerao/cordova-plugin-otp-auto-verification.git OR ionic plugin add https://github.com/sandeepdillerao/cordova-plugin-otp-auto-verification.git

kvedantmahajan commented 7 years ago

Still not working.

    AppFactory.post('/sendOtp', {'mobileNo': mobileNo})
        .then(function(response){
            if(response.code === 1){

                let options = {
                    delimiter : "(OTP) is",
                    length : 6,
                    origin : "This is picked up from SMS header leaving first two letters"
                };

                let success = function (otp) {
                    console.log("GOT OTP", otp);
                    ctrl.otp = otp;
                    OTPAutoVerification.stopOTPListener();
                };

                let failure = function () {
                    OTPAutoVerification.stopOTPListener();
                    $rootScope.showToast("Problem in listening OTP");
                };

                OTPAutoVerification.startOTPListener(options, success, failure);

            }else{
                if(response.message === 'NOT_EXIST'){
                    $rootScope.showToast("Mobile no doesn't exists");
                }else{
                    $rootScope.showToast(response.message);
                }
            }
        });
sandeepdillerao commented 7 years ago

@kushalmahajan make sure that you have installed latest plugin release-1.0.0 version. bcz in this release i fixed the android run time permission issue for android 6 and above devices

NOTE: dont install plugin by package name install it from github url. bcz on nmp it is 0.0.4 version and latest is 1.0.0

kvedantmahajan commented 7 years ago

ionic plugin add https://github.com/sandeepdillerao/cordova-plugin-otp-auto-verification.git did it.

Thanks

RakeshKB commented 7 years ago

Hey @kushalmahajan , I tried ionic plugin add https://github.com/sandeepdillerao/cordova-plugin-otp-auto-verification.git but still the success callback is not getting called. it always goes to the failure callback. Any help would be much appreciated.

sandeepdillerao commented 7 years ago

Hey if it going to failure means something ur doing wrong.. Can you please share you code snippet how ur calling n all.. so that I can help in..

Sent from Mail for Windows 10

From: Rakesh KB Sent: 02 August 2017 13:29 To: sandeepdillerao/cordova-plugin-otp-auto-verification Cc: Sandeep Dillerao; Comment Subject: Re: [sandeepdillerao/cordova-plugin-otp-auto-verification] Notworking in Ionic 1 (#4)

Hey, I tried ionic plugin add https://github.com/sandeepdillerao/cordova-plugin-otp-auto-verification.git but still the success callback is not getting called. it always goes to the failure callback. Any help would be much appreciated. — You are receiving this because you commented. Reply to this email directly, view it on GitHub, or mute the thread.

RakeshKB commented 7 years ago

@kushalmahajan Hi, Thanks for your prompt response :)

After adding the plugin, I do this: var options = { delimiter : "code is", length : 4, origin : "VKMEDIBX" }; $scope.registerInfo = {};

    var success = function (otp) {
        $scope.registerInfo.otp=otp;
        console.log("GOT OTP:"+ otp);
        OTPAutoVerification.stopOTPListener();
    };

    var failure = function () {
        $scope.registerInfo.otp = '';
        OTPAutoVerification.stopOTPListener();
        console.log("Problem in listening OTP");
    };

    $scope.autoDetectOTP = function(){
        if (ionic.Platform.device().platform) {
            console.log("OTPAutoVerification");
            OTPAutoVerification.startOTPListener(options, success, failure);
        }
    };
sandeepdillerao commented 7 years ago

@kushalmahajan the origin u have mentioned is wrong only add senderID in SMS. dont add provider code in origin for example in you case use only "MEDIBX" in origin.

updated code for you will look like below. var options = { delimiter : "code is", length : 4, origin : "MEDIBX" };

Hope this will resolve your issue..

sandeepdillerao commented 7 years ago

plugin updated on npm repository. issue resolved. so I am closing this issue. Thanks..

Kranthi32 commented 2 years ago

Hi, My OTP template is " Dear Name,

123456 is your OTP". in this scenario which one we are mentioned in delimeter to find out OTP string.