Giter Site home page Giter Site logo

pratheepkanati / autodetectotpandroid Goto Github PK

View Code? Open in Web Editor NEW

This project forked from pratheepchowdhary/autodetectotpandroid

0.0 0.0 0.0 3.25 MB

Android Library To Auto Detect OTP Without Sms Permissions

Home Page: https://www.androidhunt.in/auto-detect-otp-with-out-sms-permission-android/

Java 100.00%

autodetectotpandroid's Introduction

AutoDetectOTPAndroid

Download API

AutoDetectOTPAndroid is an Android libary to Integrate Auto Detect OTP With Out Sms Permissions Required To Your Android Appliaction Essaily With less Stuff.

Usage

1. Add the following to your build.gradle.

repositories {
    maven {
        url  "https://dl.bintray.com/pratheepchowdhary/maven" 
    }
}
   
dependencies {
  implementation 'in.androidhunt.otp:AutoDetectOTPAndroid:1.0.0'
}

2. Example Message Format and Generating Hash Code

       //Example Message Format

        <#>Your AndroidHunt OTP is: 8686. ynfd/rIwy/+

        ynfd/rIwy/+  is the hash code of your Application
       //There are Two  Ways To Genearate Hash Code One Is By Using Command Line
        keytool -exportcert -alias YOUR_KEYSTORE_ALIAS -keystore YOUR_KEYSTORE_FILE | xxd -p | tr -d "[:space:]" | echo -n com.example.myapp `cat` | sha256sum | tr -d "[:space:]-" | xxd -r -p | base64 | cut -c1-11
      //Other Way  By Doing Programatically Inside The Application.
      //Here You get Hash code by Using With Our Library
      String hashCode = AutoDetectOTP.getHashCode(this);
      // above string like this "ynfd/rIwy/+"
Obtain the user's phone number

3. Obtain the user's phone number Using hint picker with prompt

        AutoDetectOTP autoDetectOTP=new AutoDetectOTP(this);
        //To display List Of Phone No Linked with Google Account  By showing Dialog as Shown Above
        autoDetectOTP.requestPhoneNoHint();

        //we can get phone number onActivity Result when User Picked From prompt
           @Override
           protected void onActivityResult(int requestCode, int resultCode, Intent data) {
               super.onActivityResult(requestCode, resultCode, data);
               if (requestCode == AutoDetectOTP.RC_HINT) {
                   if (resultCode == RESULT_OK) {
                   String phoneNo=autoDetectOTP.getPhoneNo(data);

                   }
                   else {
                   //nothing selected
                   }

               }
           }
Verification

4. Auto Detect OTP Usage

        AutoDetectOTP autoDetectOTP=new AutoDetectOTP(this);
        autoDetectOTP.startSmsRetriver(new AutoDetectOTP.SmsCallback() {
                  @Override
                  public void connectionfailed() {

                      //do something here on failure
                      Toast.makeText(OtpActivity.this,"Failed", Toast.LENGTH_SHORT).show();
                  }

                  @Override
                  public void connectionSuccess(Void aVoid) {
                      //do something here on success
                      Toast.makeText(OtpActivity.this,"Success", Toast.LENGTH_SHORT).show();
                  }

                  @Override
                  public void smsCallback(String sms) {
                  //  Get Sms Message Here pick what want from message here
                      if(sms.contains(":") && sms.contains(".")) {
                          String otp = sms.substring( sms.indexOf(":")+1 , sms.indexOf(".") ).trim();
                          //otpTextView.setOTP(otp);
                          Toast.makeText(OtpActivity.this,"The OTP is " + otp, Toast.LENGTH_SHORT).show();
                      }
                  }
              });
              -----------------
              // Finally Stop Sms Retriver BY Calling  autoDetectOTP.stopSmsReciever() On Stop As  Shown Below
               @Override
                  protected void onStop() {
                      super.onStop();
                      autoDetectOTP.stopSmsReciever();
                  }
Licences
--------
    Copyright 2019 Pratheep Chowdhary.

    Licensed under the Apache License, Version 2.0 (the "License");
    you may not use this file except in compliance with the License.
    You may obtain a copy of the License at

       http://www.apache.org/licenses/LICENSE-2.0

    Unless required by applicable law or agreed to in writing, software
    distributed under the License is distributed on an "AS IS" BASIS,
    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
    See the License for the specific language governing permissions and
    limitations under the License.

autodetectotpandroid's People

Contributors

pratheepchowdhary avatar pratheepkanati avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.