Giter VIP home page Giter VIP logo

sendotpandroid's Introduction

SendOTP Android Sdk!

The SendOtp Verification SDK makes verifying phone numbers easy. SDK supports the verification of phone numbers via SMS & Calls.


Getting started

Gradle

Just add the "compile 'com.msg91.sendotp.library:library:2.7'" in your build.gradle of your module.

dependencies {
...
compile 'com.msg91.sendotp.library:library:2.7'
...
}

Maven

grab via Maven:

<dependency>
   <groupId>com.msg91.sendotp.library</groupId>
   <artifactId>library</artifactId>
   <version>2.7</version>
   <type>pom</type>
</dependency>

Note:

  • Login at sendOTP
  • or to create account Sign Up at MSG91 to use sendOTP services.

Create New Application

After login at sendOTP click on create new application fill app details

Note:

  • Select Android as Application Type
  • Package Name is unique and it's not editable.
  • In the key field set your debug version key hash while you are in development mode.
  • In the key field set your release version key hash while you are in production mode.

Make OTP request

Note: implement 'VerificationListener' in your activity or fragment to get result call backs.

create instance of Verification as a class variable and initialise it by passing country code and mobile number.

mVerification = SendOtpVerification.createSmsVerification(this, "set_phone_number", this, "set_country_code");

         mVerification.initiate(); //sending otp on given number

Verify OTP request

Use instance of Verification to call verify method pass received OTP here.

mVerification.verify("verification_code"); //verifying otp for given number

Getting result call backs

As a Result of each request any one of method will triggered.

  @Override
 public void onInitiated(String response) {
   Log.d(TAG, "Initialized!" + response);
   //control comes when OTP successfully sent.
 }

   @Override
   public void onInitiationFailed(Exception exception) {
     Log.e(TAG, "Verification initialization failed: " + exception.getMessage());
      //control comes when OTP  failed successfully sent.
   }

 @Override
   public void onVerified(String response) {
     Log.d(TAG, "Verified!\n" + response);
        //control comes when OTP  verified successfully.
   }

   @Override
   public void onVerificationFailed(Exception exception) {
     Log.e(TAG, "Verification failed: " + exception.getMessage());
     //control comes when OTP  verification failed.
   }

FAQ

  • If OTP not working in release mode but working in debug/test environment please replace your secret key of release version at sendOTP [to get secret key search logs of android studio by 'UserHeaders' or use this code snippet to generate]
  • If you are getting exception message 'Request Unsuccessful Try Again' it is because device not supporting 'https' , Solution is to set extra parameter true in createSmsVerification like :

mVerification = SendOtpVerification.createSmsVerification(this, phoneNumber, this, countryCode, true);

License

Copyright 2016 MSG91

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.

sendotpandroid's People

Watchers

James Cloos avatar Sameer Rathod avatar

Forkers

gypsybud

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.