项目作者: verifykit

项目描述 :
VerifyKit Android SDK
高级语言:
项目地址: git://github.com/verifykit/verifykit-sdk-android.git
创建时间: 2019-11-04T12:54:46Z
项目社区:https://github.com/verifykit/verifykit-sdk-android

开源协议:MIT License

下载


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:
    1. implementation 'org.bitbucket.verifykit:verifykit-android:${lastVersion}'
    Add it to your root build.gradle at the end of repositories:
    1. allprojects {
    2. repositories {
    3. ...
    4. maven { url 'https://jitpack.io' }
    5. }
    6. }

    Requirements

    Minimum SDK Version is api 16

    Usage

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

Application.kt

  1. val theme = VerifyKitTheme(
  2. backgroundColor = Color.WHITE
  3. )
  4. VerifyKit.init(
  5. this,
  6. VerifyKitOptions(
  7. isLogEnabled = true,
  8. verifyKitTheme = theme
  9. )
  10. )

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

  1. VerifyKit.startVerification(this, object : VerifyCompleteListener {
  2. override fun onSuccess(sessionId: String) {
  3. // TODO operate SUCCESS process
  4. }
  5. override fun onFail(error: VerifyKitError) {
  6. // TODO operate FAIL process
  7. }
  8. })

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

  1. VerifyKit.startVerification(
  2. activity = this,
  3. countryPhoneCode = "+90",
  4. phoneNumber = "5555555555",
  5. mCompleteListener = object : VerifyCompleteListener {
  6. override fun onSuccess(sessionId: String) {
  7. // TODO operate SUCCESS process
  8. }
  9. override fun onFail(error: VerifyKitError) {
  10. // TODO operate FAIL process
  11. }
  12. })

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.

  1. VerifyKit.checkInterruptedSession(object : VerifyCompleteListener {
  2. override fun onSuccess(sessionId: String) {
  3. // sessionId
  4. }
  5. override fun onFail(error: VerifyKitError) {
  6. // error
  7. }
  8. })

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:

  1. <meta-data
  2. android:name="com.verifykit.sdk.clientKey"
  3. android:value="your_verifykit_client_key" />
  4. <meta-data
  5. android:name="com.verifykit.sdk.clientSecret"
  6. android:value="your_verifykit_client_secret" />
  7. <activity
  8. android:name="com.verifykit.sdk.ui.VerificationActivity"
  9. android:launchMode="singleInstance"
  10. android:screenOrientation="portrait">
  11. <intent-filter android:autoVerify="true">
  12. <action android:name="android.intent.action.VIEW" ></action>
  13. <category android:name="android.intent.category.DEFAULT" ></category>
  14. <category android:name="android.intent.category.BROWSABLE" ></category>
  15. <data
  16. android:host="your_deep_link_url"
  17. android:pathPattern="your_deep_link_pattern"
  18. android:scheme="https" ></data>
  19. </intent-filter>
  20. </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

  1. -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;

  1. $vfk = new \VerifyKit\VerifyKit($serverKey);
  2. /** @var \VerifyKit\Entity\Response $result */
  3. $result = $vfk->getResult($sessionId);
  4. if ($result->isSuccess()) {
  5. echo "Phone number : " . $result->getPhoneNumber() .
  6. ", Validation Type : " . $result->getValidationType() .
  7. ", Validation Date : " . $result->getValidationDate()->format('Y-m-d H:i:s') . PHP_EOL;
  8. } else {
  9. echo "Error message : " . $result->getErrorMessage() . ", error code : " . $result->getErrorCode() . PHP_EOL;
  10. }

You can use our python-sdk like this;

  1. from VerifyKit import Verify
  2. verify = Verify(server_key="{SERVER-KEY}")
  3. verify.validation(session_id='{SESSION-ID}')
  4. if verify.is_valid:
  5. #Validation success.
  6. print(verify.response())
  7. elif verify.is_valid == False:
  8. #Validation fail.
  9. print(verify.response())

Or you can use curl request like this;

  1. curl --location --request POST 'https://api.verifykit.com/v1.0/result' \
  2. --header 'X-Vfk-Server-Key:{SERVER-KEY}' \
  3. --header 'Content-Type: application/json' \
  4. --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.