Skip to content

Commit 539d916

Browse files
author
qingqing.wang
committed
v0.6.4 新增获取验证码、设置前后两次获取验证码的时间间隔接口
1 parent 524fd2c commit 539d916

File tree

5 files changed

+134
-31
lines changed

5 files changed

+134
-31
lines changed

CHANGELOG.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@
22
## 0.6.4
33
+ 新增:授权页和隐私页状态栏样式
44
+ 新增:授权页弹出是否使用动画
5+
+ 新增:设置前后两次获取验证码的时间间隔 [setSmsIntervalTime]
6+
+ 新增:获取验证码 [getSmsCode] 具体使用查看 API 文档或者 demo 样例;
57
## 0.6.3
68
+ 修改文档
79
## 0.6.2

android/src/main/java/com/jiguang/jverify/JverifyPlugin.java

Lines changed: 47 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -113,6 +113,10 @@ public void onMethodCall(MethodCall call, Result result) {
113113
clearPreLoginCache(call, result);
114114
} else if (call.method.equals("setCustomAuthorizationView")) {
115115
setCustomAuthorizationView(call, result);
116+
} else if (call.method.equals("getSMSCode")) {
117+
getSMSCode(call, result);
118+
} else if (call.method.equals("setSmsIntervalTime")) {
119+
setSmsIntervalTime(call, result);
116120
} else {
117121
result.notImplemented();
118122
}
@@ -186,6 +190,48 @@ private boolean isInitSuccess(MethodCall call, Result result) {
186190
return isSuccess;
187191
}
188192

193+
/**
194+
* 设置前后两次获取验证码的时间间隔,默认 30000ms,有效范围(0,300000)
195+
*/
196+
private void setSmsIntervalTime(MethodCall call, Result result) {
197+
Log.d(TAG, "Action - setSmsIntervalTime:");
198+
Object intervalTime = getValueByKey(call, "intervalTime");
199+
JVerificationInterface.setSmsIntervalTime((Long) intervalTime);
200+
}
201+
202+
/**
203+
* 获取短信验证码
204+
*/
205+
private void getSMSCode(MethodCall call, final Result result) {
206+
207+
Object phoneNum = getValueByKey(call, "phoneNumber");
208+
Object signId = getValueByKey(call, "signId");
209+
Object tempId = getValueByKey(call, "tempId");
210+
211+
if (phoneNum == null) {
212+
phoneNum = "0";
213+
}
214+
215+
Log.d(TAG, "Action - getSmsCode:" + phoneNum);
216+
217+
JVerificationInterface.getSmsCode(context, (String) phoneNum, (String) signId, (String) tempId, new RequestCallback<String>() {
218+
@Override
219+
public void onResult(int code, String s) {
220+
221+
if (code == 3000) {//code: 返回码,3000代表获取成功,其他为失败
222+
Log.d(TAG, "uuid:" + s);
223+
} else {
224+
Log.e(TAG, "code=" + code + ", message=" + s);
225+
}
226+
227+
Map<String, Object> map = new HashMap<>();
228+
map.put(j_code_key, code);
229+
map.put(j_msg_key, s);
230+
231+
runMainThread(map, result, null);
232+
}
233+
});
234+
}
189235

190236
/**
191237
* SDK 判断网络环境是否支持
@@ -257,7 +303,7 @@ private void preLogin(final MethodCall call, final Result result) {
257303

258304
int timeOut = j_default_timeout;
259305
if (call.hasArgument("timeOut")) {
260-
timeOut = call.argument("timeOut");
306+
timeOut = call.argument("timeOut");
261307
}
262308

263309
JVerificationInterface.preLogin(context, timeOut, new PreLoginListener() {

example/lib/main.dart

Lines changed: 26 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -199,7 +199,32 @@ class _MyAppState extends State<MyApp> {
199199
}
200200
});
201201
}
202+
/// 获取短信验证码
203+
void getSMSCode(String phoneNum,{String signId,String tempId}){
204+
setState(() {
205+
_loading = true;
206+
});
202207

208+
jverify.checkVerifyEnable().then((map) {
209+
bool result = map[f_result_key];
210+
if (result) {
211+
jverify.getSMSCode(phoneNum,signId,tempId).then((map) {
212+
print("获取短信验证码:${map.toString()}");
213+
int code = map[f_code_key];
214+
String message = map[f_msg_key];
215+
setState(() {
216+
_loading = false;
217+
_result = "[$code] message = $message";
218+
});
219+
});
220+
}else {
221+
setState(() {
222+
_loading = false;
223+
_result = "[2016],msg = 当前网络环境不支持认证";
224+
});
225+
}
226+
});
227+
}
203228

204229
/// 登录预取号
205230
void preLogin(){
@@ -246,7 +271,7 @@ class _MyAppState extends State<MyApp> {
246271
/// 自定义授权的 UI 界面,以下设置的图片必须添加到资源文件里,
247272
/// android项目将图片存放至drawable文件夹下,可使用图片选择器的文件名,例如:btn_login.xml,入参为"btn_login"。
248273
/// ios项目存放在 Assets.xcassets。
249-
///
274+
///
250275
JVUIConfig uiConfig = JVUIConfig();
251276
//uiConfig.authBackgroundImage = ;
252277

example/pubspec.lock

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,7 @@ packages:
8787
path: ".."
8888
relative: true
8989
source: path
90-
version: "0.6.3"
90+
version: "0.6.4"
9191
matcher:
9292
dependency: transitive
9393
description:

lib/jverify.dart

Lines changed: 58 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -182,6 +182,37 @@ class Jverify {
182182
_channel.invokeMethod("setDebugMode", {"debug": debug});
183183
}
184184

185+
///设置前后两次获取验证码的时间间隔,默认 30000ms,有效范围(0,300000)
186+
void setSmsIntervalTime(int intervalTime) {
187+
print("$flutter_log" + "setSmsIntervalTime");
188+
_channel.invokeMethod("setSmsIntervalTime", {"intervalTime": intervalTime});
189+
}
190+
191+
/*
192+
* SDK 获取短信验证码
193+
*
194+
* return Map
195+
* key = "code", vlaue = 状态码,3000代表获取成功
196+
* key = "message", value = 成功即为验证码,失败为提示
197+
* */
198+
Future<Map<dynamic, dynamic>> getSMSCode(
199+
String phoneNum, String signId, String tempId) async {
200+
print("$flutter_log" + "getSMSCode");
201+
202+
var args = <String, String>{};
203+
args["phoneNumber"] = phoneNum;
204+
205+
if (signId != null) {
206+
args["signId"] = signId;
207+
}
208+
209+
if (tempId != null) {
210+
args["tempId"] = tempId;
211+
}
212+
213+
return await _channel.invokeMethod("getSMSCode", args);
214+
}
215+
185216
/*
186217
* 获取 SDK 初始化是否成功标识
187218
*
@@ -502,23 +533,23 @@ class JVUIConfig {
502533
String privacyNavTitleTitle2; // 协议2 web页面导航栏标题
503534
String privacyNavReturnBtnImage;
504535

536+
///only android
537+
bool privacyStatusBarColorWithNav = false; //web状态栏是否与导航栏同色
538+
bool privacyStatusBarDarkMode = false; //web状态栏是否暗色
539+
bool privacyStatusBarTransparent = false; //web页状态栏是否透明
540+
bool privacyStatusBarHidden = false; //web页状态栏是否隐藏
541+
bool privacyVirtualButtonTransparent = false; //web页虚拟按键背景是否透明
505542

506-
bool privacyStatusBarColorWithNav = false;//web状态栏是否与导航栏同色
507-
bool privacyStatusBarDarkMode = false;//web状态栏是否暗色
508-
bool privacyStatusBarTransparent = false;//web页状态栏是否透明
509-
bool privacyStatusBarHidden = false;//web页状态栏是否隐藏
510-
bool privacyVirtualButtonTransparent = false;//web页虚拟按键背景是否透明
543+
///导航栏only android
544+
bool statusBarColorWithNav = false; //状态栏是否跟导航栏同色
545+
bool statusBarDarkMode = false; //状态栏是否为暗色
546+
bool statusBarTransparent = false; //状态栏是否透明
547+
bool statusBarHidden = false; //状态栏是否隐藏
548+
bool virtualButtonTransparent = false; //虚拟按键背景是否透明
511549

512-
///导航栏
513-
bool statusBarColorWithNav =false;//状态栏是否跟导航栏同色
514-
bool statusBarDarkMode =false;//状态栏是否为暗色
515-
bool statusBarTransparent =false;//状态栏是否透明
516-
bool statusBarHidden =false;//状态栏是否隐藏
517-
bool virtualButtonTransparent =false;//虚拟按键背景是否透明
518-
519-
///是否需要动画
520-
bool needStartAnim =false;//设置拉起授权页时是否需要显示默认动画
521-
bool needCloseAnim =false;//设置关闭授权页时是否需要显示默认动画
550+
///是否需要动画only android
551+
bool needStartAnim = false; //设置拉起授权页时是否需要显示默认动画
552+
bool needCloseAnim = false; //设置关闭授权页时是否需要显示默认动画
522553

523554
/// 授权页弹窗模式 配置,选填
524555
JVPopViewConfig popViewConfig;
@@ -592,21 +623,20 @@ class JVUIConfig {
592623
"privacyNavReturnBtnImage": privacyNavReturnBtnImage ??= null,
593624
"popViewConfig": popViewConfig != null ? popViewConfig.toJsonMap() : null,
594625

595-
"privacyStatusBarColorWithNav":privacyStatusBarColorWithNav,
596-
"privacyStatusBarDarkMode":privacyStatusBarDarkMode,
597-
"privacyStatusBarTransparent":privacyStatusBarTransparent,
598-
"privacyStatusBarHidden":privacyStatusBarHidden,
599-
"privacyVirtualButtonTransparent":privacyVirtualButtonTransparent,
600-
601-
"statusBarColorWithNav":statusBarColorWithNav,
602-
"statusBarDarkMode":statusBarDarkMode,
603-
"statusBarTransparent":statusBarTransparent,
604-
"statusBarHidden":statusBarHidden,
605-
"virtualButtonTransparent":virtualButtonTransparent,
626+
"privacyStatusBarColorWithNav": privacyStatusBarColorWithNav,
627+
"privacyStatusBarDarkMode": privacyStatusBarDarkMode,
628+
"privacyStatusBarTransparent": privacyStatusBarTransparent,
629+
"privacyStatusBarHidden": privacyStatusBarHidden,
630+
"privacyVirtualButtonTransparent": privacyVirtualButtonTransparent,
606631

607-
"needStartAnim":needStartAnim,
608-
"needCloseAnim":needCloseAnim,
632+
"statusBarColorWithNav": statusBarColorWithNav,
633+
"statusBarDarkMode": statusBarDarkMode,
634+
"statusBarTransparent": statusBarTransparent,
635+
"statusBarHidden": statusBarHidden,
636+
"virtualButtonTransparent": virtualButtonTransparent,
609637

638+
"needStartAnim": needStartAnim,
639+
"needCloseAnim": needCloseAnim,
610640
}..removeWhere((key, value) => value == null);
611641
}
612642
}

0 commit comments

Comments
 (0)