Skip to content

Commit 494e262

Browse files
authored
Merge pull request #22 from jpush/dev
修复认证android dismissLoginAuthActivity方法不在主线调用导致的崩溃
2 parents f5963d4 + 9177d4e commit 494e262

File tree

4 files changed

+35
-12
lines changed

4 files changed

+35
-12
lines changed

android/src/main/java/cn/jiguang/plugins/verification/JVerificationModule.java

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -130,7 +130,13 @@ public void onEvent(int code, String content) {
130130

131131
@ReactMethod
132132
public void dismissLoginAuthActivity(){
133-
JVerificationInterface.dismissLoginAuthActivity();
133+
reactContext.runOnUiQueueThread(new Runnable() {
134+
@Override
135+
public void run() {
136+
JVerificationInterface.dismissLoginAuthActivity();
137+
}
138+
});
139+
134140
}
135141

136142
@ReactMethod

example/App.js

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -245,11 +245,13 @@ export default class App extends React.Component {
245245
console.log('LoginListener:' + JSON.stringify(result));
246246
};
247247
JVerification.addLoginEventListener(this.LoginListener);
248+
if(Platform.OS == 'ios'){
248249
this.UnCheckboxEvent = result => {
249250
console.log('UnCheckboxEvent:未选中隐私协议框');
250251
this.createAlert('Listener:未选中隐私协议框' );
251252
}
252253
JVerification.addUncheckBoxEventListener(this.UnCheckboxEvent)
254+
}
253255
}
254256

255257
render() {
@@ -292,14 +294,14 @@ export default class App extends React.Component {
292294
if(Platform.OS == 'android'){
293295
JVerification.addLoginCustomConfig(customUIWithConfigAndroid, customViewParams);
294296
} else {
295-
JVerification.addLoginCustomConfig(customUIWithConfigiOS, []);
297+
JVerification.addLoginCustomConfig(customUIWithConfigiOS, customViewParams);
296298
}
297299
}}/>
298300

299301
<Button title='自定义弹窗授权页'
300302
onPress={() => {
301303
if(Platform.OS == 'android'){
302-
JVerification.addLoginCustomConfig(androidDialogConfig, undefined);
304+
JVerification.addLoginCustomConfig(androidDialogConfig, customViewParams);
303305
} else {
304306
JVerification.addLoginCustomConfig(iosDialogConfig, customViewParams);
305307
}

example/CustomView1.js

Lines changed: 24 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import React from 'react';
2-
import {StyleSheet, Text, View,Alert, TouchableHighlight} from 'react-native';
2+
import {StyleSheet, Text, View,Alert,Image, TouchableHighlight} from 'react-native';
3+
import JVerification from 'jverification-react-native';
34

45
export default class CustomView1 extends React.Component {
56
createAlert = (title) =>
@@ -14,14 +15,28 @@ export default class CustomView1 extends React.Component {
1415

1516

1617
render() {
17-
return (
18-
<View style={styles.container}>
19-
<Button title="this is CustomView1"
20-
onPress={() =>
21-
this.createAlert("CustomView1 onClicked")
22-
}/>
23-
</View>
24-
);
18+
19+
return (
20+
<View>
21+
<TouchableHighlight onPress={() =>{
22+
// this.createAlert("CustomView1 onClicked")
23+
JVerification.dismissLoginPage()
24+
}}>
25+
<Image
26+
source={{uri: "https://reactnative.dev/docs/assets/p_cat1.png"}}
27+
style={{width: 50, height: 50}}
28+
/>
29+
</TouchableHighlight>
30+
</View>
31+
);
32+
// return (
33+
// <View style={styles.container}>
34+
// <Button title="this is CustomView1"
35+
// onPress={() =>
36+
// this.createAlert("CustomView1 onClicked")
37+
// }/>
38+
// </View>
39+
// );
2540
}
2641
}
2742

example/img/my_icon.jpg

1.14 MB
Loading

0 commit comments

Comments
 (0)