forked from igalarzab/react-native-app-indexing
-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.js
54 lines (42 loc) · 1.08 KB
/
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
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
'use strict'
import url from 'url'
import {Linking, NativeModules, Platform} from 'react-native'
export default class AppIndexing {
static getInitialURL() {
return Linking.getInitialURL().then((urltext) => {
if (!urltext) {
return null;
}
let parser = url.parse(urltext, true, true)
return {
protocol: parser.protocol,
hostname: parser.hostname,
port: parser.port,
pathname: parser.pathname,
query: parser.query,
hash: parser.hash,
}
})
}
static instantViewAction(title, url) {
if (Platform.OS !== 'android') {
return null;
}
NativeModules.AppIndexing.instantViewAction(title, url);
}
static startViewAction(title, url) {
if (Platform.OS !== 'android') {
return null;
}
if (!title || !url) {
throw new Error('title and url are mandatory');
}
NativeModules.AppIndexing.startViewAction(title, url);
}
static stopViewAction() {
if (Platform.OS !== 'android') {
return null;
}
NativeModules.AppIndexing.stopViewAction();
}
}