From a8e33c51e6bdea43255314070b2b18681ec4e1f8 Mon Sep 17 00:00:00 2001 From: PH2 <1293456824@qq.com> Date: Mon, 23 Nov 2020 13:41:50 +0800 Subject: [PATCH] =?UTF-8?q?1=E3=80=81=E6=B7=BB=E5=8A=A0=E7=A7=92=E9=AA=8Cd?= =?UTF-8?q?emo?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- lib/util/second_test/second_test_util.dart | 81 ++++++++++++++++++++++ pubspec.yaml | 3 + 2 files changed, 84 insertions(+) create mode 100644 lib/util/second_test/second_test_util.dart diff --git a/lib/util/second_test/second_test_util.dart b/lib/util/second_test/second_test_util.dart new file mode 100644 index 0000000..d508ebe --- /dev/null +++ b/lib/util/second_test/second_test_util.dart @@ -0,0 +1,81 @@ +import 'package:secverify/secverify.dart'; +import 'package:zhiying_comm/util/log/let_log.dart'; + +class SecondTestUtil { + // sdk 版本 + String _version = "unkown"; + + // 是否支持 + bool _isVerifySupport = true; + + /// 单例对象 + static SecondTestUtil _instance; + + /// 内部构造方法,可避免外部暴露构造函数,进行实例化 + SecondTestUtil._internal(); + + /// 工厂构造方法,这里使用命名构造函数方式进行声明 + factory SecondTestUtil.getInstance() => _getInstance(); + + /// 获取单例内部方法 + static _getInstance() { + // 只能有一个实例 + if (_instance == null) { + _instance = SecondTestUtil._internal(); + } + return _instance; + } + + void init() { + //可选预先设置 + preSettings(); + //判断手机本地环境是否支持 + isVerifySupport(); + if (_isVerifySupport) { + //预取号 + preVerify(); + } + } + + void preVerify() { + Secverify.preVerify((Map ret, Map err) { + if (err != null) { + //失败情况下会返回错误信息,可以打印查看 +// showAlert(err.toString(),context); + Logger.log('mob 秒验登录失败: ${err?.toString()}, sdk 版本 = ${_version}'); + } else { + String rst = ret.toString(); + if (ret == null || ret.isEmpty) { + rst = 'mob 秒验 预登录成功!, sdk 版本 = ${_version}'; + Logger.log(rst); + } +// showAlert(rst,context); + } + }); + } + +// 预登录 + void preSettings() { + //提交隐私协议结果 + Secverify.submitPrivacyGrantResult(true); + //是否自动关闭授权页面,如果不自动关闭,必须在取号回调中调用方法关闭授权页面 + Secverify.autoFinishOauthPage(false); + //是否输出运营商控制台日志 + Secverify.setDebugMode(false); + //设置超时时间 + Secverify.setTimeOut(5000); + //获取当前SDK版本号 + getVersion(); + } + + Future getVersion() async { + String version; + version = await Secverify.getVersion; + _version = version; + } + + Future isVerifySupport() async { + bool isVerifySupport = await Secverify.isVerifySupport; + this._isVerifySupport = isVerifySupport; + } +} diff --git a/pubspec.yaml b/pubspec.yaml index 00c1c83..60ef6d1 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -47,6 +47,9 @@ dependencies: #图片预览控件 photo_view: ^0.10.2 imei_plugin: 1.2.0 + # mob 分享sdk + sharesdk_plugin: ^1.2.8 + secverify: ^1.0.2 loading_indicator: ^1.2.0