emi-indo-cordova-plugin-admob 1.4.8 → 1.5.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.github/ISSUE_TEMPLATE/bug_report.md +3 -0
- package/README.md +525 -82
- package/package.json +2 -1
- package/plugin.xml +302 -309
- package/src/android/emiAdmobPlugin.kt +1843 -0
- package/src/ios/emiAdmobPlugin.h +6 -2
- package/src/ios/emiAdmobPlugin.m +1646 -2560
- package/www/emiAdmobPlugin.js +42 -17
- package/example/Advanced topics/IABTFC.html +0 -187
- package/example/Advanced topics/consent.html +0 -156
- package/example/Advanced topics/globalSettings.html +0 -49
- package/example/Advanced topics/requestIDFA.html +0 -59
- package/example/Advanced topics/targeting.html +0 -64
- package/example/app_open_ads.html +0 -128
- package/example/banner_ads.html +0 -213
- package/example/interstitial_ads.html +0 -150
- package/example/rewarded_ads.html +0 -169
- package/example/rewarded_interstitial_ads.html +0 -167
- package/example/wewrtr.html +0 -0
- package/src/android/emiAdmobPlugin.java +0 -1
package/src/ios/emiAdmobPlugin.m
CHANGED
@@ -4,2641 +4,1727 @@
|
|
4
4
|
#import <Cordova/CDVPlugin.h>
|
5
5
|
#import <Foundation/Foundation.h>
|
6
6
|
#import <UserMessagingPlatform/UserMessagingPlatform.h>
|
7
|
-
@implementation
|
8
|
-
emiAdmobPlugin
|
7
|
+
@implementation emiAdmobPlugin
|
9
8
|
@synthesize appOpenAd;
|
10
|
-
@synthesize
|
11
|
-
|
12
|
-
@synthesize
|
13
|
-
|
14
|
-
@synthesize
|
15
|
-
rewardedInterstitialAd;
|
16
|
-
@synthesize
|
17
|
-
rewardedAd;
|
9
|
+
@synthesize bannerView;
|
10
|
+
@synthesize interstitial;
|
11
|
+
@synthesize rewardedInterstitialAd;
|
12
|
+
@synthesize rewardedAd;
|
18
13
|
@synthesize command;
|
19
|
-
@synthesize
|
20
|
-
|
21
|
-
@synthesize
|
22
|
-
isPrivacyOptionsRequired;
|
14
|
+
@synthesize responseInfo;
|
15
|
+
@synthesize isPrivacyOptionsRequired;
|
23
16
|
int idfaStatus = 0;
|
24
|
-
int fromStatus = 0;
|
25
|
-
int Consent_Status
|
26
|
-
= 0;
|
17
|
+
int fromStatus = 0; // Deprecated
|
18
|
+
int Consent_Status = 0;
|
27
19
|
int adFormat = 0;
|
28
|
-
int adWidth = 320;
|
20
|
+
int adWidth = 320; // Deprecated
|
29
21
|
BOOL auto_Show = NO;
|
30
|
-
NSString *Npa = @"1";
|
31
|
-
NSString *Position
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
BOOL
|
36
|
-
|
22
|
+
// NSString *Npa = @"1"; // Deprecated
|
23
|
+
NSString *Position = @"bottom";
|
24
|
+
NSString *bannerSaveAdUnitId = @""; // autoResize dependency = true
|
25
|
+
|
26
|
+
BOOL enableCollapsible = NO;
|
27
|
+
BOOL isAutoResize = NO;
|
28
|
+
|
37
29
|
int isAdSkip = 0;
|
38
30
|
BOOL isIAB = NO;
|
39
|
-
BOOL UnderAgeOfConsent
|
40
|
-
|
41
|
-
BOOL
|
42
|
-
|
43
|
-
BOOL
|
44
|
-
= NO;
|
45
|
-
- (void)initialize:
|
46
|
-
(CDVInvokedUrlCommand
|
47
|
-
*)command
|
48
|
-
{
|
31
|
+
BOOL UnderAgeOfConsent = NO;
|
32
|
+
BOOL isPrivacyOptions = NO;
|
33
|
+
BOOL isDebugGeography = NO;
|
34
|
+
BOOL ResponseInfo = NO;
|
35
|
+
BOOL isUsingAdManagerRequest = YES;
|
49
36
|
|
50
|
-
|
51
|
-
|
52
|
-
sharedInstance];
|
53
|
-
[ads startWithCompletionHandler:^(
|
54
|
-
GADInitializationStatus
|
55
|
-
*status) {
|
56
|
-
NSDictionary *
|
57
|
-
adapterStatuses
|
58
|
-
= [status
|
59
|
-
adapterStatusesByClassName];
|
60
|
-
for (
|
61
|
-
NSString *adapter in
|
62
|
-
adapterStatuses)
|
63
|
-
{
|
64
|
-
GADAdapterStatus
|
65
|
-
*adapterStatus
|
66
|
-
= adapterStatuses
|
67
|
-
[adapter];
|
68
|
-
NSLog (
|
69
|
-
@"Adapter "
|
70
|
-
@"Name: %@, "
|
71
|
-
@"Descriptio"
|
72
|
-
@"n: %@, "
|
73
|
-
@"Latency: "
|
74
|
-
@"%f",
|
75
|
-
adapter,
|
76
|
-
adapterStatus
|
77
|
-
.description,
|
78
|
-
adapterStatus
|
79
|
-
.latency);
|
80
|
-
}
|
81
|
-
[self
|
82
|
-
fireEvent:@""
|
83
|
-
event:
|
84
|
-
@"on."
|
85
|
-
@"sdkI"
|
86
|
-
@"niti"
|
87
|
-
@"aliz"
|
88
|
-
@"atio"
|
89
|
-
@"n"
|
90
|
-
withData:nil];
|
91
|
-
}];
|
37
|
+
- (BOOL)canRequestAds {
|
38
|
+
return UMPConsentInformation.sharedInstance.canRequestAds;
|
92
39
|
}
|
93
|
-
- (void)
|
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
|
-
|
40
|
+
- (void)setUsingAdManagerRequest:(BOOL)value {
|
41
|
+
isUsingAdManagerRequest = value;
|
42
|
+
}
|
43
|
+
- (void)ResponseInfo:(BOOL)value {
|
44
|
+
ResponseInfo = value;
|
45
|
+
}
|
46
|
+
- (void)isDebugGeography:(BOOL)value {
|
47
|
+
isDebugGeography = value;
|
48
|
+
}
|
49
|
+
|
50
|
+
- (void)initialize:(CDVInvokedUrlCommand *)command {
|
51
|
+
|
52
|
+
NSDictionary *options = [command.arguments objectAtIndex:0];
|
53
|
+
|
54
|
+
BOOL setAdRequest = [[options valueForKey:@"isUsingAdManagerRequest"] boolValue];
|
55
|
+
BOOL responseInfo = [[options valueForKey:@"isResponseInfo"] boolValue];
|
56
|
+
BOOL setDebugGeography = [[options valueForKey:@"isConsentDebug"] boolValue];
|
57
|
+
|
58
|
+
[self setUsingAdManagerRequest:setAdRequest];
|
59
|
+
[self ResponseInfo:responseInfo];
|
60
|
+
[self isDebugGeography:setDebugGeography];
|
61
|
+
|
62
|
+
__block CDVPluginResult *pluginResult;
|
63
|
+
NSString *callbackId = command.callbackId;
|
64
|
+
NSString *deviceId = [self __getAdMobDeviceId];
|
65
|
+
UMPRequestParameters *parameters = [[UMPRequestParameters alloc] init];
|
66
|
+
|
67
|
+
if (isDebugGeography) {
|
68
|
+
UMPDebugSettings *debugSettings = [[UMPDebugSettings alloc] init];
|
69
|
+
parameters.debugSettings = debugSettings;
|
70
|
+
debugSettings.geography = UMPDebugGeographyEEA;
|
71
|
+
debugSettings.testDeviceIdentifiers = @[ deviceId ];
|
72
|
+
}
|
73
|
+
|
74
|
+
parameters.tagForUnderAgeOfConsent = UnderAgeOfConsent;
|
75
|
+
|
76
|
+
dispatch_async(dispatch_get_main_queue(), ^{
|
77
|
+
// Request consent info update
|
78
|
+
[UMPConsentInformation.sharedInstance
|
79
|
+
requestConsentInfoUpdateWithParameters:parameters
|
80
|
+
completionHandler:^(NSError *_Nullable requestConsentError) {
|
81
|
+
if (requestConsentError) {
|
82
|
+
// NSLog(@"Request consent error: %@", requestConsentError.localizedDescription);
|
83
|
+
pluginResult = [CDVPluginResult resultWithStatus:CDVCommandStatus_ERROR messageAsString:requestConsentError.description];
|
84
|
+
[self.commandDelegate sendPluginResult:pluginResult callbackId:callbackId];
|
85
|
+
return;
|
129
86
|
}
|
130
|
-
|
131
|
-
|
132
|
-
|
133
|
-
|
134
|
-
|
135
|
-
|
87
|
+
|
88
|
+
// Check the consent status after update
|
89
|
+
UMPConsentStatus status = UMPConsentInformation.sharedInstance.consentStatus;
|
90
|
+
// NSLog(@"Consent status: %ld", (long)status);
|
91
|
+
|
92
|
+
// Handle consent status
|
93
|
+
if (status == UMPConsentStatusRequired) {
|
94
|
+
// If consent is required, load and display consent form
|
95
|
+
[UMPConsentForm loadWithCompletionHandler:^(UMPConsentForm *form, NSError *loadError) {
|
96
|
+
if (loadError) {
|
97
|
+
// NSLog(@"Load consent form error: %@", loadError.localizedDescription);
|
98
|
+
pluginResult = [CDVPluginResult resultWithStatus:CDVCommandStatus_ERROR messageAsString:loadError.description];
|
99
|
+
[self.commandDelegate sendPluginResult:pluginResult callbackId:callbackId];
|
100
|
+
} else {
|
101
|
+
// Present the consent form to the user
|
102
|
+
[form presentFromViewController:[UIApplication sharedApplication].delegate.window.rootViewController
|
103
|
+
completionHandler:^(NSError *_Nullable dismissError) {
|
104
|
+
if (dismissError) {
|
105
|
+
// NSLog(@"Dismiss consent form error: %@", dismissError.localizedDescription);
|
106
|
+
pluginResult = [CDVPluginResult resultWithStatus:CDVCommandStatus_ERROR messageAsString:dismissError.description];
|
107
|
+
} else {
|
108
|
+
// NSLog(@"Consent form successfully presented.");
|
109
|
+
pluginResult = [CDVPluginResult resultWithStatus:CDVCommandStatus_OK messageAsString:@"Consent form displayed successfully."];
|
110
|
+
}
|
111
|
+
[self.commandDelegate sendPluginResult:pluginResult callbackId:callbackId];
|
112
|
+
}];
|
113
|
+
}
|
114
|
+
|
115
|
+
|
116
|
+
if (UMPConsentInformation.sharedInstance.canRequestAds) {
|
117
|
+
[self startGoogleMobileAdsSDK];
|
118
|
+
}
|
119
|
+
|
120
|
+
|
121
|
+
}];
|
122
|
+
} else if (status == UMPConsentStatusNotRequired || status == UMPConsentStatusObtained) {
|
123
|
+
// If consent is not required or already obtained, start the ads SDK
|
124
|
+
if (UMPConsentInformation.sharedInstance.canRequestAds) {
|
125
|
+
[self startGoogleMobileAdsSDK];
|
126
|
+
pluginResult = [CDVPluginResult resultWithStatus:CDVCommandStatus_OK messageAsString:@"Ads SDK started."];
|
127
|
+
} else {
|
128
|
+
pluginResult = [CDVPluginResult resultWithStatus:CDVCommandStatus_ERROR messageAsString:@"Cannot request ads, consent is required."];
|
129
|
+
}
|
130
|
+
[self.commandDelegate sendPluginResult:pluginResult callbackId:callbackId];
|
131
|
+
} else {
|
132
|
+
// NSLog(@"Consent status unknown or error.");
|
133
|
+
pluginResult = [CDVPluginResult resultWithStatus:CDVCommandStatus_ERROR messageAsString:@"Consent status unknown."];
|
134
|
+
[self.commandDelegate sendPluginResult:pluginResult callbackId:callbackId];
|
136
135
|
}
|
137
|
-
|
138
|
-
|
139
|
-
[self
|
140
|
-
fireEvent:@""
|
141
|
-
event:
|
142
|
-
@"on."
|
143
|
-
@"getI"
|
144
|
-
@"DFA."
|
145
|
-
@"stat"
|
146
|
-
@"us"
|
147
|
-
withData:nil];
|
148
|
-
pluginResult = [CDVPluginResult
|
149
|
-
resultWithStatus:
|
150
|
-
CDVCommandStatus_OK
|
151
|
-
messageAsInt:
|
152
|
-
idfaStatus];
|
153
|
-
}
|
154
|
-
else
|
155
|
-
{
|
156
|
-
[self
|
157
|
-
fireEvent:@""
|
158
|
-
event:
|
159
|
-
@"on."
|
160
|
-
@"getI"
|
161
|
-
@"DFA."
|
162
|
-
@"erro"
|
163
|
-
@"r"
|
164
|
-
withData:nil];
|
165
|
-
pluginResult = [CDVPluginResult
|
166
|
-
resultWithStatus:
|
167
|
-
CDVCommandStatus_ERROR];
|
168
|
-
}
|
169
|
-
[self.commandDelegate
|
170
|
-
sendPluginResult:
|
171
|
-
pluginResult
|
172
|
-
callbackId:
|
173
|
-
callbackId];
|
136
|
+
}];
|
137
|
+
});
|
174
138
|
}
|
175
139
|
|
176
|
-
|
177
|
-
|
178
|
-
|
179
|
-
|
180
|
-
|
181
|
-
|
182
|
-
|
183
|
-
|
184
|
-
|
185
|
-
|
186
|
-
|
187
|
-
|
188
|
-
|
189
|
-
|
190
|
-
|
191
|
-
|
192
|
-
|
193
|
-
|
194
|
-
if (
|
195
|
-
|
196
|
-
|
197
|
-
|
198
|
-
*debugSettings
|
199
|
-
= [[UMPDebugSettings
|
200
|
-
alloc]
|
201
|
-
init];
|
202
|
-
parameters
|
203
|
-
.debugSettings
|
204
|
-
= debugSettings;
|
205
|
-
debugSettings
|
206
|
-
.geography
|
207
|
-
= UMPDebugGeographyEEA;
|
208
|
-
debugSettings
|
209
|
-
.testDeviceIdentifiers
|
210
|
-
= @[
|
211
|
-
deviceId
|
212
|
-
];
|
213
|
-
}
|
214
|
-
parameters
|
215
|
-
.tagForUnderAgeOfConsent
|
216
|
-
= UnderAgeOfConsent;
|
217
|
-
// NSLog(@"tag For
|
218
|
-
// Under Age Of
|
219
|
-
// Consent %s",
|
220
|
-
// UnderAgeOfConsent
|
221
|
-
// ? "true" :
|
222
|
-
// "false");
|
223
|
-
dispatch_async (dispatch_get_main_queue (),
|
224
|
-
^{
|
225
|
-
[UMPConsentInformation
|
226
|
-
.sharedInstance
|
227
|
-
requestConsentInfoUpdateWithParameters:
|
228
|
-
parameters
|
229
|
-
completionHandler:^(
|
230
|
-
NSError
|
231
|
-
*_Nullable requestConsentError) {
|
232
|
-
if (requestConsentError)
|
233
|
-
{
|
234
|
-
NSLog (
|
235
|
-
@"request Consent Error: %@",
|
236
|
-
requestConsentError
|
237
|
-
.localizedDescription);
|
238
|
-
|
239
|
-
pluginResult = [CDVPluginResult
|
240
|
-
resultWithStatus:
|
241
|
-
CDVCommandStatus_ERROR
|
242
|
-
messageAsString:
|
243
|
-
requestConsentError
|
244
|
-
.description];
|
245
|
-
|
246
|
-
return;
|
247
|
-
}
|
248
|
-
[self
|
249
|
-
readStatus:
|
250
|
-
command];
|
251
|
-
[UMPConsentForm loadWithCompletionHandler:^(
|
252
|
-
UMPConsentForm
|
253
|
-
*form,
|
254
|
-
NSError
|
255
|
-
*loadError) {
|
256
|
-
if (loadError)
|
257
|
-
{
|
258
|
-
pluginResult = [CDVPluginResult
|
259
|
-
resultWithStatus:
|
260
|
-
CDVCommandStatus_ERROR
|
261
|
-
messageAsString:
|
262
|
-
loadError
|
263
|
-
.description];
|
264
|
-
NSLog (
|
265
|
-
@"load Error: %@",
|
266
|
-
loadError
|
267
|
-
.localizedDescription);
|
268
|
-
}
|
269
|
-
else
|
270
|
-
{
|
271
|
-
[form
|
272
|
-
presentFromViewController:
|
273
|
-
[UIApplication
|
274
|
-
sharedApplication]
|
275
|
-
.delegate
|
276
|
-
.window
|
277
|
-
.rootViewController
|
278
|
-
completionHandler:
|
279
|
-
^(NSError
|
280
|
-
*_Nullable dismissError) {
|
281
|
-
if (dismissError)
|
282
|
-
{
|
283
|
-
NSLog (
|
284
|
-
@"dismiss Error: %@",
|
285
|
-
dismissError
|
286
|
-
.localizedDescription);
|
287
|
-
pluginResult = [CDVPluginResult
|
288
|
-
resultWithStatus:
|
289
|
-
CDVCommandStatus_ERROR
|
290
|
-
messageAsString:
|
291
|
-
dismissError
|
292
|
-
.description];
|
293
|
-
}
|
294
|
-
else
|
295
|
-
{
|
296
|
-
NSLog (
|
297
|
-
@"UMP ConsentInformation: %@",
|
298
|
-
UMPConsentInformation
|
299
|
-
.description);
|
300
|
-
pluginResult = [CDVPluginResult
|
301
|
-
resultWithStatus:
|
302
|
-
CDVCommandStatus_ERROR
|
303
|
-
messageAsString:
|
304
|
-
UMPConsentInformation
|
305
|
-
.description];
|
140
|
+
|
141
|
+
|
142
|
+
- (void)requestIDFA:(CDVInvokedUrlCommand *)command {
|
143
|
+
CDVPluginResult *pluginResult;
|
144
|
+
NSString *callbackId = command.callbackId;
|
145
|
+
if (@available(iOS 14, *)) {
|
146
|
+
dispatch_async(dispatch_get_main_queue(), ^{
|
147
|
+
[ATTrackingManager
|
148
|
+
requestTrackingAuthorizationWithCompletionHandler:^(
|
149
|
+
ATTrackingManagerAuthorizationStatus status) {
|
150
|
+
if (status == ATTrackingManagerAuthorizationStatusDenied) {
|
151
|
+
idfaStatus = ATTrackingManagerAuthorizationStatusDenied;
|
152
|
+
} else if (status ==
|
153
|
+
ATTrackingManagerAuthorizationStatusAuthorized) {
|
154
|
+
idfaStatus = ATTrackingManagerAuthorizationStatusAuthorized;
|
155
|
+
} else if (status ==
|
156
|
+
ATTrackingManagerAuthorizationStatusRestricted) {
|
157
|
+
idfaStatus = ATTrackingManagerAuthorizationStatusRestricted;
|
158
|
+
} else if (status ==
|
159
|
+
ATTrackingManagerAuthorizationStatusNotDetermined) {
|
160
|
+
idfaStatus =
|
161
|
+
ATTrackingManagerAuthorizationStatusNotDetermined;
|
306
162
|
}
|
307
|
-
|
308
|
-
|
309
|
-
|
310
|
-
|
311
|
-
|
312
|
-
|
313
|
-
|
314
|
-
|
315
|
-
|
316
|
-
|
317
|
-
|
318
|
-
|
319
|
-
|
320
|
-
|
321
|
-
|
322
|
-
|
323
|
-
|
324
|
-
|
325
|
-
|
163
|
+
}];
|
164
|
+
});
|
165
|
+
[self fireEvent:@""
|
166
|
+
event:@"on."
|
167
|
+
@"getI"
|
168
|
+
@"DFA."
|
169
|
+
@"stat"
|
170
|
+
@"us"
|
171
|
+
withData:nil];
|
172
|
+
pluginResult = [CDVPluginResult resultWithStatus:CDVCommandStatus_OK
|
173
|
+
messageAsInt:idfaStatus];
|
174
|
+
} else {
|
175
|
+
[self fireEvent:@""
|
176
|
+
event:@"on."
|
177
|
+
@"getI"
|
178
|
+
@"DFA."
|
179
|
+
@"erro"
|
180
|
+
@"r"
|
181
|
+
withData:nil];
|
182
|
+
pluginResult =
|
183
|
+
[CDVPluginResult resultWithStatus:CDVCommandStatus_ERROR];
|
184
|
+
}
|
185
|
+
[self.commandDelegate sendPluginResult:pluginResult callbackId:callbackId];
|
326
186
|
}
|
327
187
|
|
328
|
-
- (void)
|
329
|
-
|
330
|
-
(CDVInvokedUrlCommand
|
331
|
-
*)command
|
332
|
-
{
|
333
|
-
NSString *deviceId = [self
|
334
|
-
__getAdMobDeviceId];
|
335
|
-
UMPRequestParameters
|
336
|
-
*parameters
|
337
|
-
= [[UMPRequestParameters
|
338
|
-
alloc] init];
|
339
|
-
if (isDebugGeography
|
340
|
-
== YES)
|
341
|
-
{
|
342
|
-
UMPDebugSettings
|
343
|
-
*debugSettings
|
344
|
-
= [[UMPDebugSettings
|
345
|
-
alloc]
|
346
|
-
init];
|
347
|
-
parameters
|
348
|
-
.debugSettings
|
349
|
-
= debugSettings;
|
350
|
-
debugSettings
|
351
|
-
.geography
|
352
|
-
= UMPDebugGeographyEEA;
|
353
|
-
debugSettings
|
354
|
-
.testDeviceIdentifiers
|
355
|
-
= @[
|
356
|
-
deviceId
|
357
|
-
];
|
358
|
-
}
|
359
|
-
parameters
|
360
|
-
.tagForUnderAgeOfConsent
|
361
|
-
= UnderAgeOfConsent;
|
362
|
-
dispatch_async (dispatch_get_main_queue (),
|
363
|
-
^{
|
364
|
-
[UMPConsentInformation
|
365
|
-
.sharedInstance
|
366
|
-
requestConsentInfoUpdateWithParameters:
|
367
|
-
parameters
|
368
|
-
completionHandler:
|
369
|
-
^(NSError
|
370
|
-
*_Nullable requestConsentError) {
|
371
|
-
[UMPConsentForm
|
372
|
-
loadAndPresentIfRequiredFromViewController:
|
373
|
-
self.viewController
|
374
|
-
completionHandler:^(
|
375
|
-
NSError
|
376
|
-
*loadAndPresentError) {
|
377
|
-
CDVPluginResult
|
378
|
-
*pluginResult
|
379
|
-
= [CDVPluginResult
|
380
|
-
resultWithStatus:
|
381
|
-
CDVCommandStatus_ERROR
|
382
|
-
messageAsString:
|
383
|
-
loadAndPresentError
|
384
|
-
.description];
|
385
|
-
[self.commandDelegate
|
386
|
-
sendPluginResult:
|
387
|
-
pluginResult
|
388
|
-
callbackId:
|
389
|
-
command
|
390
|
-
.callbackId];
|
391
|
-
}];
|
392
|
-
|
393
|
-
[self
|
394
|
-
isPrivacyOptionsRequired];
|
395
|
-
isPrivacyOptions
|
396
|
-
= YES;
|
397
|
-
[self
|
398
|
-
privacyOptionsFormShow:
|
399
|
-
command];
|
400
|
-
}];
|
401
|
-
});
|
188
|
+
- (void)getConsentRequest:(CDVInvokedUrlCommand *)command {
|
189
|
+
|
402
190
|
}
|
403
191
|
|
404
|
-
- (void)
|
405
|
-
privacyOptionsFormShow:
|
406
|
-
(CDVInvokedUrlCommand
|
407
|
-
*)command
|
408
|
-
{
|
409
192
|
|
410
|
-
|
411
|
-
|
412
|
-
|
413
|
-
|
414
|
-
|
415
|
-
|
416
|
-
|
417
|
-
|
418
|
-
|
419
|
-
|
420
|
-
|
421
|
-
|
422
|
-
|
423
|
-
|
424
|
-
|
425
|
-
|
426
|
-
|
427
|
-
|
428
|
-
|
429
|
-
|
430
|
-
|
431
|
-
|
432
|
-
|
433
|
-
|
434
|
-
|
435
|
-
|
436
|
-
|
437
|
-
|
438
|
-
|
439
|
-
|
440
|
-
|
441
|
-
|
442
|
-
|
443
|
-
|
193
|
+
|
194
|
+
|
195
|
+
|
196
|
+
|
197
|
+
|
198
|
+
|
199
|
+
- (void)startGoogleMobileAdsSDK {
|
200
|
+
static dispatch_once_t onceToken;
|
201
|
+
dispatch_once(&onceToken, ^{
|
202
|
+
// Initialize the Google Mobile Ads SDK.
|
203
|
+
GADMobileAds *ads = [GADMobileAds sharedInstance];
|
204
|
+
[ads startWithCompletionHandler:^(GADInitializationStatus *status) {
|
205
|
+
|
206
|
+
NSDictionary *adapterStatuses = [status adapterStatusesByClassName];
|
207
|
+
NSMutableArray *adaptersArray = [NSMutableArray array];
|
208
|
+
|
209
|
+
for (NSString *adapter in adapterStatuses) {
|
210
|
+
GADAdapterStatus *adapterStatus = adapterStatuses[adapter];
|
211
|
+
NSLog(@"Adapter Name: %@, Description: %@, Latency: %f", adapter, adapterStatus.description, adapterStatus.latency);
|
212
|
+
|
213
|
+
NSDictionary *adapterInfo = @{
|
214
|
+
@"name": adapter
|
215
|
+
};
|
216
|
+
|
217
|
+
[adaptersArray addObject:adapterInfo];
|
218
|
+
}
|
219
|
+
|
220
|
+
NSString *sdkVersion = GADGetStringFromVersionNumber(GADMobileAds.sharedInstance.versionNumber);
|
221
|
+
int Consent_Status = (int)UMPConsentInformation.sharedInstance.consentStatus;
|
222
|
+
|
223
|
+
NSMutableDictionary *result = [[NSMutableDictionary alloc] init];
|
224
|
+
NSUserDefaults *prefs = [NSUserDefaults standardUserDefaults];
|
225
|
+
NSNumber *CmpSdkID = [prefs valueForKey:@"IABTCF_CmpSdkID"];
|
226
|
+
NSString *gdprApplies = [prefs stringForKey:@"IABTCF_gdprApplies"];
|
227
|
+
NSString *PurposeConsents = [prefs stringForKey:@"IABTCF_PurposeConsents"];
|
228
|
+
NSString *TCString = [prefs stringForKey:@"IABTCF_TCString"];
|
229
|
+
NSString *additionalConsent = [prefs stringForKey:@"IABTCF_AddtlConsent"];
|
230
|
+
|
231
|
+
result[@"version"] = sdkVersion;
|
232
|
+
result[@"consentStatus"] = @(Consent_Status);
|
233
|
+
result[@"adapter"] = adaptersArray;
|
234
|
+
result[@"CmpSdkID"] = CmpSdkID;
|
235
|
+
result[@"gdprApplies"] = gdprApplies;
|
236
|
+
result[@"PurposeConsents"] = PurposeConsents;
|
237
|
+
result[@"TCString"] = TCString;
|
238
|
+
result[@"additionalConsent"] = additionalConsent;
|
239
|
+
|
240
|
+
// NSLog(@"Result dictionary: %@", result);consentStatus
|
241
|
+
|
242
|
+
NSError *error;
|
243
|
+
NSData *jsonData = [NSJSONSerialization dataWithJSONObject:result options:0 error:&error];
|
244
|
+
|
245
|
+
if (!jsonData) {
|
246
|
+
NSLog(@"Error converting result to JSON: %@", error.localizedDescription);
|
247
|
+
} else {
|
248
|
+
NSString *jsonString = [[NSString alloc] initWithData:jsonData encoding:NSUTF8StringEncoding];
|
249
|
+
|
250
|
+
// NSLog(@"JSON String: %@", jsonString);
|
251
|
+
|
252
|
+
[self fireEvent:@"" event:@"on.sdkInitialization" withData:jsonString];
|
253
|
+
}
|
254
|
+
|
255
|
+
[prefs synchronize];
|
256
|
+
}];
|
257
|
+
});
|
444
258
|
}
|
445
259
|
|
446
|
-
- (void)readStatus:
|
447
|
-
(CDVInvokedUrlCommand
|
448
|
-
*)command
|
449
|
-
{
|
450
|
-
[self.commandDelegate runInBackground:^{
|
451
|
-
Consent_Status
|
452
|
-
= (int)UMPConsentInformation
|
453
|
-
.sharedInstance
|
454
|
-
.consentStatus;
|
455
|
-
|
456
|
-
if (Consent_Status
|
457
|
-
== UMPConsentStatusUnknown)
|
458
|
-
{
|
459
260
|
|
460
|
-
Consent_Status
|
461
|
-
= UMPConsentStatusUnknown;
|
462
|
-
}
|
463
|
-
else if (
|
464
|
-
Consent_Status
|
465
|
-
== UMPConsentStatusRequired)
|
466
|
-
{
|
467
261
|
|
468
|
-
Consent_Status
|
469
|
-
= UMPConsentStatusRequired;
|
470
|
-
}
|
471
|
-
else if (
|
472
|
-
Consent_Status
|
473
|
-
== UMPConsentStatusNotRequired)
|
474
|
-
{
|
475
262
|
|
476
|
-
|
477
|
-
|
263
|
+
|
264
|
+
|
265
|
+
- (void)forceDisplayPrivacyForm:(CDVInvokedUrlCommand *)command {
|
266
|
+
NSString *deviceId = [self __getAdMobDeviceId];
|
267
|
+
UMPRequestParameters *parameters = [[UMPRequestParameters alloc] init];
|
268
|
+
|
269
|
+
if (isDebugGeography) {
|
270
|
+
UMPDebugSettings *debugSettings = [[UMPDebugSettings alloc] init];
|
271
|
+
debugSettings.geography = UMPDebugGeographyEEA;
|
272
|
+
debugSettings.testDeviceIdentifiers = @[ deviceId ];
|
273
|
+
parameters.debugSettings = debugSettings;
|
478
274
|
}
|
479
|
-
|
480
|
-
|
481
|
-
|
482
|
-
|
275
|
+
|
276
|
+
parameters.tagForUnderAgeOfConsent = UnderAgeOfConsent;
|
277
|
+
|
278
|
+
// [UMPConsentInformation.sharedInstance reset];
|
279
|
+
|
280
|
+
dispatch_async(dispatch_get_main_queue(), ^{
|
281
|
+
[UMPConsentInformation.sharedInstance
|
282
|
+
requestConsentInfoUpdateWithParameters:parameters
|
283
|
+
completionHandler:^(NSError *_Nullable requestConsentError) {
|
284
|
+
if (requestConsentError != nil) {
|
285
|
+
// NSLog(@"Errors in updating consent information: %@", requestConsentError);
|
286
|
+
CDVPluginResult *pluginResult = [CDVPluginResult resultWithStatus:CDVCommandStatus_ERROR messageAsString:requestConsentError.description];
|
287
|
+
[self.commandDelegate sendPluginResult:pluginResult callbackId:command.callbackId];
|
288
|
+
return;
|
289
|
+
}
|
290
|
+
|
291
|
+
// NSLog(@"Successful update of consent info. Continue to load and present consent form.");
|
292
|
+
|
293
|
+
[UMPConsentForm loadAndPresentIfRequiredFromViewController:self.viewController
|
294
|
+
completionHandler:^(NSError *loadAndPresentError) {
|
295
|
+
if (loadAndPresentError != nil) {
|
296
|
+
// NSLog(@"Error loading and presenting consent form: %@", loadAndPresentError);
|
297
|
+
CDVPluginResult *pluginResult = [CDVPluginResult resultWithStatus:CDVCommandStatus_ERROR messageAsString:loadAndPresentError.description];
|
298
|
+
[self.commandDelegate sendPluginResult:pluginResult callbackId:command.callbackId];
|
299
|
+
} else {
|
300
|
+
// NSLog(@"Consent form successfully loaded");
|
301
|
+
[UMPConsentForm presentPrivacyOptionsFormFromViewController:self.viewController completionHandler:^(NSError * _Nullable formError) {
|
302
|
+
if (formError) {
|
303
|
+
// NSLog(@"Error when displaying the form: %@", formError);
|
304
|
+
} else {
|
305
|
+
// NSLog(@"The privacy options form is successfully displayed.");
|
306
|
+
}
|
307
|
+
}];
|
308
|
+
}
|
309
|
+
}];
|
310
|
+
}];
|
311
|
+
});
|
312
|
+
}
|
483
313
|
|
484
|
-
|
485
|
-
|
314
|
+
|
315
|
+
|
316
|
+
|
317
|
+
|
318
|
+
- (void)showPrivacyOptionsForm:(CDVInvokedUrlCommand *)command {
|
319
|
+
NSString *deviceId = [self __getAdMobDeviceId];
|
320
|
+
UMPRequestParameters *parameters = [[UMPRequestParameters alloc] init];
|
321
|
+
|
322
|
+
if (isDebugGeography) {
|
323
|
+
UMPDebugSettings *debugSettings = [[UMPDebugSettings alloc] init];
|
324
|
+
parameters.debugSettings = debugSettings;
|
325
|
+
debugSettings.geography = UMPDebugGeographyEEA;
|
326
|
+
debugSettings.testDeviceIdentifiers = @[ deviceId ];
|
327
|
+
|
328
|
+
// NSLog(@"[showPrivacyOptionsForm] Using EEA debug geography for consent.");
|
486
329
|
}
|
330
|
+
|
331
|
+
parameters.tagForUnderAgeOfConsent = UnderAgeOfConsent;
|
332
|
+
|
333
|
+
dispatch_async(dispatch_get_main_queue(), ^{
|
334
|
+
[UMPConsentInformation.sharedInstance
|
335
|
+
requestConsentInfoUpdateWithParameters:parameters
|
336
|
+
completionHandler:^(NSError *_Nullable requestConsentError) {
|
337
|
+
if (requestConsentError != nil) {
|
338
|
+
// NSLog(@"[showPrivacyOptionsForm] Error in updating consent info: %@", requestConsentError);
|
339
|
+
CDVPluginResult *pluginResult = [CDVPluginResult resultWithStatus:CDVCommandStatus_ERROR messageAsString:requestConsentError.description];
|
340
|
+
[self.commandDelegate sendPluginResult:pluginResult callbackId:command.callbackId];
|
341
|
+
return;
|
342
|
+
}
|
343
|
+
|
344
|
+
// NSLog(@"[showPrivacyOptionsForm] Successful update of consent info. Continue to load and present consent form.");
|
345
|
+
|
346
|
+
[UMPConsentForm loadAndPresentIfRequiredFromViewController:self.viewController
|
347
|
+
completionHandler:^(NSError *loadAndPresentError) {
|
348
|
+
if (loadAndPresentError) {
|
349
|
+
// NSLog(@"[showPrivacyOptionsForm] Error loading and presenting consent form: %@", loadAndPresentError);
|
350
|
+
CDVPluginResult *pluginResult = [CDVPluginResult resultWithStatus:CDVCommandStatus_ERROR messageAsString:loadAndPresentError.description];
|
351
|
+
[self.commandDelegate sendPluginResult:pluginResult callbackId:command.callbackId];
|
352
|
+
} else {
|
353
|
+
/// NSLog(@"[showPrivacyOptionsForm] Consent form successfully displayed.");
|
354
|
+
}
|
355
|
+
}];
|
356
|
+
|
357
|
+
|
358
|
+
if ([self isPrivacyOptionsRequired]) {
|
359
|
+
// NSLog(@"[isPrivacyOptionsRequired] Privacy options required.");
|
360
|
+
[self privacyOptionsFormShow:command];
|
361
|
+
} else {
|
362
|
+
// NSLog(@"[isPrivacyOptionsRequired] Privacy option form not required.");
|
363
|
+
CDVPluginResult *pluginResult = [CDVPluginResult resultWithStatus:CDVCommandStatus_OK messageAsString:@"The privacy option form is not required."];
|
364
|
+
[self.commandDelegate sendPluginResult:pluginResult callbackId:command.callbackId];
|
365
|
+
}
|
366
|
+
}];
|
367
|
+
});
|
368
|
+
}
|
487
369
|
|
488
|
-
|
489
|
-
|
490
|
-
|
491
|
-
|
492
|
-
|
493
|
-
|
494
|
-
|
495
|
-
|
496
|
-
|
497
|
-
|
498
|
-
|
499
|
-
|
500
|
-
|
501
|
-
|
502
|
-
|
503
|
-
|
504
|
-
.callbackId];
|
505
|
-
}];
|
370
|
+
|
371
|
+
- (void)privacyOptionsFormShow:(CDVInvokedUrlCommand *)command {
|
372
|
+
[self.commandDelegate runInBackground:^{
|
373
|
+
dispatch_async(dispatch_get_main_queue(), ^{
|
374
|
+
[UMPConsentForm presentPrivacyOptionsFormFromViewController:self.viewController
|
375
|
+
completionHandler:^(NSError *_Nullable formError) {
|
376
|
+
if (formError) {
|
377
|
+
// NSLog(@"[privacyOptionsFormShow] Error displaying the privacy options form: %@", formError);
|
378
|
+
CDVPluginResult *pluginResult = [CDVPluginResult resultWithStatus:CDVCommandStatus_ERROR messageAsString:formError.description];
|
379
|
+
[self.commandDelegate sendPluginResult:pluginResult callbackId:command.callbackId];
|
380
|
+
} else {
|
381
|
+
// NSLog(@"[privacyOptionsFormShow] The privacy options form is successfully displayed.");
|
382
|
+
}
|
383
|
+
}];
|
384
|
+
});
|
385
|
+
}];
|
506
386
|
}
|
507
387
|
|
508
|
-
|
509
|
-
|
510
|
-
|
511
|
-
|
512
|
-
|
513
|
-
.privacyOptionsRequirementStatus
|
514
|
-
== UMPPrivacyOptionsRequirementStatusRequired;
|
388
|
+
// Cek apakah opsi privasi diperlukan
|
389
|
+
- (BOOL)isPrivacyOptionsRequired {
|
390
|
+
UMPPrivacyOptionsRequirementStatus status = UMPConsentInformation.sharedInstance.privacyOptionsRequirementStatus;
|
391
|
+
// NSLog(@"[isPrivacyOptionsRequired] Privacy option status: %ld", (long)status);
|
392
|
+
return status == UMPPrivacyOptionsRequirementStatusRequired;
|
515
393
|
}
|
516
394
|
|
517
|
-
|
518
|
-
|
519
|
-
{
|
520
|
-
|
521
|
-
|
522
|
-
|
523
|
-
|
524
|
-
|
525
|
-
|
526
|
-
|
527
|
-
|
528
|
-
|
529
|
-
|
530
|
-
|
531
|
-
|
532
|
-
|
533
|
-
|
534
|
-
|
535
|
-
|
536
|
-
|
537
|
-
|
538
|
-
|
539
|
-
|
540
|
-
|
541
|
-
|
542
|
-
|
543
|
-
|
544
|
-
stringForKey:
|
545
|
-
@"IABTCF"
|
546
|
-
@"_Purpo"
|
547
|
-
@"seCons"
|
548
|
-
@"ents"];
|
549
|
-
NSString *TCString =
|
550
|
-
[prefs
|
551
|
-
stringForKey:
|
552
|
-
@"IABTCF"
|
553
|
-
@"_TCStr"
|
554
|
-
@"ing"];
|
555
|
-
result[@"IABTCF_"
|
556
|
-
@"CmpSdkID"]
|
557
|
-
= CmpSdkID;
|
558
|
-
result
|
559
|
-
[@"IABTCF_"
|
560
|
-
@"gdprApplies"]
|
561
|
-
= gdprApplies;
|
562
|
-
result[@"IABTCF_"
|
563
|
-
@"PurposeCons"
|
564
|
-
@"ents"]
|
565
|
-
= PurposeConsents;
|
566
|
-
result[@"IABTCF_"
|
567
|
-
@"TCString"]
|
568
|
-
= TCString;
|
569
|
-
// NSLog(@"%@",
|
570
|
-
// [[NSUserDefaults
|
571
|
-
// standardUserDefaults]
|
572
|
-
// dictionaryRepresentation]);
|
573
|
-
[prefs synchronize];
|
395
|
+
|
396
|
+
- (void)readStatus:(CDVInvokedUrlCommand *)command {
|
397
|
+
[self.commandDelegate runInBackground:^{
|
398
|
+
Consent_Status = (int)UMPConsentInformation.sharedInstance.consentStatus;
|
399
|
+
|
400
|
+
if (Consent_Status == UMPConsentStatusUnknown) {
|
401
|
+
|
402
|
+
Consent_Status = UMPConsentStatusUnknown;
|
403
|
+
} else if (Consent_Status == UMPConsentStatusRequired) {
|
404
|
+
|
405
|
+
Consent_Status = UMPConsentStatusRequired;
|
406
|
+
} else if (Consent_Status == UMPConsentStatusNotRequired) {
|
407
|
+
|
408
|
+
Consent_Status = UMPConsentStatusNotRequired;
|
409
|
+
} else if (Consent_Status == UMPConsentStatusObtained) {
|
410
|
+
|
411
|
+
Consent_Status = UMPConsentStatusObtained;
|
412
|
+
}
|
413
|
+
|
414
|
+
NSLog(@"The Consent " @"Status %i",
|
415
|
+
Consent_Status);
|
416
|
+
CDVPluginResult *pluginResult =
|
417
|
+
[CDVPluginResult resultWithStatus:CDVCommandStatus_OK
|
418
|
+
messageAsInt:Consent_Status];
|
419
|
+
[self.commandDelegate sendPluginResult:pluginResult
|
420
|
+
callbackId:command.callbackId];
|
421
|
+
}];
|
574
422
|
}
|
575
|
-
|
576
|
-
|
577
|
-
|
578
|
-
|
579
|
-
|
580
|
-
|
581
|
-
|
582
|
-
|
583
|
-
|
584
|
-
|
585
|
-
|
586
|
-
|
587
|
-
|
588
|
-
|
589
|
-
|
590
|
-
|
591
|
-
|
592
|
-
|
593
|
-
|
594
|
-
|
595
|
-
|
596
|
-
|
597
|
-
|
598
|
-
|
599
|
-
|
600
|
-
|
601
|
-
|
602
|
-
|
603
|
-
|
604
|
-
|
605
|
-
|
606
|
-
|
607
|
-
@"
|
608
|
-
|
609
|
-
@"
|
610
|
-
@"
|
611
|
-
|
612
|
-
@"
|
613
|
-
|
614
|
-
|
615
|
-
|
616
|
-
|
617
|
-
|
618
|
-
|
619
|
-
|
620
|
-
|
621
|
-
|
622
|
-
|
623
|
-
|
624
|
-
|
625
|
-
|
626
|
-
|
627
|
-
|
628
|
-
|
629
|
-
|
630
|
-
|
631
|
-
|
632
|
-
result[@"IABTCF_"
|
633
|
-
@"CmpSdkID"]
|
634
|
-
= CmpSdkID;
|
635
|
-
result[@"IABTCF_"
|
636
|
-
@"gdprAppli"
|
637
|
-
@"es"]
|
638
|
-
= gdprApplies;
|
639
|
-
result[@"IABTCF_"
|
640
|
-
@"PurposeCo"
|
641
|
-
@"nsents"]
|
642
|
-
= PurposeConsents;
|
643
|
-
result[@"IABTCF_"
|
644
|
-
@"TCString"]
|
645
|
-
= TCString;
|
646
|
-
[[NSUserDefaults
|
647
|
-
standardUserDefaults]
|
648
|
-
synchronize];
|
649
|
-
NSLog (
|
650
|
-
@"%@",
|
651
|
-
[[NSUserDefaults
|
652
|
-
standardUserDefaults]
|
653
|
-
dictionaryRepresentation]);
|
654
|
-
pluginResult = [CDVPluginResult
|
655
|
-
resultWithStatus:
|
656
|
-
CDVCommandStatus_OK
|
657
|
-
messageAsDictionary:
|
658
|
-
result];
|
659
|
-
[self
|
660
|
-
fireEvent:@""
|
661
|
-
event:
|
662
|
-
@"on."
|
663
|
-
@"getI"
|
664
|
-
@"abTf"
|
665
|
-
@"c"
|
666
|
-
withData:nil];
|
667
|
-
}
|
668
|
-
else
|
669
|
-
{
|
670
|
-
pluginResult = [CDVPluginResult
|
671
|
-
resultWithStatus:
|
672
|
-
CDVCommandStatus_ERROR];
|
673
|
-
}
|
674
|
-
[self.commandDelegate
|
675
|
-
sendPluginResult:
|
676
|
-
pluginResult
|
677
|
-
callbackId:
|
678
|
-
callbackId];
|
423
|
+
|
424
|
+
|
425
|
+
- (void)getIabTfc:(CDVInvokedUrlCommand *)command {
|
426
|
+
CDVPluginResult *pluginResult;
|
427
|
+
NSString *callbackId = command.callbackId;
|
428
|
+
if (isIAB == 1) {
|
429
|
+
NSMutableDictionary *result = [[NSMutableDictionary alloc] init];
|
430
|
+
NSUserDefaults *prefs = [NSUserDefaults standardUserDefaults];
|
431
|
+
NSNumber *CmpSdkID = [prefs valueForKey:@"IABT"
|
432
|
+
@"CF_"
|
433
|
+
@"CmpS"
|
434
|
+
@"dkI"
|
435
|
+
@"D"];
|
436
|
+
NSString *gdprApplies = [prefs stringForKey:@"IABT"
|
437
|
+
@"CF_"
|
438
|
+
@"gdpr"
|
439
|
+
@"Appl"
|
440
|
+
@"ie"
|
441
|
+
@"s"];
|
442
|
+
NSString *PurposeConsents = [prefs stringForKey:@"IABT"
|
443
|
+
@"CF_"
|
444
|
+
@"Purp"
|
445
|
+
@"oseC"
|
446
|
+
@"onse"
|
447
|
+
@"nt"
|
448
|
+
@"s"];
|
449
|
+
NSString *TCString = [prefs stringForKey:@"IABT"
|
450
|
+
@"CF_"
|
451
|
+
@"TCSt"
|
452
|
+
@"rin"
|
453
|
+
@"g"];
|
454
|
+
result[@"IABTCF_"
|
455
|
+
@"CmpSdkID"] = CmpSdkID;
|
456
|
+
result[@"IABTCF_"
|
457
|
+
@"gdprAppli"
|
458
|
+
@"es"] = gdprApplies;
|
459
|
+
result[@"IABTCF_"
|
460
|
+
@"PurposeCo"
|
461
|
+
@"nsents"] = PurposeConsents;
|
462
|
+
result[@"IABTCF_"
|
463
|
+
@"TCString"] = TCString;
|
464
|
+
[[NSUserDefaults standardUserDefaults] synchronize];
|
465
|
+
NSLog(@"%@",
|
466
|
+
[[NSUserDefaults standardUserDefaults] dictionaryRepresentation]);
|
467
|
+
pluginResult = [CDVPluginResult resultWithStatus:CDVCommandStatus_OK
|
468
|
+
messageAsDictionary:result];
|
469
|
+
[self fireEvent:@""
|
470
|
+
event:@"on."
|
471
|
+
@"getI"
|
472
|
+
@"abTf"
|
473
|
+
@"c"
|
474
|
+
withData:nil];
|
475
|
+
} else {
|
476
|
+
pluginResult =
|
477
|
+
[CDVPluginResult resultWithStatus:CDVCommandStatus_ERROR];
|
478
|
+
}
|
479
|
+
[self.commandDelegate sendPluginResult:pluginResult callbackId:callbackId];
|
679
480
|
}
|
680
|
-
- (void)consentReset:
|
681
|
-
|
682
|
-
|
683
|
-
{
|
684
|
-
|
685
|
-
|
686
|
-
|
687
|
-
|
688
|
-
|
689
|
-
|
690
|
-
|
691
|
-
[[UMPConsentInformation
|
692
|
-
sharedInstance]
|
693
|
-
reset];
|
694
|
-
pluginResult = [CDVPluginResult
|
695
|
-
resultWithStatus:
|
696
|
-
CDVCommandStatus_OK];
|
697
|
-
}
|
698
|
-
@catch (
|
699
|
-
NSException
|
700
|
-
*exception)
|
701
|
-
{
|
702
|
-
pluginResult = [CDVPluginResult
|
703
|
-
resultWithStatus:
|
704
|
-
CDVCommandStatus_ERROR
|
705
|
-
messageAsString:
|
706
|
-
exception
|
707
|
-
.reason];
|
708
|
-
}
|
709
|
-
[self.commandDelegate
|
710
|
-
sendPluginResult:
|
711
|
-
pluginResult
|
712
|
-
callbackId:
|
713
|
-
callbackId];
|
481
|
+
- (void)consentReset:(CDVInvokedUrlCommand *)command {
|
482
|
+
CDVPluginResult *pluginResult;
|
483
|
+
NSString *callbackId = command.callbackId;
|
484
|
+
@try {
|
485
|
+
[[UMPConsentInformation sharedInstance] reset];
|
486
|
+
pluginResult = [CDVPluginResult resultWithStatus:CDVCommandStatus_OK];
|
487
|
+
} @catch (NSException *exception) {
|
488
|
+
pluginResult = [CDVPluginResult resultWithStatus:CDVCommandStatus_ERROR
|
489
|
+
messageAsString:exception.reason];
|
490
|
+
}
|
491
|
+
[self.commandDelegate sendPluginResult:pluginResult callbackId:callbackId];
|
714
492
|
}
|
715
|
-
|
716
|
-
|
717
|
-
|
718
|
-
|
719
|
-
|
720
|
-
|
721
|
-
|
722
|
-
|
723
|
-
|
724
|
-
|
725
|
-
|
726
|
-
|
727
|
-
|
728
|
-
|
729
|
-
|
730
|
-
|
731
|
-
|
732
|
-
|
733
|
-
|
734
|
-
|
735
|
-
|
736
|
-
|
737
|
-
|
738
|
-
floatValue];
|
739
|
-
BOOL
|
740
|
-
publisherFirstPartyIdEnabled
|
741
|
-
= [[command
|
742
|
-
argumentAtIndex:
|
743
|
-
3]
|
744
|
-
boolValue];
|
745
|
-
NSString *npa =
|
746
|
-
[command.arguments
|
747
|
-
objectAtIndex:
|
748
|
-
2];
|
749
|
-
BOOL
|
750
|
-
enableCollapsible
|
751
|
-
= [[command
|
752
|
-
argumentAtIndex:
|
753
|
-
3]
|
754
|
-
boolValue];
|
755
|
-
BOOL responseInfo =
|
756
|
-
[[command
|
757
|
-
argumentAtIndex:
|
758
|
-
4]
|
759
|
-
boolValue];
|
760
|
-
BOOL
|
761
|
-
setDebugGeography
|
762
|
-
= [[command
|
763
|
-
argumentAtIndex:
|
764
|
-
5]
|
765
|
-
boolValue];
|
766
|
-
@try
|
767
|
-
{
|
768
|
-
GADMobileAds
|
769
|
-
.sharedInstance
|
770
|
-
.applicationVolume
|
771
|
-
= setAppVolume;
|
772
|
-
GADMobileAds
|
773
|
-
.sharedInstance
|
774
|
-
.applicationMuted
|
775
|
-
= setAppMuted;
|
776
|
-
[self
|
777
|
-
setPublisherFirstPartyIDEnabled:
|
778
|
-
publisherFirstPartyIdEnabled];
|
779
|
-
Npa = npa;
|
780
|
-
EnableCollapsible
|
781
|
-
= enableCollapsible;
|
782
|
-
ResponseInfo
|
783
|
-
= responseInfo;
|
784
|
-
isDebugGeography
|
785
|
-
= setDebugGeography;
|
786
|
-
pluginResult = [CDVPluginResult
|
787
|
-
resultWithStatus:
|
788
|
-
CDVCommandStatus_OK];
|
789
|
-
}
|
790
|
-
@catch (
|
791
|
-
NSException
|
792
|
-
*exception)
|
793
|
-
{
|
794
|
-
pluginResult = [CDVPluginResult
|
795
|
-
resultWithStatus:
|
796
|
-
CDVCommandStatus_ERROR
|
797
|
-
messageAsString:
|
798
|
-
exception
|
799
|
-
.reason];
|
800
|
-
}
|
801
|
-
[self.commandDelegate
|
802
|
-
sendPluginResult:
|
803
|
-
pluginResult
|
804
|
-
callbackId:
|
805
|
-
callbackId];
|
493
|
+
|
494
|
+
|
495
|
+
|
496
|
+
|
497
|
+
|
498
|
+
|
499
|
+
- (void)globalSettings:(CDVInvokedUrlCommand *)command {
|
500
|
+
CDVPluginResult *pluginResult;
|
501
|
+
NSString *callbackId = command.callbackId;
|
502
|
+
NSDictionary *options = [command.arguments objectAtIndex:0];
|
503
|
+
BOOL setAppMuted = [[options valueForKey:@"setAppMuted"] boolValue];
|
504
|
+
BOOL setAppVolume = [[options valueForKey:@"setAppVolume"] boolValue];
|
505
|
+
BOOL pubIdEnabled = [[options valueForKey:@"pubIdEnabled"] boolValue];
|
506
|
+
@try {
|
507
|
+
GADMobileAds.sharedInstance.applicationVolume = setAppVolume;
|
508
|
+
GADMobileAds.sharedInstance.applicationMuted = setAppMuted;
|
509
|
+
[GADMobileAds.sharedInstance.requestConfiguration setPublisherFirstPartyIDEnabled:pubIdEnabled];
|
510
|
+
pluginResult = [CDVPluginResult resultWithStatus:CDVCommandStatus_OK];
|
511
|
+
} @catch (NSException *exception) {
|
512
|
+
pluginResult = [CDVPluginResult resultWithStatus:CDVCommandStatus_ERROR
|
513
|
+
messageAsString:exception.reason];
|
514
|
+
}
|
515
|
+
[self.commandDelegate sendPluginResult:pluginResult callbackId:callbackId];
|
806
516
|
}
|
807
|
-
|
808
|
-
|
809
|
-
|
810
|
-
|
811
|
-
|
812
|
-
|
813
|
-
|
814
|
-
|
815
|
-
|
816
|
-
|
817
|
-
|
818
|
-
|
819
|
-
|
820
|
-
|
821
|
-
|
822
|
-
|
823
|
-
|
824
|
-
|
825
|
-
|
826
|
-
|
827
|
-
|
828
|
-
|
829
|
-
|
830
|
-
|
831
|
-
@
|
832
|
-
|
833
|
-
|
834
|
-
|
835
|
-
|
836
|
-
|
837
|
-
|
838
|
-
|
839
|
-
|
840
|
-
|
841
|
-
|
842
|
-
.tagForUnderAgeOfConsent
|
843
|
-
= underAgeOfConsent;
|
844
|
-
requestConfiguration
|
845
|
-
.maxAdContentRating
|
846
|
-
= contentRating;
|
847
|
-
UnderAgeOfConsent
|
848
|
-
= underAgeOfConsent;
|
849
|
-
}
|
850
|
-
@catch (
|
851
|
-
NSException
|
852
|
-
*exception)
|
853
|
-
{
|
854
|
-
pluginResult = [CDVPluginResult
|
855
|
-
resultWithStatus:
|
856
|
-
CDVCommandStatus_ERROR
|
857
|
-
messageAsString:
|
858
|
-
exception
|
859
|
-
.reason];
|
860
|
-
}
|
861
|
-
[self.commandDelegate
|
862
|
-
sendPluginResult:
|
863
|
-
pluginResult
|
864
|
-
callbackId:
|
865
|
-
callbackId];
|
517
|
+
|
518
|
+
|
519
|
+
- (void)targeting:(CDVInvokedUrlCommand *)command {
|
520
|
+
CDVPluginResult *pluginResult;
|
521
|
+
NSString *callbackId = command.callbackId;
|
522
|
+
NSDictionary *options = [command.arguments objectAtIndex:0];
|
523
|
+
BOOL childDirectedTreatment = [[options valueForKey:@"childDirectedTreatment"] boolValue];
|
524
|
+
BOOL underAgeOfConsent = [[options valueForKey:@"underAgeOfConsent"] boolValue];
|
525
|
+
NSString *contentRating = [options valueForKey:@"contentRating"];
|
526
|
+
@try {
|
527
|
+
GADRequestConfiguration *requestConfiguration = GADMobileAds.sharedInstance.requestConfiguration;
|
528
|
+
requestConfiguration.tagForChildDirectedTreatment = @(childDirectedTreatment);
|
529
|
+
requestConfiguration.tagForUnderAgeOfConsent = @(underAgeOfConsent);
|
530
|
+
|
531
|
+
if (contentRating != nil) {
|
532
|
+
if ([contentRating isEqualToString:@"G"]) {
|
533
|
+
requestConfiguration.maxAdContentRating = GADMaxAdContentRatingGeneral;
|
534
|
+
} else if ([contentRating isEqualToString:@"PG"]) {
|
535
|
+
requestConfiguration.maxAdContentRating = GADMaxAdContentRatingParentalGuidance;
|
536
|
+
} else if ([contentRating isEqualToString:@"T"]) {
|
537
|
+
requestConfiguration.maxAdContentRating = GADMaxAdContentRatingTeen;
|
538
|
+
} else if ([contentRating isEqualToString:@"MA"]) {
|
539
|
+
requestConfiguration.maxAdContentRating = GADMaxAdContentRatingMatureAudience;
|
540
|
+
} else {
|
541
|
+
// NSLog(@"Unknown content rating: %@", contentRating);
|
542
|
+
}
|
543
|
+
}
|
544
|
+
|
545
|
+
UnderAgeOfConsent = underAgeOfConsent;
|
546
|
+
|
547
|
+
} @catch (NSException *exception) {
|
548
|
+
pluginResult = [CDVPluginResult resultWithStatus:CDVCommandStatus_ERROR
|
549
|
+
messageAsString:exception.reason];
|
550
|
+
}
|
551
|
+
[self.commandDelegate sendPluginResult:pluginResult callbackId:callbackId];
|
866
552
|
}
|
867
|
-
|
868
|
-
|
869
|
-
|
870
|
-
|
871
|
-
{
|
872
|
-
|
873
|
-
|
874
|
-
|
875
|
-
|
876
|
-
|
877
|
-
|
878
|
-
|
879
|
-
|
880
|
-
|
881
|
-
|
882
|
-
|
883
|
-
|
884
|
-
|
885
|
-
|
886
|
-
|
887
|
-
|
888
|
-
|
889
|
-
|
890
|
-
|
891
|
-
|
892
|
-
|
893
|
-
|
894
|
-
|
895
|
-
|
896
|
-
|
897
|
-
|
898
|
-
|
899
|
-
|
900
|
-
|
901
|
-
|
902
|
-
|
903
|
-
|
904
|
-
|
905
|
-
|
906
|
-
|
907
|
-
|
908
|
-
|
909
|
-
|
910
|
-
|
911
|
-
|
912
|
-
|
913
|
-
return GADAdSizeFullBanner;
|
914
|
-
}
|
915
|
-
else if (
|
916
|
-
[size
|
917
|
-
isEqualToString:
|
918
|
-
@"LEADER"
|
919
|
-
@"BOAR"
|
920
|
-
@"D"])
|
921
|
-
{
|
922
|
-
return GADAdSizeLeaderboard;
|
923
|
-
}
|
924
|
-
else
|
925
|
-
{
|
926
|
-
return GADAdSizeBanner;
|
927
|
-
}
|
553
|
+
|
554
|
+
|
555
|
+
|
556
|
+
|
557
|
+
- (void)pluginInitialize {
|
558
|
+
[super pluginInitialize];
|
559
|
+
|
560
|
+
[[NSNotificationCenter defaultCenter] addObserver:self
|
561
|
+
selector:@selector(orientationDidChange:)
|
562
|
+
name:UIDeviceOrientationDidChangeNotification
|
563
|
+
object:nil];
|
564
|
+
|
565
|
+
isIAB = YES;
|
566
|
+
NSMutableDictionary *result = [[NSMutableDictionary alloc] init];
|
567
|
+
NSUserDefaults *prefs = [NSUserDefaults standardUserDefaults];
|
568
|
+
NSNumber *CmpSdkID = [prefs valueForKey:@"IABTCF"
|
569
|
+
@"_CmpSd"
|
570
|
+
@"kID"];
|
571
|
+
NSString *gdprApplies = [prefs stringForKey:@"IABTCF"
|
572
|
+
@"_gdprA"
|
573
|
+
@"pplie"
|
574
|
+
@"s"];
|
575
|
+
NSString *PurposeConsents = [prefs stringForKey:@"IABTCF"
|
576
|
+
@"_Purpo"
|
577
|
+
@"seCons"
|
578
|
+
@"ents"];
|
579
|
+
NSString *TCString = [prefs stringForKey:@"IABTCF"
|
580
|
+
@"_TCStr"
|
581
|
+
@"ing"];
|
582
|
+
result[@"IABTCF_"
|
583
|
+
@"CmpSdkID"] = CmpSdkID;
|
584
|
+
result[@"IABTCF_"
|
585
|
+
@"gdprApplies"] = gdprApplies;
|
586
|
+
result[@"IABTCF_"
|
587
|
+
@"PurposeCons"
|
588
|
+
@"ents"] = PurposeConsents;
|
589
|
+
result[@"IABTCF_"
|
590
|
+
@"TCString"] = TCString;
|
591
|
+
// NSLog(@"%@",
|
592
|
+
// [[NSUserDefaults
|
593
|
+
// standardUserDefaults]
|
594
|
+
// dictionaryRepresentation]);
|
595
|
+
[prefs synchronize];
|
596
|
+
|
597
|
+
|
598
|
+
|
928
599
|
}
|
929
|
-
- (void)loadBannerAd:
|
930
|
-
(CDVInvokedUrlCommand
|
931
|
-
*)command
|
932
|
-
{
|
933
600
|
|
934
|
-
|
935
|
-
|
936
|
-
|
937
|
-
|
938
|
-
|
939
|
-
|
940
|
-
|
941
|
-
|
942
|
-
|
943
|
-
|
944
|
-
|
945
|
-
|
946
|
-
|
947
|
-
|
948
|
-
|
949
|
-
|
950
|
-
|
951
|
-
|
952
|
-
|
953
|
-
|
954
|
-
|
955
|
-
|
956
|
-
|
957
|
-
|
958
|
-
|
959
|
-
|
960
|
-
|
961
|
-
|
962
|
-
|
963
|
-
|
964
|
-
|
965
|
-
|
966
|
-
|
967
|
-
|
968
|
-
|
969
|
-
|
970
|
-
|
971
|
-
|
972
|
-
|
973
|
-
|
974
|
-
|
975
|
-
|
976
|
-
|
977
|
-
|
978
|
-
|
979
|
-
|
980
|
-
|
981
|
-
|
982
|
-
|
983
|
-
intValue];
|
984
|
-
adWidth
|
985
|
-
= intValue;
|
986
|
-
Position
|
987
|
-
= position;
|
988
|
-
GADAdSize sizes = [self
|
989
|
-
__AdSizeFromString:
|
990
|
-
size];
|
991
|
-
self.bannerView =
|
992
|
-
[[GADBannerView
|
993
|
-
alloc]
|
994
|
-
initWithAdSize:
|
995
|
-
sizes];
|
996
|
-
GADRequest
|
997
|
-
*request
|
998
|
-
= [GADRequest
|
999
|
-
request];
|
1000
|
-
GADExtras *extras
|
1001
|
-
= [[GADExtras
|
1002
|
-
alloc]
|
1003
|
-
init];
|
1004
|
-
if (EnableCollapsible)
|
1005
|
-
{
|
1006
|
-
extras
|
1007
|
-
.additionalParameters
|
1008
|
-
= @{
|
1009
|
-
@"colla"
|
1010
|
-
@"psibl"
|
1011
|
-
@"e" :
|
1012
|
-
collapsible
|
1013
|
-
};
|
1014
|
-
}
|
1015
|
-
extras
|
1016
|
-
.additionalParameters
|
1017
|
-
= @{
|
1018
|
-
@"npa" :
|
1019
|
-
Npa
|
1020
|
-
};
|
1021
|
-
[request
|
1022
|
-
registerAdNetworkExtras:
|
1023
|
-
extras];
|
1024
|
-
self.bannerView
|
1025
|
-
.adUnitID
|
1026
|
-
= adUnitId;
|
1027
|
-
self.bannerView
|
1028
|
-
.rootViewController
|
1029
|
-
= self.viewController;
|
1030
|
-
self.bannerView
|
1031
|
-
.delegate
|
1032
|
-
= self;
|
1033
|
-
[self.bannerView
|
1034
|
-
loadRequest:
|
1035
|
-
request];
|
1036
|
-
self.bannerView
|
1037
|
-
.hidden
|
1038
|
-
= YES;
|
1039
|
-
[parentView
|
1040
|
-
addSubview:
|
1041
|
-
self.bannerView];
|
1042
|
-
[parentView
|
1043
|
-
bringSubviewToFront:
|
1044
|
-
self.bannerView];
|
1045
|
-
});
|
1046
|
-
pluginResult = [CDVPluginResult
|
1047
|
-
resultWithStatus:
|
1048
|
-
CDVCommandStatus_OK];
|
1049
|
-
}
|
1050
|
-
else
|
1051
|
-
{
|
1052
|
-
NSLog (
|
1053
|
-
@"Admob "
|
1054
|
-
@"Option "
|
1055
|
-
@"invalid for "
|
1056
|
-
@"banner");
|
1057
|
-
pluginResult = [CDVPluginResult
|
1058
|
-
resultWithStatus:
|
1059
|
-
CDVCommandStatus_ERROR];
|
1060
|
-
}
|
1061
|
-
[self.commandDelegate
|
1062
|
-
sendPluginResult:
|
1063
|
-
pluginResult
|
1064
|
-
callbackId:
|
1065
|
-
callbackId];
|
601
|
+
|
602
|
+
|
603
|
+
|
604
|
+
|
605
|
+
|
606
|
+
- (void)orientationDidChange:(NSNotification *)notification {
|
607
|
+
// NSLog(@"Orientation changed");
|
608
|
+
[self fireEvent:@"" event:@"on.screen.rotated" withData:nil];
|
609
|
+
if (isAutoResize) {
|
610
|
+
dispatch_async(dispatch_get_main_queue(), ^{
|
611
|
+
@try {
|
612
|
+
|
613
|
+
if (self.bannerView) {
|
614
|
+
UIView *parentView = self.bannerView.superview;
|
615
|
+
if (parentView != nil) {
|
616
|
+
[self.bannerView removeFromSuperview];
|
617
|
+
}
|
618
|
+
}
|
619
|
+
|
620
|
+
self.bannerViewLayout = [[UIView alloc] initWithFrame:CGRectZero];
|
621
|
+
self.bannerViewLayout.translatesAutoresizingMaskIntoConstraints = NO;
|
622
|
+
|
623
|
+
UIView *rootView = self.viewController.view;
|
624
|
+
if ([rootView isKindOfClass:[UIView class]]) {
|
625
|
+
[rootView addSubview:self.bannerViewLayout];
|
626
|
+
|
627
|
+
|
628
|
+
[self.bannerViewLayout.topAnchor constraintEqualToAnchor:rootView.topAnchor].active = YES;
|
629
|
+
[self.bannerViewLayout.leadingAnchor constraintEqualToAnchor:rootView.leadingAnchor].active = YES;
|
630
|
+
[self.bannerViewLayout.trailingAnchor constraintEqualToAnchor:rootView.trailingAnchor].active = YES;
|
631
|
+
[self.bannerViewLayout.heightAnchor constraintEqualToConstant:50].active = YES;
|
632
|
+
}
|
633
|
+
|
634
|
+
|
635
|
+
self.bannerView = [[GADBannerView alloc] initWithAdSize:GADCurrentOrientationAnchoredAdaptiveBannerAdSizeWithWidth(rootView.frame.size.width)];
|
636
|
+
self.bannerView.adUnitID = bannerSaveAdUnitId;
|
637
|
+
self.bannerView.delegate = self;
|
638
|
+
[self.bannerView loadRequest:[GADRequest request]];
|
639
|
+
|
640
|
+
|
641
|
+
[self.bannerViewLayout addSubview:self.bannerView];
|
642
|
+
[self.bannerViewLayout bringSubviewToFront:self.bannerView];
|
643
|
+
|
644
|
+
} @catch (NSException *exception) {
|
645
|
+
// NSLog(@"Error adjusting banner size: %@", exception.reason);
|
646
|
+
// PUBLIC_CALLBACKS.error([NSString stringWithFormat:@"Error adjusting banner size: %@", exception.reason]);
|
647
|
+
}
|
648
|
+
});
|
649
|
+
}
|
1066
650
|
}
|
1067
|
-
|
1068
|
-
|
1069
|
-
|
1070
|
-
|
1071
|
-
|
1072
|
-
|
1073
|
-
|
1074
|
-
|
1075
|
-
|
1076
|
-
|
1077
|
-
|
1078
|
-
|
1079
|
-
|
1080
|
-
|
1081
|
-
|
1082
|
-
|
1083
|
-
|
1084
|
-
|
1085
|
-
|
1086
|
-
|
1087
|
-
|
1088
|
-
|
1089
|
-
|
1090
|
-
|
1091
|
-
|
1092
|
-
|
1093
|
-
|
1094
|
-
|
1095
|
-
|
1096
|
-
|
1097
|
-
|
1098
|
-
|
1099
|
-
|
1100
|
-
|
1101
|
-
|
1102
|
-
|
1103
|
-
|
1104
|
-
|
1105
|
-
|
1106
|
-
|
1107
|
-
|
1108
|
-
|
651
|
+
|
652
|
+
|
653
|
+
|
654
|
+
|
655
|
+
|
656
|
+
|
657
|
+
- (void)addBannerConstraints {
|
658
|
+
self.bannerView.translatesAutoresizingMaskIntoConstraints = NO;
|
659
|
+
|
660
|
+
// Tambahkan constraint berdasarkan posisi
|
661
|
+
if ([Position isEqualToString:@"bottom-center"]) {
|
662
|
+
[self.viewController.view addConstraints:@[
|
663
|
+
[NSLayoutConstraint constraintWithItem:self.bannerView
|
664
|
+
attribute:NSLayoutAttributeBottom
|
665
|
+
relatedBy:NSLayoutRelationEqual
|
666
|
+
toItem:self.viewController.view.safeAreaLayoutGuide
|
667
|
+
attribute:NSLayoutAttributeBottom
|
668
|
+
multiplier:1
|
669
|
+
constant:0],
|
670
|
+
[NSLayoutConstraint constraintWithItem:self.bannerView
|
671
|
+
attribute:NSLayoutAttributeCenterX
|
672
|
+
relatedBy:NSLayoutRelationEqual
|
673
|
+
toItem:self.viewController.view
|
674
|
+
attribute:NSLayoutAttributeCenterX
|
675
|
+
multiplier:1
|
676
|
+
constant:0]
|
677
|
+
]];
|
678
|
+
} else if ([Position isEqualToString:@"top-center"]) {
|
679
|
+
[self.viewController.view addConstraints:@[
|
680
|
+
[NSLayoutConstraint constraintWithItem:self.bannerView
|
681
|
+
attribute:NSLayoutAttributeTop
|
682
|
+
relatedBy:NSLayoutRelationEqual
|
683
|
+
toItem:self.viewController.view.safeAreaLayoutGuide
|
684
|
+
attribute:NSLayoutAttributeTop
|
685
|
+
multiplier:1
|
686
|
+
constant:0],
|
687
|
+
[NSLayoutConstraint constraintWithItem:self.bannerView
|
688
|
+
attribute:NSLayoutAttributeCenterX
|
689
|
+
relatedBy:NSLayoutRelationEqual
|
690
|
+
toItem:self.viewController.view
|
691
|
+
attribute:NSLayoutAttributeCenterX
|
692
|
+
multiplier:1
|
693
|
+
constant:0]
|
694
|
+
]];
|
695
|
+
}
|
1109
696
|
}
|
1110
|
-
|
1111
|
-
|
1112
|
-
|
1113
|
-
|
1114
|
-
|
1115
|
-
|
1116
|
-
|
1117
|
-
|
1118
|
-
|
1119
|
-
|
1120
|
-
|
1121
|
-
|
1122
|
-
|
1123
|
-
|
1124
|
-
|
1125
|
-
|
1126
|
-
|
1127
|
-
|
1128
|
-
|
1129
|
-
|
1130
|
-
|
1131
|
-
|
1132
|
-
|
1133
|
-
|
1134
|
-
|
1135
|
-
|
1136
|
-
|
1137
|
-
|
1138
|
-
|
1139
|
-
|
1140
|
-
|
1141
|
-
|
1142
|
-
|
1143
|
-
|
1144
|
-
|
1145
|
-
|
1146
|
-
|
1147
|
-
|
1148
|
-
|
1149
|
-
|
1150
|
-
|
1151
|
-
|
1152
|
-
|
1153
|
-
|
1154
|
-
|
1155
|
-
|
1156
|
-
|
1157
|
-
|
1158
|
-
|
1159
|
-
|
1160
|
-
|
1161
|
-
|
1162
|
-
|
1163
|
-
|
1164
|
-
|
1165
|
-
|
1166
|
-
|
1167
|
-
|
1168
|
-
|
1169
|
-
|
1170
|
-
|
1171
|
-
|
1172
|
-
|
1173
|
-
|
1174
|
-
|
1175
|
-
|
1176
|
-
|
1177
|
-
|
1178
|
-
|
1179
|
-
|
1180
|
-
|
1181
|
-
|
1182
|
-
|
1183
|
-
|
1184
|
-
|
1185
|
-
|
1186
|
-
|
1187
|
-
|
1188
|
-
|
1189
|
-
|
1190
|
-
|
1191
|
-
|
1192
|
-
|
1193
|
-
|
1194
|
-
|
1195
|
-
.view
|
1196
|
-
attribute:
|
1197
|
-
NSLayoutAttributeCenterX
|
1198
|
-
multiplier:
|
1199
|
-
1
|
1200
|
-
constant:
|
1201
|
-
0]
|
1202
|
-
]];
|
1203
|
-
}
|
697
|
+
|
698
|
+
|
699
|
+
|
700
|
+
|
701
|
+
|
702
|
+
|
703
|
+
|
704
|
+
|
705
|
+
- (void)loadBannerAd:(CDVInvokedUrlCommand *)command {
|
706
|
+
CDVPluginResult *pluginResult;
|
707
|
+
NSString *callbackId = command.callbackId;
|
708
|
+
adFormat = 3;
|
709
|
+
NSDictionary *options = [command.arguments objectAtIndex:0];
|
710
|
+
NSString *adUnitId = [options valueForKey:@"adUnitId"];
|
711
|
+
NSString *position = [options valueForKey:@"position"];
|
712
|
+
NSString *collapsible = [options valueForKey:@"collapsible"];
|
713
|
+
BOOL autoResize = [[options valueForKey:@"autoResize"] boolValue];
|
714
|
+
NSString *size = [options valueForKey:@"size"];
|
715
|
+
BOOL autoShow = [[options valueForKey:@"autoShow"] boolValue];
|
716
|
+
|
717
|
+
bannerSaveAdUnitId = adUnitId;
|
718
|
+
|
719
|
+
if (adUnitId == nil || [adUnitId length] == 0) {
|
720
|
+
pluginResult = [CDVPluginResult resultWithStatus:CDVCommandStatus_ERROR messageAsString:@"Ad unit ID is required"];
|
721
|
+
[self.commandDelegate sendPluginResult:pluginResult callbackId:callbackId];
|
722
|
+
return;
|
723
|
+
}
|
724
|
+
|
725
|
+
if (collapsible != nil && [collapsible length] > 0) {
|
726
|
+
enableCollapsible = YES;
|
727
|
+
} else {
|
728
|
+
enableCollapsible = NO;
|
729
|
+
}
|
730
|
+
|
731
|
+
if (autoResize) {
|
732
|
+
|
733
|
+
isAutoResize = YES;
|
734
|
+
}
|
735
|
+
|
736
|
+
if (adFormat == 3) {
|
737
|
+
dispatch_async(dispatch_get_main_queue(), ^{
|
738
|
+
|
739
|
+
UIView *parentView = [self.webView superview];
|
740
|
+
CGRect frame = self.bannerView.frame;
|
741
|
+
|
742
|
+
if (@available(iOS 11.0, *)) {
|
743
|
+
UIEdgeInsets safeAreaInsets = self.bannerView.safeAreaInsets;
|
744
|
+
frame = UIEdgeInsetsInsetRect(frame, safeAreaInsets);
|
745
|
+
}
|
746
|
+
|
747
|
+
self.viewWidth = frame.size.width;
|
748
|
+
|
749
|
+
auto_Show = autoShow;
|
750
|
+
adWidth = self.viewWidth;
|
751
|
+
|
752
|
+
Position = position;
|
753
|
+
|
754
|
+
GADAdSize sizes = [self __AdSizeFromString:size];
|
755
|
+
self.bannerView = [[GADBannerView alloc] initWithAdSize:sizes];
|
756
|
+
|
757
|
+
GADRequest *request = [GADRequest request];
|
758
|
+
GADExtras *extras = [[GADExtras alloc] init];
|
759
|
+
|
760
|
+
if (enableCollapsible) {
|
761
|
+
extras.additionalParameters = @{@"collapsible" : collapsible};
|
762
|
+
}
|
763
|
+
|
764
|
+
[request registerAdNetworkExtras:extras];
|
765
|
+
|
766
|
+
self.bannerView.adUnitID = adUnitId;
|
767
|
+
self.bannerView.rootViewController = self.viewController;
|
768
|
+
self.bannerView.delegate = self;
|
769
|
+
[self.bannerView loadRequest:request];
|
770
|
+
self.bannerView.hidden = YES;
|
771
|
+
[parentView addSubview:self.bannerView];
|
772
|
+
[parentView bringSubviewToFront:self.bannerView];
|
773
|
+
});
|
774
|
+
|
775
|
+
pluginResult = [CDVPluginResult resultWithStatus:CDVCommandStatus_OK];
|
776
|
+
} else {
|
777
|
+
// NSLog(@"Admob Option invalid for banner");
|
778
|
+
pluginResult = [CDVPluginResult resultWithStatus:CDVCommandStatus_ERROR];
|
779
|
+
}
|
780
|
+
|
781
|
+
[self.commandDelegate sendPluginResult:pluginResult callbackId:callbackId];
|
1204
782
|
}
|
1205
|
-
|
1206
|
-
|
1207
|
-
|
1208
|
-
|
1209
|
-
|
1210
|
-
|
1211
|
-
|
1212
|
-
|
1213
|
-
|
1214
|
-
|
1215
|
-
|
1216
|
-
|
1217
|
-
|
1218
|
-
|
1219
|
-
|
1220
|
-
|
1221
|
-
|
1222
|
-
|
1223
|
-
|
1224
|
-
|
1225
|
-
|
1226
|
-
|
1227
|
-
|
1228
|
-
nil];
|
1229
|
-
});
|
1230
|
-
pluginResult = [CDVPluginResult
|
1231
|
-
resultWithStatus:
|
1232
|
-
CDVCommandStatus_OK];
|
1233
|
-
}
|
1234
|
-
else
|
1235
|
-
{
|
1236
|
-
pluginResult = [CDVPluginResult
|
1237
|
-
resultWithStatus:
|
1238
|
-
CDVCommandStatus_ERROR];
|
1239
|
-
}
|
1240
|
-
[self.commandDelegate
|
1241
|
-
sendPluginResult:
|
1242
|
-
pluginResult
|
1243
|
-
callbackId:
|
1244
|
-
callbackId];
|
783
|
+
|
784
|
+
|
785
|
+
- (GADAdSize)__AdSizeFromString:(NSString *)size {
|
786
|
+
|
787
|
+
if (self.viewWidth == 0) {
|
788
|
+
self.viewWidth = [UIScreen mainScreen].bounds.size.width;
|
789
|
+
}
|
790
|
+
|
791
|
+
if ([size isEqualToString:@"responsive_adaptive"]) {
|
792
|
+
return GADCurrentOrientationAnchoredAdaptiveBannerAdSizeWithWidth(self.viewWidth);
|
793
|
+
} else if ([size isEqualToString:@"in_line_adaptive"]) {
|
794
|
+
return GADCurrentOrientationInlineAdaptiveBannerAdSizeWithWidth(self.viewWidth);
|
795
|
+
} else if ([size isEqualToString:@"banner"]) {
|
796
|
+
return GADAdSizeBanner;
|
797
|
+
} else if ([size isEqualToString:@"large_banner"]) {
|
798
|
+
return GADAdSizeLargeBanner;
|
799
|
+
} else if ([size isEqualToString:@"full_banner"]) {
|
800
|
+
return GADAdSizeFullBanner;
|
801
|
+
} else if ([size isEqualToString:@"leaderboard"]) {
|
802
|
+
return GADAdSizeLeaderboard;
|
803
|
+
} else {
|
804
|
+
return GADAdSizeBanner;
|
805
|
+
}
|
1245
806
|
}
|
1246
|
-
|
1247
|
-
|
1248
|
-
|
1249
|
-
|
1250
|
-
|
1251
|
-
|
1252
|
-
|
1253
|
-
|
1254
|
-
|
1255
|
-
|
1256
|
-
|
1257
|
-
|
1258
|
-
|
1259
|
-
|
1260
|
-
|
1261
|
-
|
1262
|
-
|
1263
|
-
|
1264
|
-
|
1265
|
-
|
1266
|
-
|
1267
|
-
|
1268
|
-
|
1269
|
-
|
1270
|
-
event:
|
1271
|
-
@"on.banner.remove"
|
1272
|
-
withData:
|
1273
|
-
nil];
|
1274
|
-
});
|
1275
|
-
pluginResult = [CDVPluginResult
|
1276
|
-
resultWithStatus:
|
1277
|
-
CDVCommandStatus_OK];
|
1278
|
-
}
|
1279
|
-
else
|
1280
|
-
{
|
1281
|
-
pluginResult = [CDVPluginResult
|
1282
|
-
resultWithStatus:
|
1283
|
-
CDVCommandStatus_ERROR];
|
1284
|
-
}
|
1285
|
-
[self.commandDelegate
|
1286
|
-
sendPluginResult:
|
1287
|
-
pluginResult
|
1288
|
-
callbackId:
|
1289
|
-
callbackId];
|
807
|
+
|
808
|
+
|
809
|
+
|
810
|
+
|
811
|
+
- (void)showBannerAd:(CDVInvokedUrlCommand *)command {
|
812
|
+
CDVPluginResult *pluginResult;
|
813
|
+
NSString *callbackId = command.callbackId;
|
814
|
+
if (self.bannerView) {
|
815
|
+
self.bannerView.hidden = NO;
|
816
|
+
[self addBannerViewToView:command];
|
817
|
+
pluginResult = [CDVPluginResult resultWithStatus:CDVCommandStatus_OK];
|
818
|
+
} else {
|
819
|
+
[self fireEvent:@""
|
820
|
+
event:@"on."
|
821
|
+
@"bann"
|
822
|
+
@"er."
|
823
|
+
@"fail"
|
824
|
+
@"ed."
|
825
|
+
@"show"
|
826
|
+
withData:nil];
|
827
|
+
pluginResult =
|
828
|
+
[CDVPluginResult resultWithStatus:CDVCommandStatus_ERROR];
|
829
|
+
}
|
830
|
+
[self.commandDelegate sendPluginResult:pluginResult callbackId:callbackId];
|
1290
831
|
}
|
1291
|
-
|
1292
|
-
|
1293
|
-
|
1294
|
-
|
1295
|
-
|
1296
|
-
|
1297
|
-
|
1298
|
-
|
1299
|
-
|
1300
|
-
|
1301
|
-
|
1302
|
-
|
1303
|
-
|
1304
|
-
|
1305
|
-
|
1306
|
-
|
1307
|
-
|
1308
|
-
|
1309
|
-
|
1310
|
-
|
1311
|
-
|
1312
|
-
|
1313
|
-
|
1314
|
-
|
1315
|
-
|
1316
|
-
|
1317
|
-
|
1318
|
-
|
1319
|
-
|
1320
|
-
|
1321
|
-
|
1322
|
-
|
1323
|
-
|
1324
|
-
|
1325
|
-
|
1326
|
-
|
1327
|
-
|
1328
|
-
|
1329
|
-
|
1330
|
-
|
1331
|
-
|
1332
|
-
|
1333
|
-
|
1334
|
-
|
1335
|
-
|
1336
|
-
|
1337
|
-
|
1338
|
-
|
1339
|
-
|
1340
|
-
|
1341
|
-
|
1342
|
-
|
1343
|
-
|
1344
|
-
|
1345
|
-
|
1346
|
-
|
1347
|
-
|
1348
|
-
|
1349
|
-
|
1350
|
-
|
1351
|
-
|
1352
|
-
|
1353
|
-
|
1354
|
-
|
1355
|
-
|
1356
|
-
@"ed"
|
1357
|
-
@" t"
|
1358
|
-
@"o "
|
1359
|
-
@"lo"
|
1360
|
-
@"ad"
|
1361
|
-
@" A"
|
1362
|
-
@"pp"
|
1363
|
-
@" O"
|
1364
|
-
@"pe"
|
1365
|
-
@"n "
|
1366
|
-
@"Ad"
|
1367
|
-
@" a"
|
1368
|
-
@"d "
|
1369
|
-
@"wi"
|
1370
|
-
@"th"
|
1371
|
-
@" e"
|
1372
|
-
@"rr"
|
1373
|
-
@"or"
|
1374
|
-
@": "
|
1375
|
-
@"%"
|
1376
|
-
@"@",
|
1377
|
-
[error
|
1378
|
-
localizedDescription]);
|
1379
|
-
return;
|
1380
|
-
}
|
1381
|
-
self.appOpenAd
|
1382
|
-
= ad;
|
1383
|
-
self.appOpenAd
|
1384
|
-
.fullScreenContentDelegate
|
1385
|
-
= self;
|
1386
|
-
[self
|
1387
|
-
fireEvent:
|
1388
|
-
@""
|
1389
|
-
event:
|
1390
|
-
@"on.appOpenAd.loaded"
|
1391
|
-
withData:
|
1392
|
-
nil];
|
1393
|
-
if (auto_Show)
|
1394
|
-
{
|
1395
|
-
if (self.appOpenAd
|
1396
|
-
&&
|
1397
|
-
[self.appOpenAd
|
1398
|
-
canPresentFromRootViewController:
|
1399
|
-
self.viewController
|
1400
|
-
error:
|
1401
|
-
nil])
|
1402
|
-
{
|
1403
|
-
[self.appOpenAd
|
1404
|
-
presentFromRootViewController:
|
1405
|
-
self.viewController];
|
1406
|
-
}
|
1407
|
-
else
|
1408
|
-
{
|
1409
|
-
[self
|
1410
|
-
fireEvent:
|
1411
|
-
@""
|
1412
|
-
event:
|
1413
|
-
@"on.appOpenAd.failed.show"
|
1414
|
-
withData:
|
1415
|
-
nil];
|
1416
|
-
}
|
1417
|
-
}
|
1418
|
-
}];
|
1419
|
-
});
|
1420
|
-
pluginResult = [CDVPluginResult
|
1421
|
-
resultWithStatus:
|
1422
|
-
CDVCommandStatus_OK];
|
1423
|
-
}
|
1424
|
-
[self.commandDelegate
|
1425
|
-
sendPluginResult:
|
1426
|
-
pluginResult
|
1427
|
-
callbackId:
|
1428
|
-
callbackId];
|
832
|
+
|
833
|
+
|
834
|
+
|
835
|
+
|
836
|
+
- (void)addBannerViewToView:(CDVInvokedUrlCommand *)command {
|
837
|
+
bannerView.translatesAutoresizingMaskIntoConstraints = NO;
|
838
|
+
[self.viewController.view addSubview:bannerView];
|
839
|
+
if ([Position isEqualToString:@"bottom-center"]) {
|
840
|
+
[self.viewController.view addConstraints:@[
|
841
|
+
[NSLayoutConstraint
|
842
|
+
constraintWithItem:bannerView
|
843
|
+
attribute:NSLayoutAttributeBottom
|
844
|
+
relatedBy:NSLayoutRelationEqual
|
845
|
+
toItem:self.viewController.view.safeAreaLayoutGuide
|
846
|
+
attribute:NSLayoutAttributeBottom
|
847
|
+
multiplier:1
|
848
|
+
constant:0],
|
849
|
+
[NSLayoutConstraint constraintWithItem:bannerView
|
850
|
+
attribute:NSLayoutAttributeCenterX
|
851
|
+
relatedBy:NSLayoutRelationEqual
|
852
|
+
toItem:self.viewController.view
|
853
|
+
attribute:NSLayoutAttributeCenterX
|
854
|
+
multiplier:1
|
855
|
+
constant:0]
|
856
|
+
]];
|
857
|
+
} else if ([Position isEqualToString:@"top-center"]) {
|
858
|
+
|
859
|
+
[self.viewController.view addConstraints:@[
|
860
|
+
[NSLayoutConstraint
|
861
|
+
constraintWithItem:bannerView
|
862
|
+
attribute:NSLayoutAttributeTop
|
863
|
+
relatedBy:NSLayoutRelationEqual
|
864
|
+
toItem:self.viewController.view.safeAreaLayoutGuide
|
865
|
+
attribute:NSLayoutAttributeTop
|
866
|
+
multiplier:1
|
867
|
+
constant:0],
|
868
|
+
[NSLayoutConstraint constraintWithItem:bannerView
|
869
|
+
attribute:NSLayoutAttributeCenterX
|
870
|
+
relatedBy:NSLayoutRelationEqual
|
871
|
+
toItem:self.viewController.view
|
872
|
+
attribute:NSLayoutAttributeCenterX
|
873
|
+
multiplier:1
|
874
|
+
constant:0]
|
875
|
+
]];
|
876
|
+
|
877
|
+
} else
|
878
|
+
{
|
879
|
+
[self.viewController.view addConstraints:@[
|
880
|
+
[NSLayoutConstraint
|
881
|
+
constraintWithItem:bannerView
|
882
|
+
attribute:NSLayoutAttributeBottom
|
883
|
+
relatedBy:NSLayoutRelationEqual
|
884
|
+
toItem:self.viewController.view.safeAreaLayoutGuide
|
885
|
+
attribute:NSLayoutAttributeTop
|
886
|
+
multiplier:1
|
887
|
+
constant:0],
|
888
|
+
[NSLayoutConstraint constraintWithItem:bannerView
|
889
|
+
attribute:NSLayoutAttributeCenterX
|
890
|
+
relatedBy:NSLayoutRelationEqual
|
891
|
+
toItem:self.viewController.view
|
892
|
+
attribute:NSLayoutAttributeCenterX
|
893
|
+
multiplier:1
|
894
|
+
constant:0]
|
895
|
+
]];
|
896
|
+
}
|
1429
897
|
}
|
1430
|
-
- (void)
|
1431
|
-
|
1432
|
-
|
1433
|
-
{
|
1434
|
-
|
1435
|
-
|
1436
|
-
|
1437
|
-
|
1438
|
-
|
1439
|
-
|
1440
|
-
|
1441
|
-
|
1442
|
-
|
1443
|
-
|
1444
|
-
nil])
|
1445
|
-
{
|
1446
|
-
[self.appOpenAd
|
1447
|
-
presentFromRootViewController:
|
1448
|
-
self.viewController];
|
1449
|
-
pluginResult = [CDVPluginResult
|
1450
|
-
resultWithStatus:
|
1451
|
-
CDVCommandStatus_OK];
|
1452
|
-
}
|
1453
|
-
else
|
1454
|
-
{
|
1455
|
-
pluginResult = [CDVPluginResult
|
1456
|
-
resultWithStatus:
|
1457
|
-
CDVCommandStatus_ERROR];
|
1458
|
-
[self
|
1459
|
-
fireEvent:@""
|
1460
|
-
event:
|
1461
|
-
@"on."
|
1462
|
-
@"appO"
|
1463
|
-
@"penA"
|
1464
|
-
@"d."
|
1465
|
-
@"fail"
|
1466
|
-
@"ed."
|
1467
|
-
@"show"
|
1468
|
-
withData:nil];
|
1469
|
-
}
|
1470
|
-
[self.commandDelegate
|
1471
|
-
sendPluginResult:
|
1472
|
-
pluginResult
|
1473
|
-
callbackId:
|
1474
|
-
callbackId];
|
898
|
+
- (void)hideBannerAd:(CDVInvokedUrlCommand *)command {
|
899
|
+
CDVPluginResult *pluginResult;
|
900
|
+
NSString *callbackId = command.callbackId;
|
901
|
+
if (self.bannerView) {
|
902
|
+
dispatch_async(dispatch_get_main_queue(), ^{
|
903
|
+
self.bannerView.hidden = YES;
|
904
|
+
[self fireEvent:@"" event:@"on.banner.hide" withData:nil];
|
905
|
+
});
|
906
|
+
pluginResult = [CDVPluginResult resultWithStatus:CDVCommandStatus_OK];
|
907
|
+
} else {
|
908
|
+
pluginResult =
|
909
|
+
[CDVPluginResult resultWithStatus:CDVCommandStatus_ERROR];
|
910
|
+
}
|
911
|
+
[self.commandDelegate sendPluginResult:pluginResult callbackId:callbackId];
|
1475
912
|
}
|
1476
|
-
- (void)
|
1477
|
-
|
1478
|
-
|
1479
|
-
|
1480
|
-
{
|
1481
|
-
|
1482
|
-
|
1483
|
-
|
1484
|
-
|
1485
|
-
|
1486
|
-
|
1487
|
-
|
1488
|
-
|
1489
|
-
|
1490
|
-
|
1491
|
-
|
1492
|
-
1]
|
1493
|
-
boolValue];
|
1494
|
-
auto_Show = autoShow;
|
1495
|
-
adFormat = 2;
|
1496
|
-
if (adFormat == 2)
|
1497
|
-
{
|
1498
|
-
dispatch_async (dispatch_get_main_queue (), ^{
|
1499
|
-
GADRequest
|
1500
|
-
*request
|
1501
|
-
= [GADRequest
|
1502
|
-
request];
|
1503
|
-
[GADInterstitialAd
|
1504
|
-
loadWithAdUnitID:
|
1505
|
-
adUnitId
|
1506
|
-
request:
|
1507
|
-
request
|
1508
|
-
completionHandler:^(
|
1509
|
-
GADInterstitialAd
|
1510
|
-
*ad,
|
1511
|
-
NSError *
|
1512
|
-
error) {
|
1513
|
-
if (error)
|
1514
|
-
{
|
1515
|
-
NSLog (
|
1516
|
-
@"Fa"
|
1517
|
-
@"il"
|
1518
|
-
@"ed"
|
1519
|
-
@" t"
|
1520
|
-
@"o "
|
1521
|
-
@"lo"
|
1522
|
-
@"ad"
|
1523
|
-
@" i"
|
1524
|
-
@"nt"
|
1525
|
-
@"er"
|
1526
|
-
@"st"
|
1527
|
-
@"it"
|
1528
|
-
@"ia"
|
1529
|
-
@"l "
|
1530
|
-
@"ad"
|
1531
|
-
@" w"
|
1532
|
-
@"it"
|
1533
|
-
@"h "
|
1534
|
-
@"er"
|
1535
|
-
@"ro"
|
1536
|
-
@"r:"
|
1537
|
-
@" %"
|
1538
|
-
@"@",
|
1539
|
-
[error
|
1540
|
-
localizedDescription]);
|
1541
|
-
}
|
1542
|
-
self.interstitial
|
1543
|
-
= ad;
|
1544
|
-
self.interstitial
|
1545
|
-
.fullScreenContentDelegate
|
1546
|
-
= self;
|
1547
|
-
[self
|
1548
|
-
fireEvent:
|
1549
|
-
@""
|
1550
|
-
event:
|
1551
|
-
@"on.interstitial.loaded"
|
1552
|
-
withData:
|
1553
|
-
nil];
|
1554
|
-
if (auto_Show)
|
1555
|
-
{
|
1556
|
-
if (self.interstitial
|
1557
|
-
&&
|
1558
|
-
[self.interstitial
|
1559
|
-
canPresentFromRootViewController:
|
1560
|
-
self.viewController
|
1561
|
-
error:
|
1562
|
-
nil])
|
1563
|
-
{
|
1564
|
-
[self.interstitial
|
1565
|
-
presentFromRootViewController:
|
1566
|
-
self.viewController];
|
1567
|
-
}
|
1568
|
-
else
|
1569
|
-
{
|
1570
|
-
[self
|
1571
|
-
fireEvent:
|
1572
|
-
@""
|
1573
|
-
event:
|
1574
|
-
@"on.interstitial.failed.show"
|
1575
|
-
withData:
|
1576
|
-
nil];
|
1577
|
-
}
|
1578
|
-
}
|
1579
|
-
}];
|
1580
|
-
});
|
1581
|
-
}
|
1582
|
-
pluginResult = [CDVPluginResult
|
1583
|
-
resultWithStatus:
|
1584
|
-
CDVCommandStatus_OK];
|
1585
|
-
[self.commandDelegate
|
1586
|
-
sendPluginResult:
|
1587
|
-
pluginResult
|
1588
|
-
callbackId:
|
1589
|
-
callbackId];
|
913
|
+
- (void)removeBannerAd:(CDVInvokedUrlCommand *)command {
|
914
|
+
CDVPluginResult *pluginResult;
|
915
|
+
NSString *callbackId = command.callbackId;
|
916
|
+
if (self.bannerView) {
|
917
|
+
dispatch_async(dispatch_get_main_queue(), ^{
|
918
|
+
self.bannerView.hidden = YES;
|
919
|
+
[self.bannerView removeFromSuperview];
|
920
|
+
self.bannerView = nil;
|
921
|
+
[self fireEvent:@"" event:@"on.banner.remove" withData:nil];
|
922
|
+
});
|
923
|
+
pluginResult = [CDVPluginResult resultWithStatus:CDVCommandStatus_OK];
|
924
|
+
} else {
|
925
|
+
pluginResult =
|
926
|
+
[CDVPluginResult resultWithStatus:CDVCommandStatus_ERROR];
|
927
|
+
}
|
928
|
+
[self.commandDelegate sendPluginResult:pluginResult callbackId:callbackId];
|
1590
929
|
}
|
1591
|
-
- (void)
|
1592
|
-
|
1593
|
-
|
1594
|
-
|
1595
|
-
|
1596
|
-
|
1597
|
-
|
1598
|
-
|
1599
|
-
|
1600
|
-
|
1601
|
-
|
1602
|
-
|
1603
|
-
|
1604
|
-
|
1605
|
-
|
1606
|
-
|
1607
|
-
|
1608
|
-
|
1609
|
-
|
1610
|
-
|
1611
|
-
|
1612
|
-
|
1613
|
-
|
1614
|
-
|
1615
|
-
|
1616
|
-
|
1617
|
-
|
1618
|
-
|
1619
|
-
|
1620
|
-
|
1621
|
-
|
1622
|
-
|
1623
|
-
|
1624
|
-
|
1625
|
-
|
1626
|
-
|
1627
|
-
|
1628
|
-
|
1629
|
-
|
1630
|
-
|
1631
|
-
|
1632
|
-
|
1633
|
-
|
1634
|
-
|
1635
|
-
|
1636
|
-
|
1637
|
-
|
930
|
+
- (void)loadAppOpenAd:(CDVInvokedUrlCommand *)command {
|
931
|
+
CDVPluginResult *pluginResult;
|
932
|
+
NSString *callbackId = command.callbackId;
|
933
|
+
NSDictionary *options = [command.arguments objectAtIndex:0];
|
934
|
+
NSString *adUnitId = [options valueForKey:@"adUnitId"];
|
935
|
+
BOOL autoShow = [[options valueForKey:@"autoShow"] boolValue];
|
936
|
+
auto_Show = autoShow;
|
937
|
+
adFormat = 1;
|
938
|
+
self.appOpenAd = nil;
|
939
|
+
if (adFormat == 1) {
|
940
|
+
dispatch_async(dispatch_get_main_queue(), ^{
|
941
|
+
GADRequest *request = [GADRequest request];
|
942
|
+
GADExtras *extras = [[GADExtras alloc] init];
|
943
|
+
// extras.additionalParameters = @{@"npa" : Npa}; // Deprecated
|
944
|
+
[request registerAdNetworkExtras:extras];
|
945
|
+
[GADAppOpenAd
|
946
|
+
loadWithAdUnitID:adUnitId
|
947
|
+
request:request
|
948
|
+
completionHandler:^(GADAppOpenAd *ad, NSError *error) {
|
949
|
+
if (error) {
|
950
|
+
[self fireEvent:@""
|
951
|
+
event:@"on.appOpenAd.failed.loaded"
|
952
|
+
withData:nil];
|
953
|
+
NSLog(@"Fa"
|
954
|
+
@"il"
|
955
|
+
@"ed"
|
956
|
+
@" t"
|
957
|
+
@"o "
|
958
|
+
@"lo"
|
959
|
+
@"ad"
|
960
|
+
@" A"
|
961
|
+
@"pp"
|
962
|
+
@" O"
|
963
|
+
@"pe"
|
964
|
+
@"n "
|
965
|
+
@"Ad"
|
966
|
+
@" a"
|
967
|
+
@"d "
|
968
|
+
@"wi"
|
969
|
+
@"th"
|
970
|
+
@" e"
|
971
|
+
@"rr"
|
972
|
+
@"or"
|
973
|
+
@": "
|
974
|
+
@"%"
|
975
|
+
@"@",
|
976
|
+
[error localizedDescription]);
|
977
|
+
return;
|
978
|
+
}
|
979
|
+
self.appOpenAd = ad;
|
980
|
+
self.appOpenAd.fullScreenContentDelegate = self;
|
981
|
+
[self fireEvent:@"" event:@"on.appOpenAd.loaded" withData:nil];
|
982
|
+
if (auto_Show) {
|
983
|
+
if (self.appOpenAd &&
|
984
|
+
[self.appOpenAd
|
985
|
+
canPresentFromRootViewController:self.viewController
|
986
|
+
error:nil]) {
|
987
|
+
[self.appOpenAd
|
988
|
+
presentFromRootViewController:self.viewController];
|
989
|
+
} else {
|
990
|
+
[self fireEvent:@""
|
991
|
+
event:@"on.appOpenAd.failed.show"
|
992
|
+
withData:nil];
|
993
|
+
}
|
994
|
+
}
|
995
|
+
}];
|
996
|
+
});
|
997
|
+
pluginResult = [CDVPluginResult resultWithStatus:CDVCommandStatus_OK];
|
998
|
+
}
|
999
|
+
[self.commandDelegate sendPluginResult:pluginResult callbackId:callbackId];
|
1638
1000
|
}
|
1639
|
-
- (void)
|
1640
|
-
|
1641
|
-
|
1642
|
-
|
1643
|
-
|
1644
|
-
|
1645
|
-
|
1646
|
-
|
1647
|
-
|
1648
|
-
|
1649
|
-
|
1650
|
-
|
1651
|
-
|
1652
|
-
|
1653
|
-
|
1654
|
-
|
1655
|
-
|
1656
|
-
|
1657
|
-
|
1658
|
-
|
1659
|
-
|
1660
|
-
|
1661
|
-
dispatch_async (
|
1662
|
-
dispatch_get_main_queue (),
|
1663
|
-
^{
|
1664
|
-
GADRequest
|
1665
|
-
*request
|
1666
|
-
= [GADRequest
|
1667
|
-
request];
|
1668
|
-
[GADRewardedInterstitialAd loadWithAdUnitID:
|
1669
|
-
adUnitId
|
1670
|
-
request:
|
1671
|
-
request
|
1672
|
-
completionHandler:
|
1673
|
-
^(GADRewardedInterstitialAd *ad, NSError
|
1674
|
-
*error) {
|
1675
|
-
if (error)
|
1676
|
-
{
|
1677
|
-
NSLog (
|
1678
|
-
@"Rewarded ad failed to load with error: %@",
|
1679
|
-
[error
|
1680
|
-
localizedDescription]);
|
1681
|
-
return;
|
1682
|
-
}
|
1683
|
-
self.rewardedInterstitialAd
|
1684
|
-
= ad;
|
1685
|
-
isAdSkip
|
1686
|
-
= 1;
|
1687
|
-
NSLog (
|
1688
|
-
@"Rewarded ad loaded.");
|
1689
|
-
self.rewardedInterstitialAd
|
1690
|
-
.fullScreenContentDelegate
|
1691
|
-
= self;
|
1692
|
-
[self
|
1693
|
-
fireEvent:
|
1694
|
-
@""
|
1695
|
-
event:
|
1696
|
-
@"on.rewardedInt.loaded"
|
1697
|
-
withData:
|
1698
|
-
nil];
|
1699
|
-
if (auto_Show)
|
1700
|
-
{
|
1701
|
-
if (self.rewardedInterstitialAd
|
1702
|
-
&&
|
1703
|
-
[self.rewardedInterstitialAd
|
1704
|
-
canPresentFromRootViewController:
|
1705
|
-
self.viewController
|
1706
|
-
error:
|
1707
|
-
nil])
|
1708
|
-
{
|
1709
|
-
[self.rewardedInterstitialAd presentFromRootViewController:
|
1710
|
-
self.viewController
|
1711
|
-
userDidEarnRewardHandler:^{
|
1712
|
-
GADAdReward
|
1713
|
-
*reward
|
1714
|
-
= self.rewardedInterstitialAd
|
1715
|
-
.adReward;
|
1716
|
-
[self
|
1717
|
-
fireEvent:
|
1718
|
-
@""
|
1719
|
-
event:
|
1720
|
-
@"on.rewardedInt.userEarnedReward"
|
1721
|
-
withData:
|
1722
|
-
nil];
|
1723
|
-
isAdSkip
|
1724
|
-
= 2;
|
1725
|
-
NSString
|
1726
|
-
*rewardMessage
|
1727
|
-
= [NSString
|
1728
|
-
stringWithFormat:
|
1729
|
-
@"Reward received with "
|
1730
|
-
@"currency %@ , amount %ld",
|
1731
|
-
reward
|
1732
|
-
.type,
|
1733
|
-
[reward.amount
|
1734
|
-
longValue]];
|
1735
|
-
NSLog (
|
1736
|
-
@"%@",
|
1737
|
-
rewardMessage);
|
1738
|
-
}];
|
1739
|
-
}
|
1740
|
-
else
|
1741
|
-
{
|
1742
|
-
[self
|
1743
|
-
fireEvent:
|
1744
|
-
@""
|
1745
|
-
event:
|
1746
|
-
@"on.rewardedInt.failed.show"
|
1747
|
-
withData:
|
1748
|
-
nil];
|
1749
|
-
}
|
1750
|
-
}
|
1751
|
-
}];
|
1752
|
-
});
|
1753
|
-
}
|
1754
|
-
pluginResult = [CDVPluginResult
|
1755
|
-
resultWithStatus:
|
1756
|
-
CDVCommandStatus_OK];
|
1757
|
-
[self.commandDelegate
|
1758
|
-
sendPluginResult:
|
1759
|
-
pluginResult
|
1760
|
-
callbackId:
|
1761
|
-
callbackId];
|
1001
|
+
- (void)showAppOpenAd:(CDVInvokedUrlCommand *)command {
|
1002
|
+
CDVPluginResult *pluginResult;
|
1003
|
+
NSString *callbackId = command.callbackId;
|
1004
|
+
if (self.appOpenAd &&
|
1005
|
+
[self.appOpenAd canPresentFromRootViewController:self.viewController
|
1006
|
+
error:nil]) {
|
1007
|
+
[self.appOpenAd presentFromRootViewController:self.viewController];
|
1008
|
+
pluginResult = [CDVPluginResult resultWithStatus:CDVCommandStatus_OK];
|
1009
|
+
} else {
|
1010
|
+
pluginResult =
|
1011
|
+
[CDVPluginResult resultWithStatus:CDVCommandStatus_ERROR];
|
1012
|
+
[self fireEvent:@""
|
1013
|
+
event:@"on."
|
1014
|
+
@"appO"
|
1015
|
+
@"penA"
|
1016
|
+
@"d."
|
1017
|
+
@"fail"
|
1018
|
+
@"ed."
|
1019
|
+
@"show"
|
1020
|
+
withData:nil];
|
1021
|
+
}
|
1022
|
+
[self.commandDelegate sendPluginResult:pluginResult callbackId:callbackId];
|
1762
1023
|
}
|
1763
|
-
- (void)
|
1764
|
-
|
1765
|
-
|
1766
|
-
|
1767
|
-
|
1768
|
-
|
1769
|
-
|
1770
|
-
|
1771
|
-
|
1772
|
-
|
1773
|
-
|
1774
|
-
|
1775
|
-
|
1776
|
-
|
1777
|
-
|
1778
|
-
|
1779
|
-
|
1780
|
-
|
1781
|
-
|
1782
|
-
|
1783
|
-
|
1784
|
-
|
1785
|
-
|
1786
|
-
|
1787
|
-
|
1788
|
-
|
1789
|
-
|
1790
|
-
|
1791
|
-
|
1792
|
-
|
1793
|
-
@"
|
1794
|
-
|
1795
|
-
|
1796
|
-
|
1797
|
-
|
1798
|
-
|
1799
|
-
|
1800
|
-
|
1801
|
-
|
1802
|
-
|
1803
|
-
|
1804
|
-
|
1805
|
-
|
1806
|
-
|
1807
|
-
|
1808
|
-
|
1809
|
-
|
1024
|
+
- (void)loadInterstitialAd:(CDVInvokedUrlCommand *)command {
|
1025
|
+
CDVPluginResult *pluginResult;
|
1026
|
+
NSString *callbackId = command.callbackId;
|
1027
|
+
NSDictionary *options = [command.arguments objectAtIndex:0];
|
1028
|
+
NSString *adUnitId = [options valueForKey:@"adUnitId"];
|
1029
|
+
BOOL autoShow = [[options valueForKey:@"autoShow"] boolValue];
|
1030
|
+
auto_Show = autoShow;
|
1031
|
+
adFormat = 2;
|
1032
|
+
if (adFormat == 2) {
|
1033
|
+
dispatch_async(dispatch_get_main_queue(), ^{
|
1034
|
+
GADRequest *request = [GADRequest request];
|
1035
|
+
[GADInterstitialAd
|
1036
|
+
loadWithAdUnitID:adUnitId
|
1037
|
+
request:request
|
1038
|
+
completionHandler:^(GADInterstitialAd *ad, NSError *error) {
|
1039
|
+
if (error) {
|
1040
|
+
NSLog(@"Fa"
|
1041
|
+
@"il"
|
1042
|
+
@"ed"
|
1043
|
+
@" t"
|
1044
|
+
@"o "
|
1045
|
+
@"lo"
|
1046
|
+
@"ad"
|
1047
|
+
@" i"
|
1048
|
+
@"nt"
|
1049
|
+
@"er"
|
1050
|
+
@"st"
|
1051
|
+
@"it"
|
1052
|
+
@"ia"
|
1053
|
+
@"l "
|
1054
|
+
@"ad"
|
1055
|
+
@" w"
|
1056
|
+
@"it"
|
1057
|
+
@"h "
|
1058
|
+
@"er"
|
1059
|
+
@"ro"
|
1060
|
+
@"r:"
|
1061
|
+
@" %"
|
1062
|
+
@"@",
|
1063
|
+
[error localizedDescription]);
|
1064
|
+
}
|
1065
|
+
self.interstitial = ad;
|
1066
|
+
self.interstitial.fullScreenContentDelegate = self;
|
1067
|
+
[self fireEvent:@""
|
1068
|
+
event:@"on.interstitial.loaded"
|
1069
|
+
withData:nil];
|
1070
|
+
if (auto_Show) {
|
1071
|
+
if (self.interstitial &&
|
1072
|
+
[self.interstitial
|
1073
|
+
canPresentFromRootViewController:self.viewController
|
1074
|
+
error:nil]) {
|
1075
|
+
[self.interstitial
|
1076
|
+
presentFromRootViewController:self.viewController];
|
1077
|
+
} else {
|
1078
|
+
[self fireEvent:@""
|
1079
|
+
event:@"on.interstitial.failed.show"
|
1080
|
+
withData:nil];
|
1081
|
+
}
|
1082
|
+
}
|
1810
1083
|
}];
|
1811
|
-
|
1812
|
-
|
1813
|
-
|
1814
|
-
|
1815
|
-
else
|
1816
|
-
{
|
1817
|
-
pluginResult = [CDVPluginResult
|
1818
|
-
resultWithStatus:
|
1819
|
-
CDVCommandStatus_ERROR];
|
1820
|
-
[self
|
1821
|
-
fireEvent:@""
|
1822
|
-
event:
|
1823
|
-
@"on."
|
1824
|
-
@"rewa"
|
1825
|
-
@"rded"
|
1826
|
-
@"Int."
|
1827
|
-
@"fail"
|
1828
|
-
@"ed."
|
1829
|
-
@"show"
|
1830
|
-
withData:nil];
|
1831
|
-
}
|
1832
|
-
[self.commandDelegate
|
1833
|
-
sendPluginResult:
|
1834
|
-
pluginResult
|
1835
|
-
callbackId:
|
1836
|
-
callbackId];
|
1084
|
+
});
|
1085
|
+
}
|
1086
|
+
pluginResult = [CDVPluginResult resultWithStatus:CDVCommandStatus_OK];
|
1087
|
+
[self.commandDelegate sendPluginResult:pluginResult callbackId:callbackId];
|
1837
1088
|
}
|
1838
|
-
- (void)
|
1839
|
-
|
1840
|
-
|
1841
|
-
|
1842
|
-
|
1843
|
-
|
1844
|
-
|
1845
|
-
|
1846
|
-
|
1847
|
-
|
1848
|
-
|
1849
|
-
|
1850
|
-
|
1851
|
-
|
1852
|
-
|
1853
|
-
|
1854
|
-
|
1855
|
-
|
1856
|
-
|
1857
|
-
|
1858
|
-
|
1859
|
-
|
1860
|
-
dispatch_get_main_queue (),
|
1861
|
-
^{
|
1862
|
-
GADRequest
|
1863
|
-
*request
|
1864
|
-
= [GADRequest
|
1865
|
-
request];
|
1866
|
-
[GADRewardedAd loadWithAdUnitID:
|
1867
|
-
adUnitId
|
1868
|
-
request:
|
1869
|
-
request
|
1870
|
-
completionHandler:^(
|
1871
|
-
GADRewardedAd *ad, NSError
|
1872
|
-
*error) {
|
1873
|
-
if (error)
|
1874
|
-
{
|
1875
|
-
NSLog (
|
1876
|
-
@"Rewarded ad failed to load with error: %@",
|
1877
|
-
[error
|
1878
|
-
localizedDescription]);
|
1879
|
-
return;
|
1880
|
-
}
|
1881
|
-
self.rewardedAd
|
1882
|
-
= ad;
|
1883
|
-
NSLog (
|
1884
|
-
@"Rewarded ad loaded.");
|
1885
|
-
isAdSkip
|
1886
|
-
= 0;
|
1887
|
-
self.rewardedAd
|
1888
|
-
.fullScreenContentDelegate
|
1889
|
-
= self;
|
1890
|
-
[self
|
1891
|
-
fireEvent:
|
1892
|
-
@""
|
1893
|
-
event:
|
1894
|
-
@"on.rewarded.loaded"
|
1895
|
-
withData:
|
1896
|
-
nil];
|
1897
|
-
if (auto_Show)
|
1898
|
-
{
|
1899
|
-
if (self.rewardedAd
|
1900
|
-
&&
|
1901
|
-
[self.rewardedAd
|
1902
|
-
canPresentFromRootViewController:
|
1903
|
-
self.viewController
|
1904
|
-
error:
|
1905
|
-
nil])
|
1906
|
-
{
|
1907
|
-
[self.rewardedAd
|
1908
|
-
presentFromRootViewController:
|
1909
|
-
self.viewController
|
1910
|
-
userDidEarnRewardHandler:^{
|
1911
|
-
GADAdReward
|
1912
|
-
*reward
|
1913
|
-
= self.rewardedAd
|
1914
|
-
.adReward;
|
1915
|
-
[self
|
1916
|
-
fireEvent:
|
1917
|
-
@""
|
1918
|
-
event:
|
1919
|
-
@"on.reward.userEarnedReward"
|
1920
|
-
withData:
|
1921
|
-
nil];
|
1922
|
-
isAdSkip
|
1923
|
-
= 2;
|
1924
|
-
NSString
|
1925
|
-
*rewardMessage
|
1926
|
-
= [NSString
|
1927
|
-
stringWithFormat:
|
1928
|
-
@"Reward received with currency "
|
1929
|
-
@"%@ , amount %lf",
|
1930
|
-
reward
|
1931
|
-
.type,
|
1932
|
-
[reward.amount
|
1933
|
-
doubleValue]];
|
1934
|
-
NSLog (
|
1935
|
-
@"%@",
|
1936
|
-
rewardMessage);
|
1937
|
-
}];
|
1938
|
-
}
|
1939
|
-
else
|
1940
|
-
{
|
1941
|
-
[self
|
1942
|
-
fireEvent:
|
1943
|
-
@""
|
1944
|
-
event:
|
1945
|
-
@"on.rewarded.failed.show"
|
1946
|
-
withData:
|
1947
|
-
nil];
|
1948
|
-
}
|
1949
|
-
}
|
1950
|
-
}];
|
1951
|
-
});
|
1952
|
-
}
|
1953
|
-
pluginResult = [CDVPluginResult
|
1954
|
-
resultWithStatus:
|
1955
|
-
CDVCommandStatus_OK];
|
1956
|
-
[self.commandDelegate
|
1957
|
-
sendPluginResult:
|
1958
|
-
pluginResult
|
1959
|
-
callbackId:
|
1960
|
-
callbackId];
|
1089
|
+
- (void)showInterstitialAd:(CDVInvokedUrlCommand *)command {
|
1090
|
+
CDVPluginResult *pluginResult;
|
1091
|
+
NSString *callbackId = command.callbackId;
|
1092
|
+
if (self.interstitial &&
|
1093
|
+
[self.interstitial canPresentFromRootViewController:self.viewController
|
1094
|
+
error:nil]) {
|
1095
|
+
[self.interstitial presentFromRootViewController:self.viewController];
|
1096
|
+
pluginResult = [CDVPluginResult resultWithStatus:CDVCommandStatus_OK];
|
1097
|
+
} else {
|
1098
|
+
pluginResult =
|
1099
|
+
[CDVPluginResult resultWithStatus:CDVCommandStatus_ERROR];
|
1100
|
+
[self fireEvent:@""
|
1101
|
+
event:@"on."
|
1102
|
+
@"inte"
|
1103
|
+
@"rsti"
|
1104
|
+
@"tial"
|
1105
|
+
@".fai"
|
1106
|
+
@"led."
|
1107
|
+
@"show"
|
1108
|
+
withData:nil];
|
1109
|
+
}
|
1110
|
+
[self.commandDelegate sendPluginResult:pluginResult callbackId:callbackId];
|
1961
1111
|
}
|
1962
|
-
- (void)
|
1963
|
-
|
1964
|
-
|
1965
|
-
|
1966
|
-
|
1967
|
-
|
1968
|
-
|
1969
|
-
|
1970
|
-
|
1971
|
-
|
1972
|
-
|
1973
|
-
|
1974
|
-
|
1975
|
-
|
1976
|
-
|
1977
|
-
|
1978
|
-
|
1979
|
-
|
1980
|
-
|
1981
|
-
|
1982
|
-
|
1983
|
-
|
1984
|
-
|
1985
|
-
|
1986
|
-
|
1987
|
-
|
1988
|
-
|
1989
|
-
|
1990
|
-
|
1991
|
-
|
1992
|
-
|
1993
|
-
|
1994
|
-
|
1995
|
-
|
1996
|
-
|
1997
|
-
|
1998
|
-
|
1999
|
-
|
2000
|
-
|
2001
|
-
|
2002
|
-
|
2003
|
-
|
2004
|
-
|
1112
|
+
- (void)loadRewardedInterstitialAd:(CDVInvokedUrlCommand *)command {
|
1113
|
+
CDVPluginResult *pluginResult;
|
1114
|
+
NSString *callbackId = command.callbackId;
|
1115
|
+
|
1116
|
+
NSDictionary *options = [command.arguments objectAtIndex:0];
|
1117
|
+
NSString *adUnitId = [options valueForKey:@"adUnitId"];
|
1118
|
+
BOOL autoShow = [[options valueForKey:@"autoShow"] boolValue];
|
1119
|
+
|
1120
|
+
auto_Show = autoShow;
|
1121
|
+
adFormat = 4;
|
1122
|
+
if (adFormat == 4) {
|
1123
|
+
dispatch_async(dispatch_get_main_queue(), ^{
|
1124
|
+
GADRequest *request = [GADRequest request];
|
1125
|
+
[GADRewardedInterstitialAd
|
1126
|
+
loadWithAdUnitID:adUnitId
|
1127
|
+
request:request
|
1128
|
+
completionHandler:^(GADRewardedInterstitialAd *ad,
|
1129
|
+
NSError *error) {
|
1130
|
+
if (error) {
|
1131
|
+
NSLog(@"Rewarded ad failed to load with error: %@",
|
1132
|
+
[error localizedDescription]);
|
1133
|
+
return;
|
1134
|
+
}
|
1135
|
+
self.rewardedInterstitialAd = ad;
|
1136
|
+
isAdSkip = 1;
|
1137
|
+
NSLog(@"Rewarded ad loaded.");
|
1138
|
+
self.rewardedInterstitialAd.fullScreenContentDelegate = self;
|
1139
|
+
[self fireEvent:@""
|
1140
|
+
event:@"on.rewardedInt.loaded"
|
1141
|
+
withData:nil];
|
1142
|
+
if (auto_Show) {
|
1143
|
+
if (self.rewardedInterstitialAd &&
|
1144
|
+
[self.rewardedInterstitialAd
|
1145
|
+
canPresentFromRootViewController:self.viewController
|
1146
|
+
error:nil]) {
|
1147
|
+
[self.rewardedInterstitialAd
|
1148
|
+
presentFromRootViewController:self.viewController
|
1149
|
+
userDidEarnRewardHandler:^{
|
1150
|
+
GADAdReward *reward =
|
1151
|
+
self.rewardedInterstitialAd.adReward;
|
1152
|
+
[self fireEvent:@""
|
1153
|
+
event:@"on.rewardedInt."
|
1154
|
+
@"userEarnedReward"
|
1155
|
+
withData:nil];
|
1156
|
+
isAdSkip = 2;
|
1157
|
+
NSString *rewardMessage = [NSString
|
1158
|
+
stringWithFormat:
|
1159
|
+
@"Reward received with "
|
1160
|
+
@"currency %@ , amount %ld",
|
1161
|
+
reward.type,
|
1162
|
+
[reward.amount longValue]];
|
1163
|
+
NSLog(@"%@", rewardMessage);
|
1164
|
+
}];
|
1165
|
+
} else {
|
1166
|
+
[self fireEvent:@""
|
1167
|
+
event:@"on.rewardedInt.failed.show"
|
1168
|
+
withData:nil];
|
1169
|
+
}
|
1170
|
+
}
|
1171
|
+
}];
|
1172
|
+
});
|
1173
|
+
}
|
1174
|
+
pluginResult = [CDVPluginResult resultWithStatus:CDVCommandStatus_OK];
|
1175
|
+
[self.commandDelegate sendPluginResult:pluginResult callbackId:callbackId];
|
1176
|
+
}
|
1177
|
+
- (void)showRewardedInterstitialAd:(CDVInvokedUrlCommand *)command {
|
1178
|
+
CDVPluginResult *pluginResult;
|
1179
|
+
NSString *callbackId = command.callbackId;
|
1180
|
+
if (self.rewardedInterstitialAd &&
|
1181
|
+
[self.rewardedInterstitialAd
|
1182
|
+
canPresentFromRootViewController:self.viewController
|
1183
|
+
error:nil]) {
|
1184
|
+
[self.rewardedInterstitialAd
|
1185
|
+
presentFromRootViewController:self.viewController
|
1186
|
+
userDidEarnRewardHandler:^{
|
1187
|
+
GADAdReward *reward = self.rewardedInterstitialAd.adReward;
|
1188
|
+
[self fireEvent:@""
|
1189
|
+
event:@"on.rewardedInt.userEarnedReward"
|
1190
|
+
withData:nil];
|
1191
|
+
isAdSkip = 2;
|
1192
|
+
NSString *rewardMessage = [NSString
|
1193
|
+
stringWithFormat:@"Reward received with "
|
1194
|
+
@"currency %@ , amount %ld",
|
1195
|
+
reward.type, [reward.amount longValue]];
|
1196
|
+
NSLog(@"%"
|
2005
1197
|
@"@",
|
2006
1198
|
rewardMessage);
|
1199
|
+
}];
|
1200
|
+
pluginResult = [CDVPluginResult resultWithStatus:CDVCommandStatus_OK];
|
1201
|
+
} else {
|
1202
|
+
pluginResult =
|
1203
|
+
[CDVPluginResult resultWithStatus:CDVCommandStatus_ERROR];
|
1204
|
+
[self fireEvent:@""
|
1205
|
+
event:@"on."
|
1206
|
+
@"rewa"
|
1207
|
+
@"rded"
|
1208
|
+
@"Int."
|
1209
|
+
@"fail"
|
1210
|
+
@"ed."
|
1211
|
+
@"show"
|
1212
|
+
withData:nil];
|
1213
|
+
}
|
1214
|
+
[self.commandDelegate sendPluginResult:pluginResult callbackId:callbackId];
|
1215
|
+
}
|
1216
|
+
- (void)loadRewardedAd:(CDVInvokedUrlCommand *)command {
|
1217
|
+
CDVPluginResult *pluginResult;
|
1218
|
+
NSString *callbackId = command.callbackId;
|
1219
|
+
NSDictionary *options = [command.arguments objectAtIndex:0];
|
1220
|
+
NSString *adUnitId = [options valueForKey:@"adUnitId"];
|
1221
|
+
BOOL autoShow = [[options valueForKey:@"autoShow"] boolValue];
|
1222
|
+
auto_Show = autoShow;
|
1223
|
+
adFormat = 3;
|
1224
|
+
if (adFormat == 3) {
|
1225
|
+
dispatch_async(dispatch_get_main_queue(), ^{
|
1226
|
+
GADRequest *request = [GADRequest request];
|
1227
|
+
[GADRewardedAd
|
1228
|
+
loadWithAdUnitID:adUnitId
|
1229
|
+
request:request
|
1230
|
+
completionHandler:^(GADRewardedAd *ad, NSError *error) {
|
1231
|
+
if (error) {
|
1232
|
+
NSLog(@"Rewarded ad failed to load with error: %@",
|
1233
|
+
[error localizedDescription]);
|
1234
|
+
return;
|
1235
|
+
}
|
1236
|
+
self.rewardedAd = ad;
|
1237
|
+
NSLog(@"Rewarded ad loaded.");
|
1238
|
+
isAdSkip = 0;
|
1239
|
+
self.rewardedAd.fullScreenContentDelegate = self;
|
1240
|
+
[self fireEvent:@"" event:@"on.rewarded.loaded" withData:nil];
|
1241
|
+
if (auto_Show) {
|
1242
|
+
if (self.rewardedAd &&
|
1243
|
+
[self.rewardedAd
|
1244
|
+
canPresentFromRootViewController:self.viewController
|
1245
|
+
error:nil]) {
|
1246
|
+
[self.rewardedAd
|
1247
|
+
presentFromRootViewController:self.viewController
|
1248
|
+
userDidEarnRewardHandler:^{
|
1249
|
+
GADAdReward *reward =
|
1250
|
+
self.rewardedAd.adReward;
|
1251
|
+
[self fireEvent:@""
|
1252
|
+
event:@"on.reward.userEarnedReward"
|
1253
|
+
withData:nil];
|
1254
|
+
isAdSkip = 2;
|
1255
|
+
NSString *rewardMessage = [NSString
|
1256
|
+
stringWithFormat:
|
1257
|
+
@"Reward received with currency "
|
1258
|
+
@"%@ , amount %lf",
|
1259
|
+
reward.type,
|
1260
|
+
[reward.amount doubleValue]];
|
1261
|
+
NSLog(@"%@", rewardMessage);
|
1262
|
+
}];
|
1263
|
+
} else {
|
1264
|
+
[self fireEvent:@""
|
1265
|
+
event:@"on.rewarded.failed.show"
|
1266
|
+
withData:nil];
|
1267
|
+
}
|
1268
|
+
}
|
2007
1269
|
}];
|
2008
|
-
|
2009
|
-
|
2010
|
-
|
2011
|
-
|
2012
|
-
else
|
2013
|
-
{
|
2014
|
-
pluginResult = [CDVPluginResult
|
2015
|
-
resultWithStatus:
|
2016
|
-
CDVCommandStatus_ERROR];
|
2017
|
-
[self
|
2018
|
-
fireEvent:@""
|
2019
|
-
event:
|
2020
|
-
@"on."
|
2021
|
-
@"rewa"
|
2022
|
-
@"rded"
|
2023
|
-
@".fai"
|
2024
|
-
@"led."
|
2025
|
-
@"show"
|
2026
|
-
withData:nil];
|
2027
|
-
}
|
2028
|
-
[self.commandDelegate
|
2029
|
-
sendPluginResult:
|
2030
|
-
pluginResult
|
2031
|
-
callbackId:
|
2032
|
-
callbackId];
|
1270
|
+
});
|
1271
|
+
}
|
1272
|
+
pluginResult = [CDVPluginResult resultWithStatus:CDVCommandStatus_OK];
|
1273
|
+
[self.commandDelegate sendPluginResult:pluginResult callbackId:callbackId];
|
2033
1274
|
}
|
2034
|
-
- (void)
|
2035
|
-
|
2036
|
-
|
2037
|
-
|
2038
|
-
|
2039
|
-
|
2040
|
-
|
2041
|
-
|
2042
|
-
|
2043
|
-
|
2044
|
-
|
2045
|
-
|
2046
|
-
|
2047
|
-
|
2048
|
-
|
2049
|
-
|
2050
|
-
|
2051
|
-
|
2052
|
-
|
2053
|
-
|
2054
|
-
|
2055
|
-
|
2056
|
-
|
2057
|
-
|
2058
|
-
|
2059
|
-
|
2060
|
-
|
2061
|
-
|
2062
|
-
|
2063
|
-
|
2064
|
-
|
2065
|
-
|
2066
|
-
|
2067
|
-
|
2068
|
-
|
2069
|
-
|
2070
|
-
@"window."
|
2071
|
-
@"dispatch"
|
2072
|
-
@"Event("
|
2073
|
-
@"evt);",
|
2074
|
-
eventName];
|
2075
|
-
}
|
2076
|
-
else if (jsonStr &&
|
2077
|
-
[jsonStr
|
2078
|
-
length]
|
2079
|
-
> 0)
|
2080
|
-
{
|
2081
|
-
js = [NSString
|
2082
|
-
stringWithFormat:
|
2083
|
-
@"javascri"
|
2084
|
-
@"pt:"
|
2085
|
-
@"cordova."
|
2086
|
-
@"fireDocu"
|
2087
|
-
@"mentEven"
|
2088
|
-
@"t('%@',%"
|
2089
|
-
@"@);",
|
2090
|
-
eventName,
|
2091
|
-
jsonStr];
|
2092
|
-
}
|
2093
|
-
else
|
2094
|
-
{
|
2095
|
-
js = [NSString
|
2096
|
-
stringWithFormat:
|
2097
|
-
@"javascri"
|
2098
|
-
@"pt:"
|
2099
|
-
@"cordova."
|
2100
|
-
@"fireDocu"
|
2101
|
-
@"mentEven"
|
2102
|
-
@"t('%@')"
|
2103
|
-
@";",
|
2104
|
-
eventName];
|
2105
|
-
}
|
2106
|
-
[self.commandDelegate
|
2107
|
-
evalJs:js];
|
1275
|
+
- (void)showRewardedAd:(CDVInvokedUrlCommand *)command {
|
1276
|
+
CDVPluginResult *pluginResult;
|
1277
|
+
NSString *callbackId = command.callbackId;
|
1278
|
+
if (self.rewardedAd &&
|
1279
|
+
[self.rewardedAd canPresentFromRootViewController:self.viewController
|
1280
|
+
error:nil]) {
|
1281
|
+
[self.rewardedAd
|
1282
|
+
presentFromRootViewController:self.viewController
|
1283
|
+
userDidEarnRewardHandler:^{
|
1284
|
+
GADAdReward *reward = self.rewardedAd.adReward;
|
1285
|
+
[self fireEvent:@""
|
1286
|
+
event:@"on.reward.userEarnedReward"
|
1287
|
+
withData:nil];
|
1288
|
+
isAdSkip = 2;
|
1289
|
+
NSString *rewardMessage = [NSString
|
1290
|
+
stringWithFormat:
|
1291
|
+
@"Reward received with currency %@ , amount %lf",
|
1292
|
+
reward.type, [reward.amount doubleValue]];
|
1293
|
+
NSLog(@"%"
|
1294
|
+
@"@",
|
1295
|
+
rewardMessage);
|
1296
|
+
}];
|
1297
|
+
pluginResult = [CDVPluginResult resultWithStatus:CDVCommandStatus_OK];
|
1298
|
+
} else {
|
1299
|
+
pluginResult =
|
1300
|
+
[CDVPluginResult resultWithStatus:CDVCommandStatus_ERROR];
|
1301
|
+
[self fireEvent:@""
|
1302
|
+
event:@"on."
|
1303
|
+
@"rewa"
|
1304
|
+
@"rded"
|
1305
|
+
@".fai"
|
1306
|
+
@"led."
|
1307
|
+
@"show"
|
1308
|
+
withData:nil];
|
1309
|
+
}
|
1310
|
+
[self.commandDelegate sendPluginResult:pluginResult callbackId:callbackId];
|
2108
1311
|
}
|
2109
|
-
|
2110
|
-
|
2111
|
-
|
2112
|
-
|
2113
|
-
|
2114
|
-
|
2115
|
-
|
2116
|
-
|
2117
|
-
|
2118
|
-
|
1312
|
+
- (void)fireEvent:(NSString *)obj
|
1313
|
+
event:(NSString *)eventName
|
1314
|
+
withData:(NSString *)jsonStr {
|
1315
|
+
NSString *js;
|
1316
|
+
if (obj && [obj isEqualToString:@"windo"
|
1317
|
+
@"w"]) {
|
1318
|
+
js = [NSString stringWithFormat:@"var "
|
1319
|
+
@"evt="
|
1320
|
+
@"document"
|
1321
|
+
@".createE"
|
1322
|
+
@"vent("
|
1323
|
+
@"\"UIEven"
|
1324
|
+
@"ts\");"
|
1325
|
+
@"evt."
|
1326
|
+
@"initUIEv"
|
1327
|
+
@"ent("
|
1328
|
+
@"\"%@\","
|
1329
|
+
@"true,"
|
1330
|
+
@"false,"
|
1331
|
+
@"window,"
|
1332
|
+
@"0);"
|
1333
|
+
@"window."
|
1334
|
+
@"dispatch"
|
1335
|
+
@"Event("
|
1336
|
+
@"evt);",
|
1337
|
+
eventName];
|
1338
|
+
} else if (jsonStr && [jsonStr length] > 0) {
|
1339
|
+
js = [NSString stringWithFormat:@"javascri"
|
1340
|
+
@"pt:"
|
1341
|
+
@"cordova."
|
1342
|
+
@"fireDocu"
|
1343
|
+
@"mentEven"
|
1344
|
+
@"t('%@',%"
|
1345
|
+
@"@);",
|
1346
|
+
eventName, jsonStr];
|
1347
|
+
} else {
|
1348
|
+
js = [NSString stringWithFormat:@"javascri"
|
1349
|
+
@"pt:"
|
1350
|
+
@"cordova."
|
1351
|
+
@"fireDocu"
|
1352
|
+
@"mentEven"
|
1353
|
+
@"t('%@')"
|
1354
|
+
@";",
|
1355
|
+
eventName];
|
1356
|
+
}
|
1357
|
+
[self.commandDelegate evalJs:js];
|
2119
1358
|
}
|
2120
1359
|
|
2121
|
-
- (NSString *)
|
2122
|
-
|
2123
|
-
|
2124
|
-
CC_MD5_CTX
|
2125
|
-
md5Context;
|
2126
|
-
CC_MD5_Init (
|
2127
|
-
&md5Context);
|
2128
|
-
NSData *data = [string
|
2129
|
-
dataUsingEncoding:
|
2130
|
-
NSUTF8StringEncoding];
|
2131
|
-
CC_MD5_Update (
|
2132
|
-
&md5Context,
|
2133
|
-
[data bytes],
|
2134
|
-
(CC_LONG)
|
2135
|
-
[data
|
2136
|
-
length]);
|
2137
|
-
unsigned char digest
|
2138
|
-
[CC_MD5_DIGEST_LENGTH];
|
2139
|
-
CC_MD5_Final (
|
2140
|
-
digest,
|
2141
|
-
&md5Context);
|
2142
|
-
|
2143
|
-
NSMutableString
|
2144
|
-
*hexString
|
2145
|
-
= [NSMutableString
|
2146
|
-
stringWithCapacity:
|
2147
|
-
(CC_MD5_DIGEST_LENGTH
|
2148
|
-
* 2)];
|
2149
|
-
for (
|
2150
|
-
int i = 0;
|
2151
|
-
i
|
2152
|
-
< CC_MD5_DIGEST_LENGTH;
|
2153
|
-
i++)
|
2154
|
-
{
|
2155
|
-
[hexString
|
2156
|
-
appendFormat:
|
2157
|
-
@"%02x",
|
2158
|
-
digest[i]];
|
2159
|
-
}
|
2160
|
-
|
2161
|
-
return hexString;
|
1360
|
+
- (NSString *)__getAdMobDeviceId {
|
1361
|
+
NSUUID *adid = [[ASIdentifierManager sharedManager] advertisingIdentifier];
|
1362
|
+
return [self __md5:adid.UUIDString];
|
2162
1363
|
}
|
2163
1364
|
|
2164
|
-
|
2165
|
-
|
2166
|
-
|
2167
|
-
|
2168
|
-
|
2169
|
-
|
2170
|
-
|
2171
|
-
|
2172
|
-
|
2173
|
-
|
2174
|
-
|
2175
|
-
|
2176
|
-
|
2177
|
-
@".load"
|
2178
|
-
withData:nil];
|
2179
|
-
NSLog (
|
2180
|
-
@"bannerViewDidR"
|
2181
|
-
@"eceiveAd");
|
2182
|
-
if (auto_Show)
|
2183
|
-
{
|
2184
|
-
if (self.bannerView)
|
2185
|
-
{
|
2186
|
-
[self
|
2187
|
-
addBannerViewToView:
|
2188
|
-
command];
|
2189
|
-
self.bannerView
|
2190
|
-
.hidden
|
2191
|
-
= NO;
|
1365
|
+
- (NSString *)__md5:(NSString *)string {
|
1366
|
+
CC_MD5_CTX
|
1367
|
+
md5Context;
|
1368
|
+
CC_MD5_Init(&md5Context);
|
1369
|
+
NSData *data = [string dataUsingEncoding:NSUTF8StringEncoding];
|
1370
|
+
CC_MD5_Update(&md5Context, [data bytes], (CC_LONG)[data length]);
|
1371
|
+
unsigned char digest[CC_MD5_DIGEST_LENGTH];
|
1372
|
+
CC_MD5_Final(digest, &md5Context);
|
1373
|
+
|
1374
|
+
NSMutableString *hexString =
|
1375
|
+
[NSMutableString stringWithCapacity:(CC_MD5_DIGEST_LENGTH * 2)];
|
1376
|
+
for (int i = 0; i < CC_MD5_DIGEST_LENGTH; i++) {
|
1377
|
+
[hexString appendFormat:@"%02x", digest[i]];
|
2192
1378
|
}
|
2193
|
-
|
2194
|
-
|
2195
|
-
{
|
2196
|
-
[self
|
2197
|
-
fireEvent:@""
|
2198
|
-
event:
|
2199
|
-
@"on."
|
2200
|
-
@"bann"
|
2201
|
-
@"er."
|
2202
|
-
@"fail"
|
2203
|
-
@"ed."
|
2204
|
-
@"show"
|
2205
|
-
withData:nil];
|
2206
|
-
}
|
1379
|
+
|
1380
|
+
return hexString;
|
2207
1381
|
}
|
2208
|
-
|
2209
|
-
|
2210
|
-
|
2211
|
-
|
2212
|
-
|
2213
|
-
|
2214
|
-
|
2215
|
-
|
2216
|
-
|
2217
|
-
|
2218
|
-
|
2219
|
-
|
2220
|
-
|
2221
|
-
|
2222
|
-
|
2223
|
-
|
2224
|
-
|
2225
|
-
|
2226
|
-
@"
|
2227
|
-
@"
|
2228
|
-
|
2229
|
-
|
2230
|
-
|
1382
|
+
|
1383
|
+
#pragma mark GADBannerViewDelegate implementation
|
1384
|
+
- (void)bannerViewDidReceiveAd:(GADBannerView *)bannerView {
|
1385
|
+
|
1386
|
+
NSString *collapsibleStatus = bannerView.isCollapsible ? @"collapsible" : @"not collapsible";
|
1387
|
+
NSDictionary *eventData = @{ @"collapsible": collapsibleStatus };
|
1388
|
+
NSError *error;
|
1389
|
+
NSData *jsonData = [NSJSONSerialization dataWithJSONObject:eventData options:0 error:&error];
|
1390
|
+
|
1391
|
+
if (!jsonData) {
|
1392
|
+
NSLog(@"Failed to serialize event data: %@", error);
|
1393
|
+
} else {
|
1394
|
+
NSString *jsonString = [[NSString alloc] initWithData:jsonData encoding:NSUTF8StringEncoding];
|
1395
|
+
[self fireEvent:@"" event:@"on.is.collapsible" withData:jsonString];
|
1396
|
+
}
|
1397
|
+
|
1398
|
+
[self fireEvent:@""
|
1399
|
+
event:@"on."
|
1400
|
+
@"banner"
|
1401
|
+
@".load"
|
1402
|
+
withData:nil];
|
1403
|
+
NSLog(@"bannerViewDidR"
|
1404
|
+
@"eceiveAd");
|
1405
|
+
if (auto_Show) {
|
1406
|
+
if (self.bannerView) {
|
1407
|
+
[self addBannerViewToView:command];
|
1408
|
+
self.bannerView.hidden = NO;
|
1409
|
+
}
|
1410
|
+
} else {
|
1411
|
+
[self fireEvent:@""
|
1412
|
+
event:@"on."
|
1413
|
+
@"bann"
|
1414
|
+
@"er."
|
1415
|
+
@"fail"
|
1416
|
+
@"ed."
|
1417
|
+
@"show"
|
1418
|
+
withData:nil];
|
1419
|
+
}
|
2231
1420
|
}
|
2232
|
-
- (void)
|
2233
|
-
|
2234
|
-
|
2235
|
-
|
2236
|
-
|
2237
|
-
|
2238
|
-
|
2239
|
-
|
2240
|
-
|
2241
|
-
|
2242
|
-
|
2243
|
-
|
2244
|
-
|
2245
|
-
withData:nil];
|
2246
|
-
NSLog (@"bannerViewD"
|
2247
|
-
@"idRecordImp"
|
2248
|
-
@"ression");
|
1421
|
+
- (void)bannerView:(GADBannerView *)bannerView
|
1422
|
+
didFailToReceiveAdWithError:(NSError *)error {
|
1423
|
+
[self fireEvent:@""
|
1424
|
+
event:@"on."
|
1425
|
+
@"banner"
|
1426
|
+
@".faile"
|
1427
|
+
@"d.load"
|
1428
|
+
withData:nil];
|
1429
|
+
NSLog(@"bannerView:"
|
1430
|
+
@"didFailToRecei"
|
1431
|
+
@"veAdWithError:"
|
1432
|
+
@" %@",
|
1433
|
+
[error localizedDescription]);
|
2249
1434
|
}
|
2250
|
-
- (void)
|
2251
|
-
|
2252
|
-
|
2253
|
-
|
2254
|
-
|
2255
|
-
|
2256
|
-
|
2257
|
-
|
2258
|
-
|
2259
|
-
|
2260
|
-
@"banner"
|
2261
|
-
@".open"
|
2262
|
-
withData:nil];
|
2263
|
-
NSLog (@"bannerViewW"
|
2264
|
-
@"illPresentS"
|
2265
|
-
@"creen");
|
1435
|
+
- (void)bannerViewDidRecordImpression:(GADBannerView *)bannerView {
|
1436
|
+
[self fireEvent:@""
|
1437
|
+
event:@"on."
|
1438
|
+
@"banner"
|
1439
|
+
@".impre"
|
1440
|
+
@"ssion"
|
1441
|
+
withData:nil];
|
1442
|
+
NSLog(@"bannerViewD"
|
1443
|
+
@"idRecordImp"
|
1444
|
+
@"ression");
|
2266
1445
|
}
|
2267
|
-
- (void)
|
2268
|
-
|
2269
|
-
|
2270
|
-
|
2271
|
-
|
2272
|
-
|
2273
|
-
|
2274
|
-
|
2275
|
-
|
2276
|
-
@"on."
|
2277
|
-
@"banner"
|
2278
|
-
@".close"
|
2279
|
-
withData:nil];
|
2280
|
-
NSLog (@"bannerViewW"
|
2281
|
-
@"illDismissS"
|
2282
|
-
@"creen");
|
1446
|
+
- (void)bannerViewWillPresentScreen:(GADBannerView *)bannerView {
|
1447
|
+
[self fireEvent:@""
|
1448
|
+
event:@"on."
|
1449
|
+
@"banner"
|
1450
|
+
@".open"
|
1451
|
+
withData:nil];
|
1452
|
+
NSLog(@"bannerViewW"
|
1453
|
+
@"illPresentS"
|
1454
|
+
@"creen");
|
2283
1455
|
}
|
2284
|
-
- (void)
|
2285
|
-
|
2286
|
-
|
2287
|
-
|
2288
|
-
|
2289
|
-
|
2290
|
-
|
2291
|
-
|
2292
|
-
|
2293
|
-
@"on."
|
2294
|
-
@"banner"
|
2295
|
-
@".did."
|
2296
|
-
@"dismis"
|
2297
|
-
@"s"
|
2298
|
-
withData:nil];
|
2299
|
-
NSLog (
|
2300
|
-
@"bannerViewDidD"
|
2301
|
-
@"ismissScreen");
|
1456
|
+
- (void)bannerViewWillDismissScreen:(GADBannerView *)bannerView {
|
1457
|
+
[self fireEvent:@""
|
1458
|
+
event:@"on."
|
1459
|
+
@"banner"
|
1460
|
+
@".close"
|
1461
|
+
withData:nil];
|
1462
|
+
NSLog(@"bannerViewW"
|
1463
|
+
@"illDismissS"
|
1464
|
+
@"creen");
|
2302
1465
|
}
|
2303
|
-
|
2304
|
-
|
2305
|
-
|
2306
|
-
|
2307
|
-
|
2308
|
-
|
2309
|
-
|
2310
|
-
|
2311
|
-
|
2312
|
-
|
2313
|
-
event:
|
2314
|
-
@"on."
|
2315
|
-
@"appO"
|
2316
|
-
@"penA"
|
2317
|
-
@"d."
|
2318
|
-
@"show"
|
2319
|
-
withData:nil];
|
2320
|
-
NSLog (
|
2321
|
-
@"Ad will "
|
2322
|
-
@"present "
|
2323
|
-
@"full screen "
|
2324
|
-
@"content App "
|
2325
|
-
@"Open Ad.");
|
2326
|
-
}
|
2327
|
-
else if (adFormat
|
2328
|
-
== 2)
|
2329
|
-
{
|
2330
|
-
[self
|
2331
|
-
fireEvent:@""
|
2332
|
-
event:
|
2333
|
-
@"on."
|
2334
|
-
@"inte"
|
2335
|
-
@"rsti"
|
2336
|
-
@"tial"
|
2337
|
-
@".sho"
|
2338
|
-
@"w"
|
2339
|
-
withData:nil];
|
2340
|
-
[self
|
2341
|
-
fireEvent:@""
|
2342
|
-
event:
|
2343
|
-
@"onPr"
|
2344
|
-
@"esen"
|
2345
|
-
@"tAd"
|
2346
|
-
withData:nil];
|
2347
|
-
NSLog (
|
2348
|
-
@"Ad will "
|
2349
|
-
@"present "
|
2350
|
-
@"full screen "
|
2351
|
-
@"content "
|
2352
|
-
@"interstitial"
|
2353
|
-
@".");
|
2354
|
-
}
|
2355
|
-
else if (adFormat
|
2356
|
-
== 3)
|
2357
|
-
{
|
2358
|
-
[self
|
2359
|
-
fireEvent:@""
|
2360
|
-
event:
|
2361
|
-
@"on."
|
2362
|
-
@"rewa"
|
2363
|
-
@"rded"
|
2364
|
-
@".sho"
|
2365
|
-
@"w"
|
2366
|
-
withData:nil];
|
2367
|
-
isAdSkip = 1;
|
2368
|
-
NSLog (
|
2369
|
-
@"Ad will "
|
2370
|
-
@"present "
|
2371
|
-
@"full screen "
|
2372
|
-
@"content "
|
2373
|
-
@"rewarded.");
|
2374
|
-
}
|
2375
|
-
else if (adFormat
|
2376
|
-
== 4)
|
2377
|
-
{
|
2378
|
-
isAdSkip = 1;
|
2379
|
-
[self
|
2380
|
-
fireEvent:@""
|
2381
|
-
event:
|
2382
|
-
@"on."
|
2383
|
-
@"rewa"
|
2384
|
-
@"rded"
|
2385
|
-
@"Int."
|
2386
|
-
@"show"
|
2387
|
-
@"ed"
|
2388
|
-
withData:nil];
|
2389
|
-
NSLog (
|
2390
|
-
@"Ad will "
|
2391
|
-
@"present "
|
2392
|
-
@"full screen "
|
2393
|
-
@"content "
|
2394
|
-
@"interstitial"
|
2395
|
-
@" rewarded.");
|
2396
|
-
}
|
1466
|
+
- (void)bannerViewDidDismissScreen:(GADBannerView *)bannerView {
|
1467
|
+
[self fireEvent:@""
|
1468
|
+
event:@"on."
|
1469
|
+
@"banner"
|
1470
|
+
@".did."
|
1471
|
+
@"dismis"
|
1472
|
+
@"s"
|
1473
|
+
withData:nil];
|
1474
|
+
NSLog(@"bannerViewDidD"
|
1475
|
+
@"ismissScreen");
|
2397
1476
|
}
|
2398
|
-
|
2399
|
-
|
2400
|
-
|
2401
|
-
|
2402
|
-
|
2403
|
-
|
2404
|
-
|
2405
|
-
|
2406
|
-
|
2407
|
-
|
2408
|
-
|
2409
|
-
|
2410
|
-
|
2411
|
-
|
2412
|
-
|
2413
|
-
|
2414
|
-
|
2415
|
-
|
2416
|
-
|
2417
|
-
|
2418
|
-
|
2419
|
-
|
2420
|
-
|
2421
|
-
|
2422
|
-
|
2423
|
-
|
2424
|
-
|
2425
|
-
|
2426
|
-
|
2427
|
-
|
2428
|
-
|
2429
|
-
|
2430
|
-
|
2431
|
-
|
2432
|
-
|
2433
|
-
|
2434
|
-
|
2435
|
-
|
2436
|
-
|
2437
|
-
|
2438
|
-
|
2439
|
-
|
2440
|
-
|
2441
|
-
|
2442
|
-
|
2443
|
-
|
2444
|
-
|
2445
|
-
|
2446
|
-
|
2447
|
-
|
2448
|
-
|
2449
|
-
|
2450
|
-
|
2451
|
-
|
2452
|
-
|
2453
|
-
|
2454
|
-
|
2455
|
-
|
2456
|
-
|
2457
|
-
|
2458
|
-
|
2459
|
-
|
2460
|
-
|
2461
|
-
|
2462
|
-
|
2463
|
-
|
2464
|
-
@"load"
|
2465
|
-
withData:nil];
|
2466
|
-
NSLog (
|
2467
|
-
@"Ad failed "
|
2468
|
-
@"to present "
|
2469
|
-
@"full screen "
|
2470
|
-
@"content "
|
2471
|
-
@"with error "
|
2472
|
-
@"rewarded "
|
2473
|
-
@"%@.",
|
2474
|
-
[error
|
2475
|
-
localizedDescription]);
|
2476
|
-
}
|
2477
|
-
else if (adFormat
|
2478
|
-
== 4)
|
2479
|
-
{
|
2480
|
-
[self
|
2481
|
-
fireEvent:@""
|
2482
|
-
event:
|
2483
|
-
@"on."
|
2484
|
-
@"rewa"
|
2485
|
-
@"rded"
|
2486
|
-
@"Int."
|
2487
|
-
@"fail"
|
2488
|
-
@"ed."
|
2489
|
-
@"load"
|
2490
|
-
withData:nil];
|
2491
|
-
NSLog (
|
2492
|
-
@"Ad failed "
|
2493
|
-
@"to present "
|
2494
|
-
@"full screen "
|
2495
|
-
@"content "
|
2496
|
-
@"with error "
|
2497
|
-
@"interstitial"
|
2498
|
-
@" "
|
2499
|
-
@"rewarded "
|
2500
|
-
@"%@.",
|
2501
|
-
[error
|
2502
|
-
localizedDescription]);
|
2503
|
-
}
|
1477
|
+
#pragma GADFullScreeContentDelegate implementation
|
1478
|
+
- (void)adWillPresentFullScreenContent:(id)ad {
|
1479
|
+
if (adFormat == 1) {
|
1480
|
+
[self fireEvent:@""
|
1481
|
+
event:@"on."
|
1482
|
+
@"appO"
|
1483
|
+
@"penA"
|
1484
|
+
@"d."
|
1485
|
+
@"show"
|
1486
|
+
withData:nil];
|
1487
|
+
NSLog(@"Ad will "
|
1488
|
+
@"present "
|
1489
|
+
@"full screen "
|
1490
|
+
@"content App "
|
1491
|
+
@"Open Ad.");
|
1492
|
+
} else if (adFormat == 2) {
|
1493
|
+
[self fireEvent:@""
|
1494
|
+
event:@"on."
|
1495
|
+
@"inte"
|
1496
|
+
@"rsti"
|
1497
|
+
@"tial"
|
1498
|
+
@".sho"
|
1499
|
+
@"w"
|
1500
|
+
withData:nil];
|
1501
|
+
[self fireEvent:@""
|
1502
|
+
event:@"onPr"
|
1503
|
+
@"esen"
|
1504
|
+
@"tAd"
|
1505
|
+
withData:nil];
|
1506
|
+
NSLog(@"Ad will "
|
1507
|
+
@"present "
|
1508
|
+
@"full screen "
|
1509
|
+
@"content "
|
1510
|
+
@"interstitial"
|
1511
|
+
@".");
|
1512
|
+
} else if (adFormat == 3) {
|
1513
|
+
[self fireEvent:@""
|
1514
|
+
event:@"on."
|
1515
|
+
@"rewa"
|
1516
|
+
@"rded"
|
1517
|
+
@".sho"
|
1518
|
+
@"w"
|
1519
|
+
withData:nil];
|
1520
|
+
isAdSkip = 1;
|
1521
|
+
NSLog(@"Ad will "
|
1522
|
+
@"present "
|
1523
|
+
@"full screen "
|
1524
|
+
@"content "
|
1525
|
+
@"rewarded.");
|
1526
|
+
} else if (adFormat == 4) {
|
1527
|
+
isAdSkip = 1;
|
1528
|
+
[self fireEvent:@""
|
1529
|
+
event:@"on."
|
1530
|
+
@"rewa"
|
1531
|
+
@"rded"
|
1532
|
+
@"Int."
|
1533
|
+
@"show"
|
1534
|
+
@"ed"
|
1535
|
+
withData:nil];
|
1536
|
+
NSLog(@"Ad will "
|
1537
|
+
@"present "
|
1538
|
+
@"full screen "
|
1539
|
+
@"content "
|
1540
|
+
@"interstitial"
|
1541
|
+
@" rewarded.");
|
1542
|
+
}
|
2504
1543
|
}
|
2505
|
-
- (void)
|
2506
|
-
|
2507
|
-
|
2508
|
-
|
2509
|
-
|
2510
|
-
|
2511
|
-
|
2512
|
-
|
2513
|
-
|
2514
|
-
|
2515
|
-
|
2516
|
-
|
2517
|
-
|
2518
|
-
|
2519
|
-
|
2520
|
-
|
2521
|
-
|
2522
|
-
|
2523
|
-
|
2524
|
-
|
2525
|
-
|
2526
|
-
|
2527
|
-
|
2528
|
-
|
2529
|
-
|
2530
|
-
|
2531
|
-
|
2532
|
-
|
2533
|
-
|
2534
|
-
|
2535
|
-
|
2536
|
-
|
2537
|
-
|
2538
|
-
|
2539
|
-
|
2540
|
-
|
2541
|
-
|
2542
|
-
|
2543
|
-
|
2544
|
-
|
2545
|
-
|
2546
|
-
|
2547
|
-
|
2548
|
-
|
2549
|
-
|
2550
|
-
|
2551
|
-
|
2552
|
-
|
2553
|
-
|
2554
|
-
|
2555
|
-
|
2556
|
-
|
2557
|
-
|
2558
|
-
|
2559
|
-
|
2560
|
-
|
2561
|
-
|
2562
|
-
|
2563
|
-
|
2564
|
-
|
2565
|
-
|
2566
|
-
|
2567
|
-
|
2568
|
-
|
2569
|
-
|
2570
|
-
|
2571
|
-
|
2572
|
-
|
2573
|
-
|
2574
|
-
|
2575
|
-
|
2576
|
-
|
2577
|
-
|
2578
|
-
|
2579
|
-
|
2580
|
-
nil];
|
1544
|
+
- (void)ad:(id)ad didFailToPresentFullScreenContentWithError:(NSError *)error {
|
1545
|
+
if (adFormat == 1) {
|
1546
|
+
[self fireEvent:@""
|
1547
|
+
event:@"on."
|
1548
|
+
@"appO"
|
1549
|
+
@"penA"
|
1550
|
+
@"d."
|
1551
|
+
@"fail"
|
1552
|
+
@"ed."
|
1553
|
+
@"load"
|
1554
|
+
@"ed"
|
1555
|
+
withData:nil];
|
1556
|
+
NSLog(@"Ad failed "
|
1557
|
+
@"to present "
|
1558
|
+
@"full screen "
|
1559
|
+
@"content "
|
1560
|
+
@"with error "
|
1561
|
+
@"App Open Ad "
|
1562
|
+
@"%@.",
|
1563
|
+
[error localizedDescription]);
|
1564
|
+
} else if (adFormat == 2) {
|
1565
|
+
[self fireEvent:@""
|
1566
|
+
event:@"on."
|
1567
|
+
@"inte"
|
1568
|
+
@"rsti"
|
1569
|
+
@"tial"
|
1570
|
+
@".fai"
|
1571
|
+
@"led."
|
1572
|
+
@"load"
|
1573
|
+
withData:nil];
|
1574
|
+
NSLog(@"Ad failed "
|
1575
|
+
@"to present "
|
1576
|
+
@"full screen "
|
1577
|
+
@"content "
|
1578
|
+
@"with error "
|
1579
|
+
@"interstitial"
|
1580
|
+
@" %@.",
|
1581
|
+
[error localizedDescription]);
|
1582
|
+
} else if (adFormat == 3) {
|
1583
|
+
[self fireEvent:@""
|
1584
|
+
event:@"on."
|
1585
|
+
@"rewa"
|
1586
|
+
@"rded"
|
1587
|
+
@".fai"
|
1588
|
+
@"led."
|
1589
|
+
@"load"
|
1590
|
+
withData:nil];
|
1591
|
+
NSLog(@"Ad failed "
|
1592
|
+
@"to present "
|
1593
|
+
@"full screen "
|
1594
|
+
@"content "
|
1595
|
+
@"with error "
|
1596
|
+
@"rewarded "
|
1597
|
+
@"%@.",
|
1598
|
+
[error localizedDescription]);
|
1599
|
+
} else if (adFormat == 4) {
|
1600
|
+
[self fireEvent:@""
|
1601
|
+
event:@"on."
|
1602
|
+
@"rewa"
|
1603
|
+
@"rded"
|
1604
|
+
@"Int."
|
1605
|
+
@"fail"
|
1606
|
+
@"ed."
|
1607
|
+
@"load"
|
1608
|
+
withData:nil];
|
1609
|
+
NSLog(@"Ad failed "
|
1610
|
+
@"to present "
|
1611
|
+
@"full screen "
|
1612
|
+
@"content "
|
1613
|
+
@"with error "
|
1614
|
+
@"interstitial"
|
1615
|
+
@" "
|
1616
|
+
@"rewarded "
|
1617
|
+
@"%@.",
|
1618
|
+
[error localizedDescription]);
|
2581
1619
|
}
|
2582
|
-
|
2583
|
-
|
2584
|
-
|
2585
|
-
|
2586
|
-
|
2587
|
-
|
2588
|
-
|
2589
|
-
|
2590
|
-
|
2591
|
-
|
2592
|
-
|
2593
|
-
|
2594
|
-
|
2595
|
-
|
2596
|
-
|
2597
|
-
|
2598
|
-
|
2599
|
-
|
2600
|
-
|
2601
|
-
|
2602
|
-
|
2603
|
-
|
2604
|
-
|
2605
|
-
|
2606
|
-
|
2607
|
-
|
2608
|
-
|
2609
|
-
|
1620
|
+
}
|
1621
|
+
|
1622
|
+
- (void)adDidDismissFullScreenContent:(id)ad {
|
1623
|
+
if (adFormat == 1) {
|
1624
|
+
[self fireEvent:@""
|
1625
|
+
event:@"on."
|
1626
|
+
@"appO"
|
1627
|
+
@"penA"
|
1628
|
+
@"d."
|
1629
|
+
@"dism"
|
1630
|
+
@"isse"
|
1631
|
+
@"d"
|
1632
|
+
withData:nil];
|
1633
|
+
NSLog(@"Ad did "
|
1634
|
+
@"dismiss "
|
1635
|
+
@"full screen "
|
1636
|
+
@"content App "
|
1637
|
+
@"Open Ad.");
|
1638
|
+
} else if (adFormat == 2) {
|
1639
|
+
[self fireEvent:@""
|
1640
|
+
event:@"on."
|
1641
|
+
@"inte"
|
1642
|
+
@"rsti"
|
1643
|
+
@"tial"
|
1644
|
+
@".dis"
|
1645
|
+
@"miss"
|
1646
|
+
@"ed"
|
1647
|
+
withData:nil];
|
1648
|
+
NSLog(@"Ad did "
|
1649
|
+
@"dismiss "
|
1650
|
+
@"full screen "
|
1651
|
+
@"content "
|
1652
|
+
@"interstitial"
|
1653
|
+
@".");
|
1654
|
+
} else if (adFormat == 3) {
|
1655
|
+
[self fireEvent:@""
|
1656
|
+
event:@"on."
|
1657
|
+
@"rewa"
|
1658
|
+
@"rded"
|
1659
|
+
@".dis"
|
1660
|
+
@"miss"
|
1661
|
+
@"ed"
|
1662
|
+
withData:nil];
|
1663
|
+
if (isAdSkip != 2) {
|
1664
|
+
[self fireEvent:@""
|
1665
|
+
event:@"on"
|
1666
|
+
@".r"
|
1667
|
+
@"ew"
|
1668
|
+
@"ar"
|
1669
|
+
@"de"
|
1670
|
+
@"d."
|
1671
|
+
@"ad"
|
1672
|
+
@".s"
|
1673
|
+
@"ki"
|
1674
|
+
@"p"
|
1675
|
+
withData:nil];
|
1676
|
+
}
|
1677
|
+
NSLog(@"Ad did "
|
1678
|
+
@"dismiss "
|
1679
|
+
@"full screen "
|
1680
|
+
@"content "
|
1681
|
+
@"rewarded.");
|
1682
|
+
} else if (adFormat == 4) {
|
1683
|
+
if (isAdSkip != 2) {
|
1684
|
+
[self fireEvent:@""
|
1685
|
+
event:@"on"
|
1686
|
+
@".r"
|
1687
|
+
@"ew"
|
1688
|
+
@"ar"
|
1689
|
+
@"de"
|
1690
|
+
@"dI"
|
1691
|
+
@"nt"
|
1692
|
+
@".a"
|
1693
|
+
@"d."
|
1694
|
+
@"sk"
|
1695
|
+
@"ip"
|
1696
|
+
withData:nil];
|
1697
|
+
}
|
1698
|
+
[self fireEvent:@""
|
1699
|
+
event:@"on."
|
1700
|
+
@"rewa"
|
1701
|
+
@"rded"
|
1702
|
+
@"Int."
|
1703
|
+
@"dism"
|
1704
|
+
@"isse"
|
1705
|
+
@"d"
|
1706
|
+
withData:nil];
|
1707
|
+
NSLog(@"Ad did "
|
1708
|
+
@"dismiss "
|
1709
|
+
@"full screen "
|
1710
|
+
@"content "
|
1711
|
+
@"interstitial"
|
1712
|
+
@" rewarded.");
|
2610
1713
|
}
|
2611
|
-
[self
|
2612
|
-
fireEvent:@""
|
2613
|
-
event:
|
2614
|
-
@"on."
|
2615
|
-
@"rewa"
|
2616
|
-
@"rded"
|
2617
|
-
@"Int."
|
2618
|
-
@"dism"
|
2619
|
-
@"isse"
|
2620
|
-
@"d"
|
2621
|
-
withData:nil];
|
2622
|
-
NSLog (
|
2623
|
-
@"Ad did "
|
2624
|
-
@"dismiss "
|
2625
|
-
@"full screen "
|
2626
|
-
@"content "
|
2627
|
-
@"interstitial"
|
2628
|
-
@" rewarded.");
|
2629
|
-
}
|
2630
1714
|
}
|
2631
1715
|
#pragma mark Cleanup
|
2632
1716
|
- (void)dealloc
|
2633
1717
|
{
|
2634
|
-
|
2635
|
-
|
2636
|
-
|
2637
|
-
|
2638
|
-
|
2639
|
-
|
2640
|
-
|
2641
|
-
|
2642
|
-
|
1718
|
+
self.appOpenAd = nil;
|
1719
|
+
self.bannerView
|
1720
|
+
= nil;
|
1721
|
+
self.interstitial
|
1722
|
+
= nil;
|
1723
|
+
self.rewardedAd
|
1724
|
+
= nil;
|
1725
|
+
self.rewardedInterstitialAd
|
1726
|
+
= nil;
|
1727
|
+
[[NSNotificationCenter defaultCenter] removeObserver:self name:UIDeviceOrientationDidChangeNotification object:nil];
|
2643
1728
|
}
|
2644
1729
|
@end
|
1730
|
+
|