forked from lijian0103/react-native-updater
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathindex.js
More file actions
58 lines (54 loc) · 1.67 KB
/
index.js
File metadata and controls
58 lines (54 loc) · 1.67 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
import {NativeModules, Platform, AlertIOS, Linking} from 'react-native';
const {RNUpdater, RNTools} = NativeModules;
const showUpdate =
(isUpdate = false, isForceUpdate = false, url, versionName, updateContent) => {
let title = `发现新版本,是否升级到${versionName}版本?`;
if (isForceUpdate) {
AlertIOS.alert(
title,
updateContent,
[
{
text: "升级",
onPress: () => Linking.openURL(url).catch(err => {
console.log(err);
})
}
]
);
return;
}
if (isUpdate) {
AlertIOS.alert(
title,
updateContent,
[
{
text: '取消',
style: "cancel"
},
{
text: "升级",
onPress: () => Linking.openURL(url).catch(err => {
console.log(err);
})
}
]
);
}
};
export const CheckUpdate = (options) => {
if (options && Platform.OS === 'ios') {
showUpdate(options.update, options.forced, options.updateUrl, options.versionName, options.updateContent);
} else {
RNUpdater.checkUpdate(options);
}
};
export const Tools = {
checkNotifyEnabled: () => {
return RNTools.checkNotifyEnabled();
},
openNotifySetting: () => {
RNTools.openNotifySetting();
},
};