Repository navigation
Expand file tree
/
Copy pathindex.js
More file actions
59 lines (46 loc) · 1.66 KB
/
Copy pathindex.js
File metadata and controls
59 lines (46 loc) · 1.66 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
59
import { NativeModules, NativeEventEmitter } from 'react-native';
const {RNUnity} = NativeModules;
let EventEmitter = new NativeEventEmitter(RNUnity);
class UnityAds {
// Load Unity Ads with your appId, testMode accepts a boolean
static loadAds = (appId, testMode) => {
RNUnity.loadAds(appId, testMode);
};
// Show the default placement
static showAd = () => {
RNUnity.showAd();
};
// Show a placement by it's placementId
static showAdWithId = (placementId) => {
RNUnity.showAdWithId(placementId);
};
// Check if a placement is ready using it's placementId, callback will return a boolean
static isReady = (placementId, callback) => {
RNUnity.isReady(placementId, callback);
};
// Ready listener, return object with 'placementId'
static addReadyListener = (callback) => {
EventEmitter.addListener('ready', callback);
};
// Start listener, returns object with 'placementId'
static addStartListener = (callback) => {
EventEmitter.addListener('didStart', callback);
};
/* Finish listener, returns:
placementId -> String,
finishState -> Number
Refer to the official SDK for more information about the finish state
*/
static addFinishListener = (callback) => {
EventEmitter.addListener('didFinish', callback);
};
/* Error listener, returns:
message -> String,
error -> Number
Refer to the official SDK for more information about error values
*/
static addErrorListener = (callback) => {
EventEmitter.addListener('error', callback);
};
}
module.exports.UnityAds = UnityAds;