GithubHelp home page GithubHelp logo

verifykit / verifykit-sdk-android Goto Github PK

View Code? Open in Web Editor NEW
8.0 8.0 5.0 138 KB

VerifyKit Android SDK

Home Page: https://verifykit.com/

License: MIT License

verification phone-number sms-verification whatsapp-api whatsapp telegram sdk phone verify otp

verifykit-sdk-android's Introduction

VerifyKit

Platform API License

VerifyKit is the next generation phone number validation system. Users can easily verify their phone numbers without the need of entering phone number or a pin code.

How It Works?

  1. Register your app at https://www.verifykit.com and get your client keys and server key.
  2. Add VerifyKit SDK to your app
  3. Configure and start VerifyKit SDK
  4. When verification completed, send "sessionId" which VeriyfKit SDK gives you to your backend service
  5. At your server side, get user's phone number from VerifyKit service wtih "serverKey" and sessionId. You can check Backend Integration VerifyKit Flow

Security

"ServerKey" are used for getting info from VerifyKit service. Please keep "ServerKey" safe. Do not include your client's code base.

Installation

Add it to your app build.gradle at the end of repositories:

implementation 'org.bitbucket.verifykit:verifykit-android:${lastVersion}'

Add it to your root build.gradle at the end of repositories:

allprojects {
  repositories {
    ...
    maven { url 'https://jitpack.io' }
  }
}

Requirements

Minimum SDK Version is api 16

Usage

In your Application file you should initialize VerifyKit. VerifyKit.init() method needs VerifyKitOptions object.

Application.kt

  val theme = VerifyKitTheme(
            backgroundColor = Color.WHITE
        )
        VerifyKit.init(
            this,
            VerifyKitOptions(
                isLogEnabled = true,
                verifyKitTheme = theme
            )
        )

You can call VerifyKit.startVerification(this) method from your Activity or Fragment then get the result via VerifyCompleteListener interface from your Activity or Fragment.

 VerifyKit.startVerification(this, object : VerifyCompleteListener {
            override fun onSuccess(sessionId: String) {
              // TODO operate SUCCESS process
            }
            override fun onFail(error: VerifyKitError) {
              // TODO operate FAIL process
            }
        })

Optional You can pass user phone number to VerifyKit with startVerification method. In this way VerifyKit doesn't ask phone number to user

 VerifyKit.startVerification(  
    activity = this,  
    countryPhoneCode = "+90",
    phoneNumber = "5555555555",  
    mCompleteListener = object : VerifyCompleteListener {  
        override fun onSuccess(sessionId: String) {  
            // TODO operate SUCCESS process  
	  }  
  
        override fun onFail(error: VerifyKitError) {  
            // TODO operate FAIL process  
	  }  
    })

VerifyKit.checkInterruptedSession

There may be a case when user chooses a third party messaging app for validation, sends a message, but doesn't return to main app and kills it. In that case, that user is verified with VerifyKit but the main app doesn't know it yet.

To fix this, we have a method to check interrupted session status.

VerifyKit.checkInterruptedSession(object : VerifyCompleteListener {
            override fun onSuccess(sessionId: String) {
                // sessionId
            }
            override fun onFail(error: VerifyKitError) {
                // error
            }
        })

AndroidManifest

Open the /app/manifest/AndroidManifest.xml file.

Add the following meta-data elements, an activity for VerifyKit and intent filter for App Link inside your application element:

<meta-data
            android:name="com.verifykit.sdk.clientKey"
            android:value="your_verifykit_client_key" />
<meta-data
            android:name="com.verifykit.sdk.clientSecret"
            android:value="your_verifykit_client_secret" />
<activity
            android:name="com.verifykit.sdk.ui.VerificationActivity"
            android:launchMode="singleInstance"
            android:screenOrientation="portrait">
	<intent-filter android:autoVerify="true">
		<action android:name="android.intent.action.VIEW" />
		<category android:name="android.intent.category.DEFAULT" />
		<category android:name="android.intent.category.BROWSABLE" />
		<data
                    android:host="your_deep_link_url"
                    android:pathPattern="your_deep_link_pattern"
                    android:scheme="https" />
	</intent-filter>
</activity>

An Android App Link is a deep link based on your website URL that has been verified to belong to your website. So clicking one of these immediately opens your app if it's installed—the disambiguation dialog does not appear. Though the user may later change their preference for handling these links. For verifying your App Link see document

ProGuard

-keep class com.verifykit.sdk.core** { *; }

Backend Integration

Depending on the language you use in your backend service, you can use one of the following options.

You can use our php-sdk like this;

$vfk = new \VerifyKit\VerifyKit($serverKey);

/** @var \VerifyKit\Entity\Response $result */
$result = $vfk->getResult($sessionId);

if ($result->isSuccess()) {
    echo "Phone number : " . $result->getPhoneNumber() .
        ", Validation Type : " . $result->getValidationType() .
        ", Validation Date : " . $result->getValidationDate()->format('Y-m-d H:i:s') . PHP_EOL;
} else {
    echo "Error message : " . $result->getErrorMessage() . ", error code : " . $result->getErrorCode() . PHP_EOL;
}

You can use our python-sdk like this;

from VerifyKit import Verify

verify = Verify(server_key="{SERVER-KEY}")
verify.validation(session_id='{SESSION-ID}')

if verify.is_valid:
    #Validation success.
    print(verify.response())

elif verify.is_valid == False:
    #Validation fail.
    print(verify.response())
 

Or you can use curl request like this;

curl --location --request POST 'https://api.verifykit.com/v1.0/result' \
--header 'X-Vfk-Server-Key:{SERVER-KEY}' \
--header 'Content-Type: application/json' \
--form 'sessionId={{SESSION-ID}}’

Support

If you have any questions or requests, feel free to create an issue.

Author

VerifyKit is owned and maintained by VerifyKit DevTeam.

License

MIT

Copyright (c) 2019-2020 VerifyKit. https://verifykit.com

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

verifykit-sdk-android's People

Contributors

barisatalay avatar fustundag avatar hsmnzaydn avatar logicandroid avatar ozantas avatar rooest avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

verifykit-sdk-android's Issues

Verify Kit issue on version '0.1.11'

I'm getting this error body;
Cannot serialize Kotlin type com.verifykit.sdk.core.model.Meta. Reflective serialization of Kotlin classes without using kotlin-reflect has undefined and unexpected behavior. Please use KotlinJsonAdapter from the moshi-kotlin artifact or use code gen from the moshi-kotlin-codegen artifact.
for class com.verifykit.sdk.core.model.Meta meta
for class a.a.a.b.c.c.a.b

Getting 429 for a long time

Hi,

We are using verifykit's sms verification method to confirm our users from their phone numbers. Sending requests to /v1.0/send-otp and /v1.0/check-otp endpoints of verifykit. However, one of the environment is stacked due to getting 429 Too many request error for these requests although we can do same operations from other environments such as dev and local environments with the same token successfully. We think that our env's ip has been blocked from verifykit side.

How can we resolve this situation without any change from our side? Any tips or recommendations?

Sample Application

It would be helpful to add a sample application to this repo, especially for the Android App Link side.

Thank you

Where is the code to Java?

I like so much the api to use in my app on SMS and WhatsApp autentication, but i can't see an example code for a Java application... Is it posible?

gradle cant resolve implementation

Im trying to add VerifyKit to my android app but Gradle cant find any version of sdk

ERROR: Failed to resolve: com.github.verifykit:verifykit-sdk-android:.....

Exception when startverify

hi team,
I just tried your sdk.
But when I start the verification, it throws
VerifyKit: exception:java.lang.IllegalStateException: Expected BEGIN_OBJECT but was STRING at line 1 column 1 path $

I use version 0.4.1

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.