MCPcopy Index your code
hub / github.com/MSG91/sendotp-android

github.com/MSG91/sendotp-android @1.3.1

Chat with this repo
repository ↗ · DeepWiki ↗ · release 1.3.1 ↗ · + Follow
63 symbols 151 edges 7 files 1 documented · 2%
What it actually does AI analysis from the code graph — generated when you open this
loading…
README

SendOTP Android Sdk!

For Androidx and Above use this library and for older sdk 28 and blow see here

This Library Supports Androidx and older versions up to (SDK-16):

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

dependencies {
...
 implementation 'com.msg91.sendotpandroid.library:library:1.3.1'
...
}

Maven

grab via Maven:

<dependency>
  <groupId>com.msg91.sendotpandroid.library</groupId>
  <artifactId>library</artifactId>
  <version>1.3.1</version>
  <type>pom</type>
</dependency>

Ivy

grab via Ivy:

<dependency org='com.msg91.sendotpandroid.library' name='library' rev='1.3.1'>
  <artifact name='library' ext='pom' ></artifact>
</dependency>

-Login or create account at MSG91 to use sendOTP services.

Get your authKey

After login at MSG91 follow below steps to get your authkey

  • Select API option available on panel.
  • If you are first time user then generate new authkey.
  • copy authKey & keep it enable, gradle under defaultConfig.
android{
 defaultConfig{
    buildConfigField"String","SEND_OTP_KEY",'"ADD_YOUR_KEY_HERE"'
  }
}

Usage

initialize'SendOTP' in your Application class.

public class ApplicationClass extends Application {
    @Override
  public void onCreate() {
        super.onCreate();
        SendOTP.initializeApp(this);  //initialization
    }
}

implement 'VerificationListener' in your class & override below result callback.

@Override
public void onSendOtpResponse(final SendOTPResponseCode responseCode, final String message) {
runOnUiThread(new Runnable() {
    @Override
  public void run() {
        Log.e(TAG, "onSendOtpResponse: " + responseCode.getCode() + "=======" + message);
        if (responseCode == SendOTPResponseCode.DIRECT_VERIFICATION_SUCCESSFUL_FOR_NUMBER || responseCode == SendOTPResponseCode.OTP_VERIFIED) {
            //otp verified OR direct verified by send otp 2.O
        } else if (responseCode == SendOTPResponseCode.READ_OTP_SUCCESS) {
            //Auto read otp from sms successfully
           // you can get otp form message filled
        } else if (responseCode == SendOTPResponseCode.SMS_SUCCESSFUL_SEND_TO_NUMBER || responseCode == SendOTPResponseCode.DIRECT_VERIFICATION_FAILED_SMS_SUCCESSFUL_SEND_TO_NUMBER)
        {
            // Otp send to number successfully
        } else {
            //exception found
        }
    }
 });
}

Build Your requirements by initialize builder with pass country code and mobile number. Optional Parameters are gose in blow method.

new SendOTPConfigBuilder()
        .setCountryCode(countryCode)
        .setMobileNumber(phoneNumber)
        .setVerifyWithoutOtp(true)//direct verification while connect with mobile network
        .setAutoVerification(VerificationActivity.this)//Auto read otp from Sms And Verify
        .setSenderId("ABCDEF")
        .setMessage("##OTP## is Your verification digits.")
        .setOtpLength(OTP_LNGTH)
        .setVerificationCallBack(this).build();

Sending OTP / StartVerification to Number by using above configuration.

SendOTP.getInstance().getTrigger().initiate();

manually verifying OTP

SendOTP.getInstance().getTrigger().verify(otp);

resend OTP by voice or text .

SendOTP.getInstance().getTrigger().resend(RetryType.VOICE);

OR

SendOTP.getInstance().getTrigger().resend(RetryType.TEXT);

onDestroy

@Override
protected void onDestroy() {
    super.onDestroy();
    SendOTP.getInstance().getTrigger().stop();
}

customize message text :

OTP## is use for default OTP genrated from sdk

.message("##OTP## is Your verification digits.")

OR genrate your otp and set in parameter

String OTP = "1234";

and use blow method

.otp(OTP )
.message(OTP +" is Your verification digits.")

Unicode : To show unicode sms set true in unicode parameter.

.unicode(true)

Optional Parameters

  • setMessage("##OTP## with your Custom OTP message.") [for custom OTP message]
  • setOtpExpireInMinute(5) [long param ,default value is one day]
  • setSenderId("SENDOTP")
  • setOtp("1234") [use your OTP code]
  • setOtpLength("4") [custom OTP length]
  • setUnicodeEnable(false) [use unicode (or other languages)]
  • setVerifyWithoutOtp (true) [direct verification while connect with mobile network]
  • setOtpHits (5) [number of otp request per number]
  • setOtpHitsTimeOut (0L) [number of otp request time out reset in milliseconds default is 24 hours]
  • setAutoVerification (ActivityContext_here) [number of otp request per number]

License

Copyright 2020 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.

Extension points exported contracts — how you extend this code

CountryIsoSelectedListener (Interface)
(no doc) [1 implementers]
app/src/main/java/com/msg91/sendotp/sample/CountrySpinner.java

Core symbols most depended-on inside this repo

getInstance
called by 11
app/src/main/java/com/msg91/sendotp/sample/DataManager.java
hideProgressMessage
called by 6
app/src/main/java/com/msg91/sendotp/sample/DataManager.java
enableInputField
called by 4
app/src/main/java/com/msg91/sendotp/sample/VerificationActivity.java
hideKeypad
called by 3
app/src/main/java/com/msg91/sendotp/sample/VerificationActivity.java
showProgressMessage
called by 2
app/src/main/java/com/msg91/sendotp/sample/DataManager.java
tryAndPrefillPhoneNumber
called by 2
app/src/main/java/com/msg91/sendotp/sample/MainActivity.java
setButtonsEnabled
called by 2
app/src/main/java/com/msg91/sendotp/sample/MainActivity.java
resetNumberTextWatcher
called by 2
app/src/main/java/com/msg91/sendotp/sample/MainActivity.java

Shape

Method 55
Class 7
Interface 1

Languages

Java100%

Modules by API surface

app/src/main/java/com/msg91/sendotp/sample/VerificationActivity.java20 symbols
app/src/main/java/com/msg91/sendotp/sample/MainActivity.java14 symbols
app/src/main/java/com/msg91/sendotp/sample/OtpEditText.java10 symbols
app/src/main/java/com/msg91/sendotp/sample/CountrySpinner.java10 symbols
app/src/main/java/com/msg91/sendotp/sample/DataManager.java5 symbols
app/src/main/java/com/msg91/sendotp/sample/ApplicationClass.java2 symbols
app/src/androidTest/java/com/msg91/sendotp/sample/ApplicationTest.java2 symbols

For agents

$ claude mcp add sendotp-android \
  -- python -m otcore.mcp_server <graph>

⬇ download graph artifact