sandeepdillerao / cordova-plugin-otp-auto-verification

13 stars 10 forks source link

Ionic Auto Detect OTP Length issue #18

Open dxmari opened 5 years ago

dxmari commented 5 years ago

The below content is my sms text.

638037 is your My Application verification code

So , I dont have the delimiter right. So I should give the delimiter value to empty string. like tis {delimiter : ""} & My OTP code length is 6.

But I receive only the 5 digits of my OTP code like 38037.

I found the problem in your below code.

private String getVerificationCode(String message) { String code = null; int index = message.indexOf(OTP_DELIMITER);

    if (index != -1) {
        **int start = index + OTP_DELIMITER.length()+1;**
         It should be "int start = OTP_DELIMITER. isEmpty() ? 0 :  index + OTP_DELIMITER.length()+1;"
        int length = OTP_LENGTH;
        code = message.substring(start, start + length);
        return code;
    }

    return code;
}

Thanks for the Awesome plugin. It reduce my work much.

ruisilva450 commented 5 years ago

I think the pull request https://github.com/sandeepdillerao/cordova-plugin-otp-auto-verification/pull/17 resolves this.

@sandeepdillerao can you confirm this?