Fetch the repository succeeded.
基于虚拟机保护、设备特征识别和操作行为识别的新一代智能验证码,具备智能评分、抗Headless、模拟伪装、针对恶意设备自动提升验证难度等多项安全措施,帮助开发者减少恶意攻击导致的数字资产损失,强力护航业务安全。
你可以通过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()
}
YoTestCaptcha初始化函数
YoTestCaptchaVerify实例方法
YoTestListener实例方法
context
<Context> 必填,ApplicationContextaccessId
<String> 必填,当前项目所属的accessId,可以在友验后台中进行相关获取及查看callback
<Function>
return:
Unit一般情况下我们会将init方法放在Application onCreate时进行触发,如果有其他业务相关需求,请一定确保init方法在verify方法之前调用完成。
YoTestCaptcha.init(
this.applicationContext,
"当前项目所属的accessId,可以在后台中进行获取及查看"
) { code, message ->
Log.d("MyApplication", "YoTestCaptcha init $message")
}
context
<Activity> 必填,当前activitylistener
<Object> 非必填,回调验证各个状态
-return
: this用于初始化验证模块
yoTestCaptchaVerify = YoTestCaptchaVerify(this, yoTestListener)
return
: Unit用于将调起验证页面
yoTestCaptchaVerify.verify()
return
: Unit用于销毁相关资源
yoTestCaptchaVerify.destroy()
data
<String?> 可以为空return
: Unit初始化成功的回调监听
val yoTestCaptchaVerify = YoTestCaptchaVerify(this, object : YoTestListener(){
override fun onReady(data: String?) {
Log.d(TAG, "onReady: $data")
}
})
yoTestCaptchaVerify.verify()
data
<String?> 可以为空return
: Unit验证内容展现的回调监听
val yoTestCaptchaVerify = YoTestCaptchaVerify(this, object : YoTestListener(){
override fun onShow(data: String?) {
Log.d(TAG, "onShow: $data")
}
})
yoTestCaptchaVerify.verify()
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()
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()
data
<String?> 可以为空return
: Unit验证关闭的回调监听
val yoTestCaptchaVerify = YoTestCaptchaVerify(this, object : YoTestListener(){
override fun onClose(data: String?) {
Log.d(TAG, "onClose: $data")
}
})
yoTestCaptchaVerify.verify()
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。