-
Notifications
You must be signed in to change notification settings - Fork 1
/
index.js
55 lines (50 loc) · 1.56 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
55
import { NativeModules } from "react-native";
export function rate(packageName) {
return new Promise((resolve, reject) => {
logIOS(reject);
if (Platform.OS === "android") {
const {
RNCafebazaarIntent
} = NativeModules;
RNCafebazaarIntent.rate(packageName).then(() => resolve()).catch(e => reject(e));
}
});
}
export function view(packageName) {
return new Promise((resolve, reject) => {
logIOS(reject);
if (Platform.OS === "android") {
const {
RNCafebazaarIntent
} = NativeModules;
RNCafebazaarIntent.view(packageName).then(() => resolve()).catch(e => reject(e));
}
});
}
export function login() {
return new Promise((resolve, reject) => {
logIOS(reject);
if (Platform.OS === "android") {
const {
RNCafebazaarIntent
} = NativeModules;
RNCafebazaarIntent.login().then(() => resolve()).catch(e => reject(e));
}
});
}
export function developerCollection(developerId) {
return new Promise((resolve, reject) => {
logIOS(reject);
if (Platform.OS === "android") {
const {
RNCafebazaarIntent
} = NativeModules;
RNCafebazaarIntent.developerCollection(developerId).then(() => resolve()).catch(e => reject(e));
}
});
}
function logIOS(reject) {
if(Platform.OS === "ios") {
reject(new Error("You can't use `react-native-cafebazaar-intent` in ios"))
}
}