-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.js
32 lines (24 loc) · 789 Bytes
/
index.js
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
import { NativeModules, Linking, Platform } from 'react-native';
const { RNSimpleIntentLinking } = NativeModules;
const openURL = (url) => {
if (Platform.OS !== 'android' || url.indexOf('intent:') !== 0) {
return Linking.openURL(url);
}
if (RNSimpleIntentLinking) {
return RNSimpleIntentLinking.openURL(url);
}
return new Promise((resolve, reject) => reject('not found modules'));
};
const canOpenURL = (url) => {
if (Platform.OS !== 'android' || url.indexOf('intent:') !== 0) {
return Linking.openURL(url);
}
if (RNSimpleIntentLinking) {
return RNSimpleIntentLinking.canOpenURL(url);
}
return new Promise((resolve, reject) => reject('not found modules'));
};
export default {
openURL,
canOpenURL,
};