-
-
Notifications
You must be signed in to change notification settings - Fork 2
/
IABTFC.html
187 lines (117 loc) · 5.33 KB
/
IABTFC.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
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
<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="15" cols="40"></textarea>
<script>
let event = document.getElementById('event');
let cleanText = () => { event.value = '' };
// Load Rewarded Ad
let loadRewardedAd = () => {
cordova.plugins.emiAdmobPlugin.loadRewardedAd([adUnitId = "ca-app-pub-3940256099942544/5224354917", autoShow = true ]);
// call loadRewardedAd();
}
// Show Rewarded Ad
let showRewardedAd = () => {
cordova.plugins.emiAdmobPlugin.showRewardedAd();
// call showRewardedAd();
}
// >>>>>>>> User Messaging Platform (UMP) SDK 2.1.0
let getConsentRequest = () => {
// https://developers.google.com/admob/android/privacy
cordova.plugins.emiAdmobPlugin.getConsentRequest(
(ststus) => {
event.value += "\n Consent Status: " + ststus;
},
(error) => {
event.value += "\n Error: " + error
});
}
let consentReset = () => {
cordova.plugins.emiAdmobPlugin.consentReset();
}
// >>>>>>>> New features (UMP) SDK v2.1.0
let showPrivacyOptionsForm = () => {
cordova.plugins.emiAdmobPlugin.showPrivacyOptionsForm(
(info) => {
event.value += "\n Show Privacy Option Form: " + info;
},
(error) => {
event.value += "\n Error: " + error
});
}
/*
IAB Europe Transparency & Consent Framework
Final v.2.2 May 2023
*/
// >>>>>>>> New features (UMP) SDK v2.1.0
// https://developers.google.com/admob/android/privacy/gdpr
let getIabTfc = () => {
cordova.plugins.emiAdmobPlugin.getIabTfc(
/*
If the user chooses not to display ads,
you can restrict access to the app, or ban it,
until they change their decision back,
Just call showPrivacyOptionsForm();
*/
(info) => {
// How to read consent choices
event.value += "\n IABTCF_gdprApplies: " + info.IABTCF_gdprApplies;
event.value += "\n IABTCF_PurposeConsents: " + info.IABTCF_PurposeConsents; // In order for the ad to be displayed this must be filled in
event.value += "\n IABTCF_TCString: " + info.IABTCF_TCString; // In order for the ad to be displayed this must be filled in
/*
// A small example
var fundingChoices;
fundingChoices = info.IABTCF_PurposeConsents;
if (fundingChoices === "1111111111"){
// Enable app features.
loadRewardedAd();
} else if (fundingChoices === "") {
// disable app features.
} else {
// You have to test everything yourself.
}
*/
},
(error) => {
event.value += "\n Error: " + error
});
}
///// >>>>>> Device Ready <<<<<<
document.addEventListener("deviceready", function () {
const config_Targeting = [
childDirectedTreatment = 0, // value: 0 | -1 | 1
underAgeOfConsent = false, // default: false
contentRating = "G" // value: G | MA | PG | T | ""
]
cordova.plugins.emiAdmobPlugin.targeting(config_Targeting);
cordova.plugins.emiAdmobPlugin.initialize();
// Rewarded Ad EVENT
/*
on.rewarded.loaded
on.rewarded.failed.load
on.rewarded.click
on.rewarded.dismissed
on.rewarded.failed.show
on.rewarded.impression
on.rewarded.show
on.rewarded.revenue
on.rewarded.ad.skip
on.reward.userEarnedReward
*/
document.addEventListener('on.rewarded.loaded', () => {
event.value += ("\n on.rewarded.loaded");
});
}, false);
</script>
<p> <button onclick="getConsentRequest();">Get Consent Status</button></p>
<p> <button onclick="showPrivacyOptionsForm();">Show Privacy Options Form</button></p>
<p> <button onclick="getIabTfc();">Get IAB TFC Status</button></p>
<p> <button onclick="consentReset();">Consent Reset</button></p>
<p> <button onclick="loadRewardedAd();">Load Rewarded Ad</button></p>
<p> <button onclick="showRewardedAd();">Show Rewarded Ad</button></p>
<p> <button onclick="cleanText();">Clean response Text</button></p>
</body>
</html>