/
rewarded_interstitial_ads.html
167 lines (98 loc) · 3.82 KB
/
rewarded_interstitial_ads.html
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
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
<html>
<head>
<script type="text/javascript" src="cordova.js"></script>
</head>
<body>
<label for="event">Debug Event All response :</label>
<textarea id="event" name="event" rows="5" cols="40"></textarea>
<script>
let event = document.getElementById('event');
let cleanText = () => { event.value = '' };
// WARNING config must be an array[] not an object{}
const config_rewardedInt = [
adUnitId = "ca-app-pub-3940256099942544/5354046379",
autoShow = true
]
// how does the onclick button call a function inside the deviceready block? view https://github.com/EMI-INDO/emi-indo-cordova-plugin-admob/blob/main/example/banner_ads.html
// load Rewarded Interstitial Ad
let loadRewardedInterstitialAd = () => {
cordova.plugins.emiAdmobPlugin.loadRewardedInterstitialAd(config_rewardedInt);
// Or like this
// cordova.plugins.emiAdmobPlugin.loadRewardedInterstitialAd([adUnitId = "ca-app-pub-3940256099942544/5354046379", autoShow = false ]);
// call loadRewardedInterstitialAd();
}
// Show Rewarded Interstitial Ad
const showRewardedInterstitialAd = () => {
cordova.plugins.emiAdmobPlugin.showRewardedInterstitialAd();
// call showRewardedInterstitialAd();
}
///// >>>>>> Device Ready <<<<<<
document.addEventListener("deviceready", function(){
// WARNING config must be an array[] not an object{}
const config_globalSettings = [
// DEPRECATED enableSameAppKey
setAppMuted = false, // Type Boolean default: false
setAppVolume = 1.0, // Type float default: 1
publisherFirstPartyIdEnabled = true, // Type Boolean default: true // enableSameAppKey
npa = "1", // string "0" | "1" // DEPRECATED Beginning January 16, 2024
enableCollapsible = true, // (BETA) activate the collapsible banner ads
responseInfo = false, // For debugging and logging purposes
]
cordova.plugins.emiAdmobPlugin.globalSettings(config_globalSettings);
// Must be under globalSetting and targeting
cordova.plugins.emiAdmobPlugin.initialize();
// SDK EVENT Initialization
document.addEventListener('on.sdkInitialization', () => {
event.value += ("\n On Sdk Initialization");
});
// Rewarded Interstitial Ad EVENT
/*
on.rewardedInt.loaded
on.rewardedInt.failed.load
on.rewardedInt.click
on.rewardedInt.dismissed
on.rewardedInt.failed.show
on.rewardedInt.impression
on.rewardedInt.showed
on.rewardedInt.revenue
on.rewardedInt.ad.skip
on.rewardedInt.userEarnedReward
*/
document.addEventListener('on.rewardedInt.loaded', () => {
event.value += ("\n on.rewardedInt.loaded");
});
document.addEventListener('on.rewardedInt.failed.load', () => {
event.value += ("\n on.rewardedInt.failed.load");
});
document.addEventListener('on.rewardedInt.click', () => {
event.value += ("\n on.rewardedInt.click");
});
document.addEventListener('on.rewardedInt.dismissed', () => {
event.value += ("\n on.rewardedInt.dismissed");
});
document.addEventListener('on.rewardedInt.failed.show', () => {
event.value += ("\n on.rewardedInt.failed.show");
});
document.addEventListener('on.rewardedInt.impression', () => {
event.value += ("\n on.rewardedInt.impression");
});
document.addEventListener('on.rewardedInt.showed', () => {
event.value += ("\n on.rewardedInt.showed");
});
document.addEventListener('on.rewardedInt.revenue', () => {
event.value += ("\n on.rewardedInt.revenue");
});
document.addEventListener('on.rewardedInt.ad.skip', () => {
event.value += ("\n on.rewardedInt.ad.skip");
});
document.addEventListener('on.rewardedInt.userEarnedReward', () => {
// Give a gift to a user here
event.value += ("\n on.rewardedInt.userEarnedReward");
});
}, false);
</script>
<p> <button onclick="loadRewardedInterstitialAd();">Load Rewarded Interstitial</button></p>
<p> <button onclick="showRewardedInterstitialAd();">Show Rewarded Interstitial</button></p>
<p> <button onclick="cleanText();">Clean response Text</button></p>
</body>
</html>