1 Star 0 Fork 0

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

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
该仓库未声明开源许可证文件(LICENSE),使用请关注具体项目描述及其代码上游依赖。
克隆/下载
贡献代码
同步代码
取消
提示: 由于 Git 不支持空文件夾,创建文件夹后会生成空的 .keep 文件
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()

空文件

简介

YoTest应用端(Android/安卓) SDK 展开 收起
取消

发行版

暂无发行版

贡献者

全部

近期动态

加载更多
不能加载更多了
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

搜索帮助