sdkCallback static method
void
sdkCallback({
- dynamic onSDKTokenAuthSuccess,
- dynamic onSDKTokenUpdate,
- dynamic onSDKTokenAuthFailure,
- dynamic onVerifySuccess,
- dynamic onHalfwayVerifySuccess,
- dynamic onVerifyFailed,
- dynamic onTemplateFinish,
- dynamic onGetPhoneNumber,
- dynamic onProtocolClick,
- dynamic onVerifyInterrupt,
- dynamic onAuthEvent,
Implementation
static void sdkCallback(
{onSDKTokenAuthSuccess,
onSDKTokenUpdate,
onSDKTokenAuthFailure,
onVerifySuccess,
onHalfwayVerifySuccess,
onVerifyFailed,
onTemplateFinish,
onGetPhoneNumber,
onProtocolClick,
onVerifyInterrupt,
onAuthEvent}) {
_methodChannel.setMethodCallHandler((call) async {
final AuthResponseModel responseModel = AuthResponseModel.fromJson(
Map.from(call.arguments),
);
switch (call.method) {
case 'onSDKTokenAuthSuccess':
// token鉴权成功
await onSDKTokenAuthSuccess();
break;
case 'onSDKTokenUpdate':
// 获取新Token
return await onSDKTokenUpdate();
case 'onSDKTokenAuthFailure':
// token鉴权失败
await onSDKTokenAuthFailure(responseModel);
break;
case 'onVerifySuccess':
// 认证成功
onVerifySuccess(responseModel);
break;
case 'onHalfwayVerifySuccess':
// 中途认证节点
onHalfwayVerifySuccess(responseModel);
break;
case 'onVerifyFailed':
// 认证失败
onVerifyFailed(responseModel);
break;
case 'onTemplateFinish':
// 场景流程结束
onTemplateFinish(responseModel);
break;
case 'onGetPhoneNumber':
// 填充手机号
return onGetPhoneNumber();
case 'onProtocolClick':
// 点击协议富文本
onProtocolClick(responseModel);
break;
case 'onVerifyInterrupt':
// 认证中断
onVerifyInterrupt(responseModel);
break;
case 'onAuthEvent':
// 场景事件回调
onAuthEvent(responseModel);
break;
default:
throw UnsupportedError('Unrecognized JSON message');
}
});
}