Android SDK
When you need a real-time response to a Missed-call OTP, use our SDK on your Android code. Easier to send an Missed-call OTP and receive the OTP code.
How to Implement
These are several steps how to implement Motict Call SDK on your Android code.
Step 1
Add the JitPack repository to your build file. Add it in your root build.gradle at the end of repositories
allprojects {
repositories {
...
maven { url 'https://jitpack.io' }
}
}
Step 2
Add the dependency
dependencies {
implementation 'com.github.antonygunawan94.motict-android-sdk:sdk:0.4.2'
}
Step 3
Import motict sdk to your activity, fragment or where will you use our SDK
import com.motict.sdk.MotictMissedCallVerifier;
Step 4
Initialize motict sdk using our builder and add your own listener, list of listeners can be found at the bottom of this page
MotictMissedCallVerifier
verifier = new MotictMissedCallVerifier
.Builder(this)
.withApiKey("api_key")
addMissedCallVerificationStartedListener(start ->
runOnUiThread(() -> Toast.makeText(ExampleOneActivity.this,
String.format("Missed Call Verification Started: %s %s %s %s",
start.getVerifiedPhoneNumber(),
start.getToReceivedFourPinCode(),
start.getToReceivedSixPinCode(),
start.getToReceivedPhoneNumber()),
Toast.LENGTH_SHORT)
.show())
)
.addMissedCallVerificationFailedListener(failed ->
runOnUiThread(() -> {
if (failed instanceof PermissionDeniedException)
return;
Toast.makeText(this,
String.format("Missed Call Verification Failed: %s",
failed.toString()), Toast.LENGTH_SHORT)
.show();
})
)
.build();
Step 5
Start verifying phone number using missed call, don’t forget to catch exceptions thrown by this function. List of exceptions can be found and the bottom of this page
try {
verifier.startVerification(phoneNumber);
} catch (PermissionDeniedException e) {
Log.e("VERIFICATION_FAILED", e.toString());
} catch (Exception e) {
Log.e("VERIFICATION_FAILED", e.toString());
}
Step 6
Just relax and let our SDK do all the hard works for you
Step 7
Don’t forget to clear the SDK after you’ve already done using it to avoid memory leak
@Override
protected void onDestroy() {
verifier.clear();
super.onDestroy();
}
SDK Reference
You can find more detail about the Motict Missed-call SKD here.
class MotictMissedCallVerifier
class MotictMissedCallVerifier
// LIST OF METHODS:
public void startVerification(String phoneNumber) throws Exception
// method for starting missed call verification flow
public void cancelVerification()
// method for cancelling current missed call verification flow
public void verifyPinCode(String pinCode)
// method for manually verifying pin code when missed call received
public void addMissedCallVerificationStartedListener(MissedCallVerificationStartedListener listener)
// method for adding callback when missed call verification flow started
public void addMissedCallVerificationReceivedListener(MissedCallVerificationReceivedListener listener)
// method for adding callback when missed received
public void addMissedCallVerificationSucceedListener(MissedCallVerificationSucceedListener listener)
// method for adding callback when missed call verification flow succeed
public void addMissedCallVerificationCancelledListener(MissedCallVerificationCancelledListener listener)
// method for adding callback when missed call verification flow cancelled
public void clear()
// method for clearing resource used by SDK to avoid memory leak
class MotictMissedCallVerifier.Builder
class MotictMissedCallVerifier.Builder
// CONSTRUCTOR:
public Builder(Context context)
// LIST OF METHODS:
public Builder withApiKey(String apiKey)
// method for registering api key to this builder
public void addMissedCallVerificationStartedListener(MissedCallVerificationStartedListener listener)
// method for adding callback when missed call verification flow started
public void addMissedCallVerificationReceivedListener(MissedCallVerificationReceivedListener listener)
// method for adding callback when missed received
public void addMissedCallVerificationSucceedListener(MissedCallVerificationSucceedListener listener)
// method for adding callback when missed call verification flow succeed
public void addMissedCallVerificationCancelledListener(MissedCallVerificationCancelledListener listener)
// method for adding callback when missed call verification flow cancelled
// LIST OF EXCEPTIONS:
class AirplaneModeActiveException
// exception thrown when airplane mode is active when starting missed call verification flow
class ApiResponseException
// exception thrown when there are exceptions when our SDK calling our Backend API
class BlockedUnusualActivityException
// exception thrown when there are unusual activity on verified phone number
class InvalidAuthException
// exception thrown when SDK is supplied with wrong API Key
class InvalidAuthTokenException
// exception thrown when SDK is supplied with wrong API Key
class InvalidPhoneNumberException
// exception thrown when SDK is supplied with invalid phone number format
class InvalidPinCodeException
// exception thrown when SDK is supplied with invalid pin code in current missed call verification flow
class IPNotAllowedException
// exception thrown when SDK is called when caller IP is blocked by our system
class MaxAttemptExceededException
// exception thrown when SDK is called using the same phone numbers several times
class MissingAuthTokenException
// exception thrown when SDK is supplied with empty API Key
class PermissionDeniedException
// exception thrown when SDK doesn’t have required permission
class PinCodeVerificationNotStartedException
// exception thrown when SDK verifyPinCode method called before startVerification method called
class ServiceUnavailableException
// exception thrown when SDK is called when our backend system crashing