Skip to content

Commit 0a02dcb

Browse files
authored
Merge pull request #42 from jpush/dev
v0.6.3修改文档
2 parents 03be6e8 + 844650e commit 0a02dcb

File tree

6 files changed

+196
-42
lines changed

6 files changed

+196
-42
lines changed

CHANGELOG.md

+2
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
## 0.6.3
2+
+ 修改文档
13
## 0.6.2
24
+ 同步 JVerification SDK 版本
35
+ 内部安全策略优化

README.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ dependencies:
1919

2020
```
2121
dependencies:
22-
jverify: 0.6.2
22+
jverify: 0.6.3
2323
```
2424

2525
### 配置

documents/APIs.md

+177-36
Original file line numberDiff line numberDiff line change
@@ -74,43 +74,184 @@ jverify.getToken().then((map){
7474
```dart
7575
///具体使用可以查看 example 样例
7676
77-
Jverify jverify = new Jverify();
77+
Jverify jverify = new Jverify();
78+
79+
final screenSize = MediaQuery.of(context).size;
80+
final screenWidth = screenSize.width;
81+
final screenHeight = screenSize.height;
82+
bool isiOS = Platform.isIOS;
83+
84+
/// 自定义授权的 UI 界面,以下设置的图片必须添加到资源文件里,
85+
/// android项目将图片存放至drawable文件夹下,可使用图片选择器的文件名,例如:btn_login.xml,入参为"btn_login"。
86+
/// ios项目存放在 Assets.xcassets。
87+
///
88+
JVUIConfig uiConfig = JVUIConfig();
89+
//uiConfig.authBackgroundImage = ;
90+
91+
//uiConfig.navHidden = true;
92+
uiConfig.navColor = Colors.red.value;
93+
uiConfig.navText = "登录";
94+
uiConfig.navTextColor = Colors.blue.value;
95+
uiConfig.navReturnImgPath = "return_bg";//图片必须存在
96+
97+
uiConfig.logoWidth = 100;
98+
uiConfig.logoHeight = 100;
99+
//uiConfig.logoOffsetX = isiOS ? 0 : null;//(screenWidth/2 - uiConfig.logoWidth/2).toInt();
100+
uiConfig.logoOffsetY = 10;
101+
uiConfig.logoVerticalLayoutItem = JVIOSLayoutItem.ItemSuper;
102+
uiConfig.logoHidden = false;
103+
uiConfig.logoImgPath = "logo";
104+
105+
uiConfig.numberFieldWidth = 200;
106+
uiConfig.numberFieldHeight = 40 ;
107+
//uiConfig.numFieldOffsetX = isiOS ? 0 : null;//(screenWidth/2 - uiConfig.numberFieldWidth/2).toInt();
108+
uiConfig.numFieldOffsetY = isiOS ? 20 : 120;
109+
uiConfig.numberVerticalLayoutItem = JVIOSLayoutItem.ItemLogo;
110+
uiConfig.numberColor = Colors.blue.value;
111+
uiConfig.numberSize = 18;
112+
113+
uiConfig.sloganOffsetY = isiOS ? 20 : 160;
114+
uiConfig.sloganVerticalLayoutItem = JVIOSLayoutItem.ItemNumber;
115+
uiConfig.sloganTextColor = Colors.black.value;
116+
uiConfig.sloganTextSize = 15;
117+
//uiConfig.sloganHidden = 0;
118+
119+
uiConfig.logBtnWidth = 220;
120+
uiConfig.logBtnHeight = 50;
121+
//uiConfig.logBtnOffsetX = isiOS ? 0 : null;//(screenWidth/2 - uiConfig.logBtnWidth/2).toInt();
122+
uiConfig.logBtnOffsetY = isiOS ? 20 : 230;
123+
uiConfig.logBtnVerticalLayoutItem = JVIOSLayoutItem.ItemSlogan;
124+
uiConfig.logBtnText = "登录按钮";
125+
uiConfig.logBtnTextColor = Colors.brown.value;
126+
uiConfig.logBtnTextSize = 16;
127+
uiConfig.loginBtnNormalImage = "login_btn_normal";//图片必须存在
128+
uiConfig.loginBtnPressedImage = "login_btn_press";//图片必须存在
129+
uiConfig.loginBtnUnableImage = "login_btn_unable";//图片必须存在
130+
131+
132+
uiConfig.privacyState = true;//设置默认勾选
133+
uiConfig.privacyCheckboxSize = 20;
134+
uiConfig.checkedImgPath = "check_image";//图片必须存在
135+
uiConfig.uncheckedImgPath = "uncheck_image";//图片必须存在
136+
uiConfig.privacyCheckboxInCenter = true;
137+
//uiConfig.privacyCheckboxHidden = false;
138+
139+
//uiConfig.privacyOffsetX = isiOS ? (20 + uiConfig.privacyCheckboxSize) : null;
140+
uiConfig.privacyOffsetY = 15;// 距离底部距离
141+
uiConfig.privacyVerticalLayoutItem = JVIOSLayoutItem.ItemSuper;
142+
uiConfig.clauseName = "协议1";
143+
uiConfig.clauseUrl = "http://www.baidu.com";
144+
uiConfig.clauseBaseColor = Colors.black.value;
145+
uiConfig.clauseNameTwo = "协议二";
146+
uiConfig.clauseUrlTwo = "http://www.hao123.com";
147+
uiConfig.clauseColor = Colors.red.value;
148+
uiConfig.privacyText = ["1极","2光","3认","4证"];
149+
uiConfig.privacyTextSize = 13;
150+
//uiConfig.privacyWithBookTitleMark = true;
151+
//uiConfig.privacyTextCenterGravity = false;
152+
153+
154+
uiConfig.privacyNavColor = Colors.red.value;;
155+
uiConfig.privacyNavTitleTextColor = Colors.blue.value;
156+
uiConfig.privacyNavTitleTextSize = 16;
157+
uiConfig.privacyNavTitleTitle1 = "协议1 web页标题";
158+
uiConfig.privacyNavTitleTitle2 = "协议2 web页标题";
159+
uiConfig.privacyNavReturnBtnImage = "return_bg";//图片必须存在;
160+
161+
/// 添加自定义的 控件 到授权界面
162+
List<JVCustomWidget>widgetList = [];
163+
164+
/*
165+
final String text_widgetId = "jv_add_custom_text";// 标识控件 id
166+
JVCustomWidget textWidget = JVCustomWidget(text_widgetId, JVCustomWidgetType.textView);
167+
textWidget.title = "新加 text view 控件";
168+
textWidget.left = 20;
169+
textWidget.top = 360 ;
170+
textWidget.width = 200;
171+
textWidget.height = 40;
172+
textWidget.backgroundColor = Colors.yellow.value;
173+
textWidget.isShowUnderline = true;
174+
textWidget.textAlignment = JVTextAlignmentType.center;
175+
textWidget.isClickEnable = true;
176+
177+
// 添加点击事件监听
178+
jverify.addClikWidgetEventListener(text_widgetId, (eventId) {
179+
print("receive listener - click widget event :$eventId");
180+
if (text_widgetId == eventId) {
181+
print("receive listener - 点击【新加 text】");
182+
}
183+
});
184+
widgetList.add(textWidget);
185+
186+
final String btn_widgetId = "jv_add_custom_button";// 标识控件 id
187+
JVCustomWidget buttonWidget = JVCustomWidget(btn_widgetId, JVCustomWidgetType.button);
188+
buttonWidget.title = "新加 button 控件";
189+
buttonWidget.left = 100;
190+
buttonWidget.top = 400;
191+
buttonWidget.width = 150;
192+
buttonWidget.height = 40;
193+
buttonWidget.isShowUnderline = true;
194+
buttonWidget.backgroundColor = Colors.brown.value;
195+
//buttonWidget.btnNormalImageName = "";
196+
//buttonWidget.btnPressedImageName = "";
197+
//buttonWidget.textAlignment = JVTextAlignmentType.left;
198+
199+
// 添加点击事件监听
200+
jverify.addClikWidgetEventListener(btn_widgetId, (eventId) {
201+
print("receive listener - click widget event :$eventId");
202+
if (btn_widgetId == eventId) {
203+
print("receive listener - 点击【新加 button】");
204+
}
205+
});
206+
widgetList.add(buttonWidget);
207+
*/
78208
79-
/// 步骤 1:调用接口设置 UI
80-
jverify.setCustomAuthorizationView(true, uiConfig, landscapeConfig: uiConfig);
81-
82-
/// 步骤 2:调用一键登录接口
83-
84-
/// 方式一:使用同步接口 (如果想使用异步接口,则忽略此步骤,看方式二)
85-
/// 先,添加 loginAuthSyncApi 接口回调的监听
86-
jverify.addLoginAuthCallBackListener((event){
87-
setState(() {
88-
_loading = false;
89-
_result = "监听获取返回数据:[${event.code}] message = ${event.message}";
90-
});
91-
print("通过添加监听,获取到 loginAuthSyncApi 接口返回数据,code=${event.code},message = ${event.message},operator = ${event.operator}");
92-
});
93-
/// 再,执行同步的一键登录接口
94-
jverify.loginAuthSyncApi(autoDismiss: true);
95-
96-
/*
97-
/// 方式二:使用异步接口 (如果想使用同步接口,则忽略此步骤,看方式一)
98-
99-
/// 先,执行异步的一键登录接口
100-
jverify.loginAuth(true).then((map) {
101-
102-
/// 再,在回调里获取 loginAuth 接口异步返回数据(如果是通过添加 JVLoginAuthCallBackListener 监听来获取返回数据,则忽略此步骤)
103-
int code = map[f_code_key];
104-
String content = map[f_msg_key];
105-
String operator = map[f_opr_key];
106-
setState(() {
107-
_loading = false;
108-
_result = "接口异步返回数据:[$code] message = $content";
109-
});
110-
print("通过接口异步返回,获取到 loginAuth 接口返回数据,code=$code,message = $content,operator = $operator");
111-
});
112-
*/
113-
209+
210+
/* 弹框模式
211+
JVPopViewConfig popViewConfig = JVPopViewConfig();
212+
popViewConfig.width = (screenWidth - 100.0).toInt();
213+
popViewConfig.height = (screenHeight - 150.0).toInt();
214+
215+
uiConfig.popViewConfig = popViewConfig;
216+
*/
217+
218+
219+
/// 步骤 1:调用接口设置 UI
220+
jverify.setCustomAuthorizationView(true, uiConfig, landscapeConfig: uiConfig);
221+
222+
/// 步骤 2:调用一键登录接口
223+
224+
/// 方式一:使用同步接口 (如果想使用异步接口,则忽略此步骤,看方式二)
225+
/// 先,添加 loginAuthSyncApi 接口回调的监听
226+
jverify.addLoginAuthCallBackListener((event){
227+
setState(() {
228+
_loading = false;
229+
_result = "监听获取返回数据:[${event.code}] message = ${event.message}";
230+
});
231+
print("通过添加监听,获取到 loginAuthSyncApi 接口返回数据,code=${event.code},message = ${event.message},operator = ${event.operator}");
232+
});
233+
/// 再,执行同步的一键登录接口
234+
jverify.loginAuthSyncApi(autoDismiss: true);
235+
236+
/*
237+
238+
/// 方式二:使用异步接口 (如果想使用异步接口,则忽略此步骤,看方式二)
239+
240+
/// 先,执行异步的一键登录接口
241+
jverify.loginAuth(true).then((map) {
242+
243+
/// 再,在回调里获取 loginAuth 接口异步返回数据(如果是通过添加 JVLoginAuthCallBackListener 监听来获取返回数据,则忽略此步骤)
244+
int code = map[f_code_key];
245+
String content = map[f_msg_key];
246+
String operator = map[f_opr_key];
247+
setState(() {
248+
_loading = false;
249+
_result = "接口异步返回数据:[$code] message = $content";
250+
});
251+
print("通过接口异步返回,获取到 loginAuth 接口返回数据,code=$code,message = $content,operator = $operator");
252+
});
253+
254+
*/
114255
```
115256

116257
#### setCustomAuthorizationView

example/pubspec.lock

+1-1
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.2"
90+
version: "0.6.3"
9191
matcher:
9292
dependency: transitive
9393
description:

ios/Classes/JverifyPlugin.m

+14-3
Original file line numberDiff line numberDiff line change
@@ -134,7 +134,10 @@ -(BOOL)isSetupClient:(FlutterResult)result {
134134
if (!isSetup) {
135135
JVLog(@"初始化未完成!");
136136
}
137-
result(@{j_result_key:[NSNumber numberWithBool:isSetup]});
137+
dispatch_async(dispatch_get_main_queue(), ^{
138+
result(@{j_result_key:[NSNumber numberWithBool:isSetup]});
139+
});
140+
138141
// 初始换成功
139142
//···
140143
return isSetup;
@@ -147,7 +150,10 @@ -(BOOL)checkVerifyEnable:(FlutterMethodCall*)call result:(FlutterResult)result{
147150
if(!isEnable) {
148151
JVLog(@"当前网络环境不支持认证!");
149152
}
150-
result(@{j_result_key:[NSNumber numberWithBool:isEnable]});
153+
dispatch_async(dispatch_get_main_queue(), ^{
154+
result(@{j_result_key:[NSNumber numberWithBool:isEnable]});
155+
});
156+
151157
//继续获取token操作
152158
//...
153159
return isEnable;
@@ -929,7 +935,12 @@ - (void)clickCustomWidgetAction:(UIButton *)button {
929935
NSString *tag = [NSString stringWithFormat:@"%@",@(button.tag)];
930936
if (tag) {
931937
NSString *widgetId = [self.customWidgetIdDic objectForKey:tag];
932-
[_channel invokeMethod:@"onReceiveClickWidgetEvent" arguments:@{@"widgetId":widgetId}];
938+
__weak typeof(self) weakself = self;
939+
dispatch_async(dispatch_get_main_queue(), ^{
940+
__strong typeof(weakself) strongself = weakself;
941+
[strongself.channel invokeMethod:@"onReceiveClickWidgetEvent" arguments:@{@"widgetId":widgetId}];
942+
});
943+
933944
}
934945
}
935946

pubspec.yaml

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
name: jverify
22
description: JIGUANG Official Jverifycation SDK flutter plugin project.
3-
version: 0.6.2
3+
version: 0.6.3
44
author: xudong.rao <[email protected]>
55
homepage: https://www.jiguang.cn
66

0 commit comments

Comments
 (0)