-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathindex.js
85 lines (67 loc) · 2.16 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
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
'use strict';
import ReactNative from 'react-native';
import EventEmitter from 'events';
const {
Platform,
DeviceEventEmitter,
NativeEventEmitter,
NativeModules,
} = ReactNative;
const { RNFairbid } = NativeModules;
const g_eventEmitter = new EventEmitter();
if (Platform.OS === 'ios') {
const g_iosEventEmitter = new NativeEventEmitter(RNFairbid);
g_iosEventEmitter.addListener('RNFairbidEvent',e => {
g_eventEmitter.emit(e.name,e.body);
});
} else {
DeviceEventEmitter.addListener('RNFairbidEvent',e => {
g_eventEmitter.emit(e.name,e);
});
}
function once(event,callback) {
g_eventEmitter.once(event,callback);
}
function on(event,callback) {
g_eventEmitter.on(event,callback);
}
function removeListener(event,callback) {
g_eventEmitter.removeListener(event,callback);
}
const initWithAppID = RNFairbid.initWithAppID;
const presentTestSuite = RNFairbid.presentTestSuite;
function wrapArgMethod(method) {
return (arg, done) => {
if (!done) {
done = function() {};
}
method(arg, done);
}
}
const requestInterstitialForPlacementID = RNFairbid.requestInterstitialForPlacementID;
const isInterstitialAvailableForPlacementID = wrapArgMethod(RNFairbid.isInterstitialAvailableForPlacementID);
const showInterstitialForPlacementID = wrapArgMethod(RNFairbid.showInterstitialForPlacementID);
const requestVideoForPlacementID = RNFairbid.requestVideoForPlacementID;
const isVideoAvailableForPlacementID = wrapArgMethod(RNFairbid.isVideoAvailableForPlacementID);
const showVideoForPlacementID = wrapArgMethod(RNFairbid.showVideoForPlacementID);
const showBannerInView = wrapArgMethod(RNFairbid.showBannerInView);
const GDPRConsent = RNFairbid.GDPRConsent;
const GDPRConsentString = RNFairbid.GDPRConsentString;
const clearGDPRConsent = RNFairbid.clearGDPRConsent;
export default {
once,
on,
removeListener,
initWithAppID,
presentTestSuite,
requestInterstitialForPlacementID,
isInterstitialAvailableForPlacementID,
showInterstitialForPlacementID,
requestVideoForPlacementID,
isVideoAvailableForPlacementID,
showVideoForPlacementID,
showBannerInView,
GDPRConsent,
GDPRConsentString,
clearGDPRConsent
};