1 Star 0 Fork 0

友验技术团队 / YoTest-Android-SDK

Create your Gitee Account
Explore and code with more than 12 million developers,Free private repositories !:)
Sign up
This repository doesn't specify license. Please pay attention to the specific project description and its upstream code dependency when using it.
Clone or Download
contribute
Sync branch
Cancel
Notice: Creating folder will generate an empty file .keep, because not support in Git
Loading...
README

YoTest-Android-SDK 文档

基于虚拟机保护、设备特征识别和操作行为识别的新一代智能验证码,具备智能评分、抗Headless、模拟伪装、针对恶意设备自动提升验证难度等多项安全措施,帮助开发者减少恶意攻击导致的数字资产损失,强力护航业务安全。

仓库入口:

兼容性

  • Android 4.4+ (即API 19+)

示例项目

你可以通过Android Studio 4+打开本项目进行示例项目的预览和更改,具体文件请点击此处

安装

在工程根目录的build.gradle中添加

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

在使用的module的build.gradle文件中添加

android {
    compileOptions {
        sourceCompatibility JavaVersion.VERSION_1_8
        targetCompatibility JavaVersion.VERSION_1_8
    }
}

dependencies {
    implementation 'com.github.YoTest-team:YoTest-Android-SDK:1.0.3'
}

快速开始

在application的onCreate中初始化SDK。

import com.fastyotest.library.YoTestCaptcha

YoTestCaptcha.init(
    this.applicationContext,
    "当前项目所属的accessId,可以在后台中进行获取及查看"
    ) { code, message ->
        Log.d("MyApplication", "YoTestCaptcha init $message")
}

在要使用的页面中添加:

import com.fastyotest.library.YoTestCaptchaVerify

// 设置监听事件
private val yoTestListener = object : YoTestListener() {
    override fun onReady(data: String?) {
        Log.d(TAG, "onReady: $data")
    }

    override fun onSuccess(token: String, verified: Boolean) {
        Log.d(TAG, "onSuccess: token=$token; verified=$verified")
    }

    override fun onError(code: Int, message: String) {
        Log.d(TAG, "onError: code=$code; message=$message")
    }

    override fun onClose(data: String?) {
        Log.d(TAG, "onClose: $data")
    }
}

// 初始化验证模块
private val yoTestCaptchaVerify = YoTestCaptchaVerify(this, yoTestListener)

// 进行验证
yoTestCaptchaVerify.verify()

// 在使用页面的生活周期方法中销毁资源
override fun onDestroy() {
    super.onDestroy()
    yoTestCaptchaVerify.destroy()
}

API

YoTestCaptcha初始化函数

YoTestCaptchaVerify实例方法

YoTestListener实例方法

YoTestCaptcha.init(context, accessId, callback)

  • context <Context> 必填,ApplicationContext
  • accessId <String> 必填,当前项目所属的accessId,可以在友验后台中进行相关获取及查看
  • callback <Function>
    • code: <Int> 错误码,其返回非0时,请做好错误处理
    • message: <String> 提示信息
  • return: Unit

一般情况下我们会将init方法放在Application onCreate时进行触发,如果有其他业务相关需求,请一定确保init方法在verify方法之前调用完成

YoTestCaptcha.init(
    this.applicationContext,
    "当前项目所属的accessId,可以在后台中进行获取及查看"
    ) { code, message ->
        Log.d("MyApplication", "YoTestCaptcha init $message")
}

YoTestCaptchaVerify(context, listener)

  • context <Activity> 必填,当前activity
  • listener <Object> 非必填,回调验证各个状态 -return: this

用于初始化验证模块

yoTestCaptchaVerify = YoTestCaptchaVerify(this, yoTestListener)

YoTestCaptchaVerify.verify()

  • return: Unit

用于将调起验证页面

yoTestCaptchaVerify.verify()

YoTestCaptchaVerify.destroy()

  • return: Unit

用于销毁相关资源

yoTestCaptchaVerify.destroy()

YoTestListener.onReady(data)

  • data <String?> 可以为空
  • return: Unit

初始化成功的回调监听

val yoTestCaptchaVerify = YoTestCaptchaVerify(this, object : YoTestListener(){
    override fun onReady(data: String?) {
        Log.d(TAG, "onReady: $data")
    }
})
yoTestCaptchaVerify.verify()

YoTestListener.onShow(data)

  • data <String?> 可以为空
  • return: Unit

验证内容展现的回调监听

val yoTestCaptchaVerify = YoTestCaptchaVerify(this, object : YoTestListener(){
    override fun onShow(data: String?) {
        Log.d(TAG, "onShow: $data")
    }
})
yoTestCaptchaVerify.verify()

YoTestListener.onSuccess(token, verified)

  • token <String> 当前验证的凭证,需要提交给后端来进行是否通过判断
  • verified <Boolean> 是否验证成功
  • return: Unit

验证成功的回调监听

val yoTestCaptchaVerify = YoTestCaptchaVerify(this, object : YoTestListener(){
    override fun onSuccess(token: String, verified: Boolean) {
        Log.d(TAG, "onSuccess: token=$token; verified=$verified")
    }
})
yoTestCaptchaVerify.verify()

YoTestListener.onError(code, message)

  • code <Int> 错误码
  • message <String> 错误相关信息
  • return: Unit

验证错误的回调监听

val yoTestCaptchaVerify = YoTestCaptchaVerify(this, object : YoTestListener(){
    override fun onError(code: Int, message: String) {
        Log.d(TAG, "onError: code=$code; message=$message")
    }
})
yoTestCaptchaVerify.verify()

YoTestListener.onClose(data)

  • data <String?> 可以为空
  • return: Unit

验证关闭的回调监听

val yoTestCaptchaVerify = YoTestCaptchaVerify(this, object : YoTestListener(){
    override fun onClose(data: String?) {
        Log.d(TAG, "onClose: $data")
    }
})
yoTestCaptchaVerify.verify()

Empty file

About

YoTest应用端(Android/安卓) SDK expand collapse
Cancel

Releases

No release

Contributors

All

Activities

Load More
can not load any more
1
https://gitee.com/yo-test-team/yo-test-android-sdk.git
git@gitee.com:yo-test-team/yo-test-android-sdk.git
yo-test-team
yo-test-android-sdk
YoTest-Android-SDK
master

Search