emi-indo-cordova-plugin-admob 1.5.4 → 1.5.5
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/.vscode/settings.json +1 -5
- package/README.md +42 -148
- package/example/www/css/index.css +110 -0
- package/example/www/index.html +27 -0
- package/example/www/js/appOpenAd.js +146 -0
- package/example/www/js/bannerAd.js +156 -0
- package/example/www/js/deviceready.js +110 -0
- package/example/www/js/interstitialAd.js +123 -0
- package/example/www/js/rewardedAd.js +125 -0
- package/package.json +2 -2
- package/plugin.xml +4 -5
- package/src/android/emiAdmobPlugin.kt +838 -694
- package/src/ios/emiAdmobPlugin.m +898 -974
- package/www/emiAdmobPlugin.js +4 -4
package/src/ios/emiAdmobPlugin.m
CHANGED
@@ -46,13 +46,11 @@ BOOL isUsingAdManagerRequest = YES;
|
|
46
46
|
- (void)isDebugGeography:(BOOL)value {
|
47
47
|
isDebugGeography = value;
|
48
48
|
}
|
49
|
-
|
50
49
|
- (void)initialize:(CDVInvokedUrlCommand *)command {
|
51
50
|
|
52
51
|
NSDictionary *options = [command.arguments objectAtIndex:0];
|
53
52
|
|
54
|
-
BOOL setAdRequest =
|
55
|
-
[[options valueForKey:@"isUsingAdManagerRequest"] boolValue];
|
53
|
+
BOOL setAdRequest = [[options valueForKey:@"isUsingAdManagerRequest"] boolValue];
|
56
54
|
BOOL responseInfo = [[options valueForKey:@"isResponseInfo"] boolValue];
|
57
55
|
BOOL setDebugGeography = [[options valueForKey:@"isConsentDebug"] boolValue];
|
58
56
|
|
@@ -65,137 +63,67 @@ BOOL isUsingAdManagerRequest = YES;
|
|
65
63
|
NSString *deviceId = [self __getAdMobDeviceId];
|
66
64
|
UMPRequestParameters *parameters = [[UMPRequestParameters alloc] init];
|
67
65
|
|
68
|
-
if (
|
66
|
+
if (setDebugGeography) {
|
69
67
|
UMPDebugSettings *debugSettings = [[UMPDebugSettings alloc] init];
|
70
68
|
parameters.debugSettings = debugSettings;
|
71
69
|
debugSettings.geography = UMPDebugGeographyEEA;
|
72
70
|
debugSettings.testDeviceIdentifiers = @[ deviceId ];
|
73
71
|
}
|
74
|
-
|
75
72
|
parameters.tagForUnderAgeOfConsent = UnderAgeOfConsent;
|
76
73
|
|
74
|
+
if (UMPConsentInformation.sharedInstance.canRequestAds) {
|
75
|
+
[self startGoogleMobileAdsSDK];
|
76
|
+
}
|
77
|
+
|
78
|
+
|
77
79
|
dispatch_async(dispatch_get_main_queue(), ^{
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
|
84
|
-
|
85
|
-
|
86
|
-
|
87
|
-
|
88
|
-
|
89
|
-
|
90
|
-
|
91
|
-
|
92
|
-
|
93
|
-
|
94
|
-
|
95
|
-
|
96
|
-
|
97
|
-
|
98
|
-
|
99
|
-
|
100
|
-
|
101
|
-
|
102
|
-
|
103
|
-
|
104
|
-
|
105
|
-
|
106
|
-
|
107
|
-
|
108
|
-
|
109
|
-
|
110
|
-
|
111
|
-
|
112
|
-
|
113
|
-
|
114
|
-
|
115
|
-
|
116
|
-
|
117
|
-
|
118
|
-
|
119
|
-
|
120
|
-
|
121
|
-
[form
|
122
|
-
presentFromViewController:
|
123
|
-
[UIApplication sharedApplication]
|
124
|
-
.delegate.window
|
125
|
-
.rootViewController
|
126
|
-
completionHandler:^(
|
127
|
-
NSError
|
128
|
-
*_Nullable dismissError) {
|
129
|
-
if (dismissError) {
|
130
|
-
// NSLog(@"Dismiss consent
|
131
|
-
// form error: %@",
|
132
|
-
// dismissError.localizedDescription);
|
133
|
-
pluginResult = [CDVPluginResult
|
134
|
-
resultWithStatus:
|
135
|
-
CDVCommandStatus_ERROR
|
136
|
-
messageAsString:
|
137
|
-
dismissError
|
138
|
-
.description];
|
139
|
-
} else {
|
140
|
-
// NSLog(@"Consent form
|
141
|
-
// successfully
|
142
|
-
// presented.");
|
143
|
-
pluginResult = [CDVPluginResult
|
144
|
-
resultWithStatus:
|
145
|
-
CDVCommandStatus_OK
|
146
|
-
messageAsString:
|
147
|
-
@"Consent form "
|
148
|
-
@"displayed "
|
149
|
-
@"successfully."];
|
150
|
-
}
|
151
|
-
[self.commandDelegate
|
152
|
-
sendPluginResult:
|
153
|
-
pluginResult
|
154
|
-
callbackId:
|
155
|
-
callbackId];
|
156
|
-
}];
|
157
|
-
}
|
158
|
-
|
159
|
-
if (UMPConsentInformation.sharedInstance
|
160
|
-
.canRequestAds) {
|
161
|
-
[self startGoogleMobileAdsSDK];
|
162
|
-
}
|
163
|
-
}];
|
164
|
-
} else if (status ==
|
165
|
-
UMPConsentStatusNotRequired ||
|
166
|
-
status == UMPConsentStatusObtained) {
|
167
|
-
// If consent is not required or already
|
168
|
-
// obtained, start the ads SDK
|
169
|
-
if (UMPConsentInformation.sharedInstance
|
170
|
-
.canRequestAds) {
|
171
|
-
[self startGoogleMobileAdsSDK];
|
172
|
-
pluginResult = [CDVPluginResult
|
173
|
-
resultWithStatus:CDVCommandStatus_OK
|
174
|
-
messageAsString:@"Ads SDK started."];
|
175
|
-
} else {
|
176
|
-
pluginResult = [CDVPluginResult
|
177
|
-
resultWithStatus:CDVCommandStatus_ERROR
|
178
|
-
messageAsString:
|
179
|
-
@"Cannot request ads, consent is "
|
180
|
-
@"required."];
|
181
|
-
}
|
182
|
-
[self.commandDelegate
|
183
|
-
sendPluginResult:pluginResult
|
184
|
-
callbackId:callbackId];
|
185
|
-
} else {
|
186
|
-
// NSLog(@"Consent status unknown or error.");
|
187
|
-
pluginResult = [CDVPluginResult
|
188
|
-
resultWithStatus:CDVCommandStatus_ERROR
|
189
|
-
messageAsString:
|
190
|
-
@"Consent status unknown."];
|
191
|
-
[self.commandDelegate
|
192
|
-
sendPluginResult:pluginResult
|
193
|
-
callbackId:callbackId];
|
194
|
-
}
|
195
|
-
}];
|
80
|
+
[UMPConsentInformation.sharedInstance requestConsentInfoUpdateWithParameters:parameters completionHandler:^(NSError *_Nullable requestConsentError) {
|
81
|
+
if (requestConsentError) {
|
82
|
+
pluginResult = [CDVPluginResult resultWithStatus:CDVCommandStatus_ERROR messageAsString:requestConsentError.description];
|
83
|
+
[self.commandDelegate sendPluginResult:pluginResult callbackId:callbackId];
|
84
|
+
return;
|
85
|
+
}
|
86
|
+
|
87
|
+
UMPConsentStatus status = UMPConsentInformation.sharedInstance.consentStatus;
|
88
|
+
|
89
|
+
if (status == UMPConsentStatusRequired) {
|
90
|
+
[UMPConsentForm loadWithCompletionHandler:^(UMPConsentForm *form, NSError *loadError) {
|
91
|
+
if (loadError) {
|
92
|
+
pluginResult = [CDVPluginResult resultWithStatus:CDVCommandStatus_ERROR messageAsString:loadError.description];
|
93
|
+
[self.commandDelegate sendPluginResult:pluginResult callbackId:callbackId];
|
94
|
+
} else {
|
95
|
+
[form presentFromViewController:[UIApplication sharedApplication].delegate.window.rootViewController completionHandler:^(NSError *_Nullable dismissError) {
|
96
|
+
if (dismissError) {
|
97
|
+
pluginResult = [CDVPluginResult resultWithStatus:CDVCommandStatus_ERROR messageAsString:dismissError.description];
|
98
|
+
} else {
|
99
|
+
pluginResult = [CDVPluginResult resultWithStatus:CDVCommandStatus_OK messageAsString:@"Consent form displayed successfully."];
|
100
|
+
}
|
101
|
+
[self.commandDelegate sendPluginResult:pluginResult callbackId:callbackId];
|
102
|
+
}];
|
103
|
+
}
|
104
|
+
|
105
|
+
|
106
|
+
if (UMPConsentInformation.sharedInstance.canRequestAds) {
|
107
|
+
[self startGoogleMobileAdsSDK];
|
108
|
+
}
|
109
|
+
}];
|
110
|
+
} else if (status == UMPConsentStatusNotRequired || status == UMPConsentStatusObtained) {
|
111
|
+
if (UMPConsentInformation.sharedInstance.canRequestAds) {
|
112
|
+
[self startGoogleMobileAdsSDK];
|
113
|
+
pluginResult = [CDVPluginResult resultWithStatus:CDVCommandStatus_OK messageAsString:@"Ads SDK started."];
|
114
|
+
} else {
|
115
|
+
pluginResult = [CDVPluginResult resultWithStatus:CDVCommandStatus_ERROR messageAsString:@"Cannot request ads, consent is required."];
|
116
|
+
}
|
117
|
+
[self.commandDelegate sendPluginResult:pluginResult callbackId:callbackId];
|
118
|
+
} else {
|
119
|
+
pluginResult = [CDVPluginResult resultWithStatus:CDVCommandStatus_ERROR messageAsString:@"Consent status unknown."];
|
120
|
+
[self.commandDelegate sendPluginResult:pluginResult callbackId:callbackId];
|
121
|
+
}
|
122
|
+
}];
|
196
123
|
});
|
197
124
|
}
|
198
125
|
|
126
|
+
|
199
127
|
- (void)requestIDFA:(CDVInvokedUrlCommand *)command {
|
200
128
|
CDVPluginResult *pluginResult;
|
201
129
|
NSString *callbackId = command.callbackId;
|
@@ -308,232 +236,98 @@ BOOL isUsingAdManagerRequest = YES;
|
|
308
236
|
}
|
309
237
|
|
310
238
|
- (void)forceDisplayPrivacyForm:(CDVInvokedUrlCommand *)command {
|
311
|
-
|
312
|
-
|
313
|
-
|
314
|
-
|
315
|
-
|
316
|
-
|
317
|
-
|
318
|
-
|
319
|
-
|
239
|
+
NSString *deviceId = [self __getAdMobDeviceId];
|
240
|
+
UMPRequestParameters *parameters = [[UMPRequestParameters alloc] init];
|
241
|
+
|
242
|
+
if (isDebugGeography) {
|
243
|
+
UMPDebugSettings *debugSettings = [[UMPDebugSettings alloc] init];
|
244
|
+
debugSettings.geography = UMPDebugGeographyEEA;
|
245
|
+
debugSettings.testDeviceIdentifiers = @[ deviceId ];
|
246
|
+
parameters.debugSettings = debugSettings;
|
247
|
+
}
|
320
248
|
|
321
|
-
|
249
|
+
parameters.tagForUnderAgeOfConsent = UnderAgeOfConsent;
|
322
250
|
|
323
|
-
|
251
|
+
dispatch_async(dispatch_get_main_queue(), ^{
|
252
|
+
[UMPConsentInformation.sharedInstance requestConsentInfoUpdateWithParameters:parameters completionHandler:^(NSError *_Nullable requestConsentError) {
|
253
|
+
if (requestConsentError) {
|
254
|
+
CDVPluginResult *pluginResult = [CDVPluginResult resultWithStatus:CDVCommandStatus_ERROR messageAsString:requestConsentError.description];
|
255
|
+
[self.commandDelegate sendPluginResult:pluginResult callbackId:command.callbackId];
|
256
|
+
return;
|
257
|
+
}
|
324
258
|
|
325
|
-
|
326
|
-
|
327
|
-
|
328
|
-
|
329
|
-
|
330
|
-
|
331
|
-
|
332
|
-
|
333
|
-
|
334
|
-
|
335
|
-
|
336
|
-
|
337
|
-
|
338
|
-
|
339
|
-
// requestConsentError);
|
340
|
-
CDVPluginResult
|
341
|
-
*pluginResult = [CDVPluginResult
|
342
|
-
resultWithStatus:
|
343
|
-
CDVCommandStatus_ERROR
|
344
|
-
messageAsString:
|
345
|
-
requestConsentError
|
346
|
-
.description];
|
347
|
-
[self.commandDelegate
|
348
|
-
sendPluginResult:
|
349
|
-
pluginResult
|
350
|
-
callbackId:
|
351
|
-
command
|
352
|
-
.callbackId];
|
353
|
-
return;
|
354
|
-
}
|
355
|
-
|
356
|
-
// NSLog(@"Successful
|
357
|
-
// update of
|
358
|
-
// consent
|
359
|
-
// info.
|
360
|
-
// Continue to
|
361
|
-
// load and
|
362
|
-
// present
|
363
|
-
// consent
|
364
|
-
// form.");
|
365
|
-
|
366
|
-
[UMPConsentForm loadAndPresentIfRequiredFromViewController:
|
367
|
-
self.viewController
|
368
|
-
completionHandler:
|
369
|
-
^(NSError
|
370
|
-
*loadAndPresentError) {
|
371
|
-
if (loadAndPresentError !=
|
372
|
-
nil) {
|
373
|
-
// NSLog(@"Error loading and presenting consent form: %@", loadAndPresentError);
|
374
|
-
CDVPluginResult
|
375
|
-
*pluginResult = [CDVPluginResult
|
376
|
-
resultWithStatus:
|
377
|
-
CDVCommandStatus_ERROR
|
378
|
-
messageAsString:
|
379
|
-
loadAndPresentError
|
380
|
-
.description];
|
381
|
-
[self.commandDelegate
|
382
|
-
sendPluginResult:
|
383
|
-
pluginResult
|
384
|
-
callbackId:
|
385
|
-
command
|
386
|
-
.callbackId];
|
387
|
-
} else {
|
388
|
-
// NSLog(@"Consent form successfully loaded");
|
389
|
-
[UMPConsentForm
|
390
|
-
presentPrivacyOptionsFormFromViewController:
|
391
|
-
self.viewController
|
392
|
-
completionHandler:^(
|
393
|
-
NSError
|
394
|
-
*_Nullable formError) {
|
395
|
-
if (formError) {
|
396
|
-
// NSLog(@"Error when displaying the form: %@", formError);
|
397
|
-
} else {
|
398
|
-
// NSLog(@"The privacy options form is successfully displayed.");
|
399
|
-
}
|
400
|
-
}];
|
401
|
-
}
|
402
|
-
}];
|
403
|
-
}];
|
404
|
-
});
|
259
|
+
[UMPConsentForm loadAndPresentIfRequiredFromViewController:self.viewController completionHandler:^(NSError *loadAndPresentError) {
|
260
|
+
if (loadAndPresentError) {
|
261
|
+
CDVPluginResult *pluginResult = [CDVPluginResult resultWithStatus:CDVCommandStatus_ERROR messageAsString:loadAndPresentError.description];
|
262
|
+
[self.commandDelegate sendPluginResult:pluginResult callbackId:command.callbackId];
|
263
|
+
} else {
|
264
|
+
[UMPConsentForm presentPrivacyOptionsFormFromViewController:self.viewController completionHandler:^(NSError *_Nullable formError) {
|
265
|
+
if (formError) {
|
266
|
+
// NSLog(@"Error when displaying the form: %@", formError);
|
267
|
+
}
|
268
|
+
}];
|
269
|
+
}
|
270
|
+
}];
|
271
|
+
}];
|
272
|
+
});
|
405
273
|
}
|
406
274
|
|
407
275
|
- (void)showPrivacyOptionsForm:(CDVInvokedUrlCommand *)command {
|
408
|
-
|
409
|
-
|
410
|
-
|
411
|
-
|
412
|
-
|
413
|
-
|
414
|
-
|
415
|
-
|
276
|
+
NSString *deviceId = [self __getAdMobDeviceId];
|
277
|
+
UMPRequestParameters *parameters = [[UMPRequestParameters alloc] init];
|
278
|
+
|
279
|
+
if (isDebugGeography) {
|
280
|
+
UMPDebugSettings *debugSettings = [[UMPDebugSettings alloc] init];
|
281
|
+
parameters.debugSettings = debugSettings;
|
282
|
+
debugSettings.geography = UMPDebugGeographyEEA;
|
283
|
+
debugSettings.testDeviceIdentifiers = @[ deviceId ];
|
284
|
+
}
|
416
285
|
|
417
|
-
|
418
|
-
// consent.");
|
419
|
-
}
|
286
|
+
parameters.tagForUnderAgeOfConsent = UnderAgeOfConsent;
|
420
287
|
|
421
|
-
|
288
|
+
dispatch_async(dispatch_get_main_queue(), ^{
|
289
|
+
[UMPConsentInformation.sharedInstance requestConsentInfoUpdateWithParameters:parameters completionHandler:^(NSError *_Nullable requestConsentError) {
|
290
|
+
if (requestConsentError) {
|
291
|
+
CDVPluginResult *pluginResult = [CDVPluginResult resultWithStatus:CDVCommandStatus_ERROR messageAsString:requestConsentError.description];
|
292
|
+
[self.commandDelegate sendPluginResult:pluginResult callbackId:command.callbackId];
|
293
|
+
return;
|
294
|
+
}
|
422
295
|
|
423
|
-
|
424
|
-
|
425
|
-
|
426
|
-
|
427
|
-
|
428
|
-
|
429
|
-
|
430
|
-
|
431
|
-
|
432
|
-
|
433
|
-
|
434
|
-
|
435
|
-
|
436
|
-
|
437
|
-
|
438
|
-
requestConsentError
|
439
|
-
.description];
|
440
|
-
[self.commandDelegate
|
441
|
-
sendPluginResult:
|
442
|
-
pluginResult
|
443
|
-
callbackId:
|
444
|
-
command
|
445
|
-
.callbackId];
|
446
|
-
return;
|
447
|
-
}
|
448
|
-
|
449
|
-
// NSLog(@"[showPrivacyOptionsForm] Successful update of consent info. Continue to load and present consent form.");
|
450
|
-
|
451
|
-
[UMPConsentForm
|
452
|
-
loadAndPresentIfRequiredFromViewController:
|
453
|
-
self.viewController
|
454
|
-
completionHandler:^(
|
455
|
-
NSError
|
456
|
-
*loadAndPresentError) {
|
457
|
-
if (loadAndPresentError) {
|
458
|
-
// NSLog(@"[showPrivacyOptionsForm] Error loading and presenting consent form: %@", loadAndPresentError);
|
459
|
-
CDVPluginResult
|
460
|
-
*pluginResult = [CDVPluginResult
|
461
|
-
resultWithStatus:
|
462
|
-
CDVCommandStatus_ERROR
|
463
|
-
messageAsString:
|
464
|
-
loadAndPresentError
|
465
|
-
.description];
|
466
|
-
[self.commandDelegate
|
467
|
-
sendPluginResult:
|
468
|
-
pluginResult
|
469
|
-
callbackId:
|
470
|
-
command
|
471
|
-
.callbackId];
|
472
|
-
} else {
|
473
|
-
/// NSLog(@"[showPrivacyOptionsForm] Consent form successfully displayed.");
|
474
|
-
}
|
475
|
-
}];
|
476
|
-
|
477
|
-
if ([self
|
478
|
-
isPrivacyOptionsRequired]) {
|
479
|
-
// NSLog(@"[isPrivacyOptionsRequired] Privacy options required.");
|
480
|
-
[self
|
481
|
-
privacyOptionsFormShow:
|
482
|
-
command];
|
483
|
-
} else {
|
484
|
-
// NSLog(@"[isPrivacyOptionsRequired] Privacy option form not required.");
|
485
|
-
CDVPluginResult
|
486
|
-
*pluginResult = [CDVPluginResult
|
487
|
-
resultWithStatus:
|
488
|
-
CDVCommandStatus_OK
|
489
|
-
messageAsString:
|
490
|
-
@"The privacy option form is not required."];
|
491
|
-
[self.commandDelegate
|
492
|
-
sendPluginResult:
|
493
|
-
pluginResult
|
494
|
-
callbackId:
|
495
|
-
command
|
496
|
-
.callbackId];
|
497
|
-
}
|
498
|
-
}];
|
499
|
-
});
|
296
|
+
[UMPConsentForm loadAndPresentIfRequiredFromViewController:self.viewController completionHandler:^(NSError *loadAndPresentError) {
|
297
|
+
if (loadAndPresentError) {
|
298
|
+
CDVPluginResult *pluginResult = [CDVPluginResult resultWithStatus:CDVCommandStatus_ERROR messageAsString:loadAndPresentError.description];
|
299
|
+
[self.commandDelegate sendPluginResult:pluginResult callbackId:command.callbackId];
|
300
|
+
}
|
301
|
+
}];
|
302
|
+
|
303
|
+
if ([self isPrivacyOptionsRequired]) {
|
304
|
+
[self privacyOptionsFormShow:command];
|
305
|
+
} else {
|
306
|
+
CDVPluginResult *pluginResult = [CDVPluginResult resultWithStatus:CDVCommandStatus_OK messageAsString:@"The privacy option form is not required."];
|
307
|
+
[self.commandDelegate sendPluginResult:pluginResult callbackId:command.callbackId];
|
308
|
+
}
|
309
|
+
}];
|
310
|
+
});
|
500
311
|
}
|
501
312
|
|
313
|
+
|
502
314
|
- (void)privacyOptionsFormShow:(CDVInvokedUrlCommand *)command {
|
503
|
-
|
504
|
-
|
505
|
-
|
506
|
-
|
507
|
-
|
508
|
-
|
509
|
-
|
510
|
-
|
511
|
-
|
512
|
-
|
513
|
-
CDVPluginResult *pluginResult =
|
514
|
-
[CDVPluginResult
|
515
|
-
resultWithStatus:
|
516
|
-
CDVCommandStatus_ERROR
|
517
|
-
messageAsString:
|
518
|
-
formError.description];
|
519
|
-
[self.commandDelegate
|
520
|
-
sendPluginResult:pluginResult
|
521
|
-
callbackId:command
|
522
|
-
.callbackId];
|
523
|
-
} else {
|
524
|
-
// NSLog(@"[privacyOptionsFormShow] The
|
525
|
-
// privacy options form is successfully
|
526
|
-
// displayed.");
|
527
|
-
}
|
528
|
-
}];
|
529
|
-
});
|
530
|
-
}];
|
315
|
+
[self.commandDelegate runInBackground:^{
|
316
|
+
dispatch_async(dispatch_get_main_queue(), ^{
|
317
|
+
[UMPConsentForm presentPrivacyOptionsFormFromViewController:self.viewController completionHandler:^(NSError *_Nullable formError) {
|
318
|
+
if (formError) {
|
319
|
+
CDVPluginResult *pluginResult = [CDVPluginResult resultWithStatus:CDVCommandStatus_ERROR messageAsString:formError.description];
|
320
|
+
[self.commandDelegate sendPluginResult:pluginResult callbackId:command.callbackId];
|
321
|
+
}
|
322
|
+
}];
|
323
|
+
});
|
324
|
+
}];
|
531
325
|
}
|
532
326
|
|
533
|
-
|
327
|
+
|
328
|
+
|
534
329
|
- (BOOL)isPrivacyOptionsRequired {
|
535
|
-
UMPPrivacyOptionsRequirementStatus status =
|
536
|
-
UMPConsentInformation.sharedInstance.privacyOptionsRequirementStatus;
|
330
|
+
UMPPrivacyOptionsRequirementStatus status = UMPConsentInformation.sharedInstance.privacyOptionsRequirementStatus;
|
537
331
|
// NSLog(@"[isPrivacyOptionsRequired] Privacy option status: %ld",
|
538
332
|
// (long)status);
|
539
333
|
return status == UMPPrivacyOptionsRequirementStatusRequired;
|
@@ -569,59 +363,36 @@ BOOL isUsingAdManagerRequest = YES;
|
|
569
363
|
}
|
570
364
|
|
571
365
|
- (void)getIabTfc:(CDVInvokedUrlCommand *)command {
|
572
|
-
|
573
|
-
|
574
|
-
|
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
|
-
result[@"IABTCF_"
|
601
|
-
@"CmpSdkID"] = CmpSdkID;
|
602
|
-
result[@"IABTCF_"
|
603
|
-
@"gdprAppli"
|
604
|
-
@"es"] = gdprApplies;
|
605
|
-
result[@"IABTCF_"
|
606
|
-
@"PurposeCo"
|
607
|
-
@"nsents"] = PurposeConsents;
|
608
|
-
result[@"IABTCF_"
|
609
|
-
@"TCString"] = TCString;
|
610
|
-
[[NSUserDefaults standardUserDefaults] synchronize];
|
611
|
-
NSLog(@"%@", [[NSUserDefaults standardUserDefaults] dictionaryRepresentation]);
|
612
|
-
pluginResult = [CDVPluginResult resultWithStatus:CDVCommandStatus_OK
|
613
|
-
messageAsDictionary:result];
|
614
|
-
[self fireEvent:@""
|
615
|
-
event:@"on."
|
616
|
-
@"getI"
|
617
|
-
@"abTf"
|
618
|
-
@"c"
|
619
|
-
withData:nil];
|
620
|
-
} else {
|
621
|
-
pluginResult = [CDVPluginResult resultWithStatus:CDVCommandStatus_ERROR];
|
622
|
-
}
|
623
|
-
[self.commandDelegate sendPluginResult:pluginResult callbackId:callbackId];
|
366
|
+
CDVPluginResult *pluginResult;
|
367
|
+
NSString *callbackId = command.callbackId;
|
368
|
+
|
369
|
+
if (isIAB == 1) {
|
370
|
+
NSMutableDictionary *result = [[NSMutableDictionary alloc] init];
|
371
|
+
NSUserDefaults *prefs = [NSUserDefaults standardUserDefaults];
|
372
|
+
|
373
|
+
NSNumber *CmpSdkID = [prefs valueForKey:@"IABTCF_CmpSdkID"];
|
374
|
+
NSString *gdprApplies = [prefs stringForKey:@"IABTCF_gdprApplies"];
|
375
|
+
NSString *PurposeConsents = [prefs stringForKey:@"IABTCF_PurposeConsents"];
|
376
|
+
NSString *TCString = [prefs stringForKey:@"IABTCF_TCString"];
|
377
|
+
|
378
|
+
result[@"IABTCF_CmpSdkID"] = CmpSdkID;
|
379
|
+
result[@"IABTCF_gdprApplies"] = gdprApplies;
|
380
|
+
result[@"IABTCF_PurposeConsents"] = PurposeConsents;
|
381
|
+
result[@"IABTCF_TCString"] = TCString;
|
382
|
+
|
383
|
+
[prefs synchronize];
|
384
|
+
|
385
|
+
NSLog(@"%@", [prefs dictionaryRepresentation]);
|
386
|
+
|
387
|
+
pluginResult = [CDVPluginResult resultWithStatus:CDVCommandStatus_OK messageAsDictionary:result];
|
388
|
+
[self fireEvent:@"" event:@"onGetIabTfc" withData:nil];
|
389
|
+
} else {
|
390
|
+
pluginResult = [CDVPluginResult resultWithStatus:CDVCommandStatus_ERROR];
|
391
|
+
}
|
392
|
+
|
393
|
+
[self.commandDelegate sendPluginResult:pluginResult callbackId:callbackId];
|
624
394
|
}
|
395
|
+
|
625
396
|
- (void)consentReset:(CDVInvokedUrlCommand *)command {
|
626
397
|
CDVPluginResult *pluginResult;
|
627
398
|
NSString *callbackId = command.callbackId;
|
@@ -1052,53 +823,126 @@ BOOL isUsingAdManagerRequest = YES;
|
|
1052
823
|
[self.commandDelegate sendPluginResult:pluginResult callbackId:callbackId];
|
1053
824
|
}
|
1054
825
|
- (void)loadAppOpenAd:(CDVInvokedUrlCommand *)command {
|
1055
|
-
|
1056
|
-
|
1057
|
-
|
1058
|
-
|
1059
|
-
|
1060
|
-
|
1061
|
-
|
1062
|
-
|
1063
|
-
|
1064
|
-
|
1065
|
-
|
1066
|
-
|
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
|
-
|
826
|
+
CDVPluginResult *pluginResult;
|
827
|
+
NSString *callbackId = command.callbackId;
|
828
|
+
|
829
|
+
NSDictionary *options = [command.arguments objectAtIndex:0];
|
830
|
+
NSString *adUnitId = [options valueForKey:@"adUnitId"];
|
831
|
+
BOOL autoShow = [[options valueForKey:@"autoShow"] boolValue];
|
832
|
+
|
833
|
+
auto_Show = autoShow;
|
834
|
+
adFormat = 1;
|
835
|
+
self.appOpenAd = nil;
|
836
|
+
|
837
|
+
if (adFormat == 1) {
|
838
|
+
dispatch_async(dispatch_get_main_queue(), ^{
|
839
|
+
GADRequest *request = [GADRequest request];
|
840
|
+
GADExtras *extras = [[GADExtras alloc] init];
|
841
|
+
[request registerAdNetworkExtras:extras];
|
842
|
+
|
843
|
+
[GADAppOpenAd loadWithAdUnitID:adUnitId request:request completionHandler:^(GADAppOpenAd *ad, NSError *error) {
|
844
|
+
if (error) {
|
845
|
+
// Send load error to event
|
846
|
+
NSDictionary *errorData = @{@"error": error.localizedDescription ?: @"Unknown error"};
|
847
|
+
NSData *errorJsonData = [NSJSONSerialization dataWithJSONObject:errorData options:0 error:nil];
|
848
|
+
NSString *errorJsonString = [[NSString alloc] initWithData:errorJsonData encoding:NSUTF8StringEncoding];
|
849
|
+
|
850
|
+
[self fireEvent:@"" event:@"on.appOpenAd.failed.loaded" withData:errorJsonString];
|
851
|
+
return;
|
852
|
+
}
|
853
|
+
|
854
|
+
self.appOpenAd = ad;
|
855
|
+
self.appOpenAd.fullScreenContentDelegate = self;
|
856
|
+
[self fireEvent:@"" event:@"on.appOpenAd.loaded" withData:nil];
|
857
|
+
|
858
|
+
|
859
|
+
|
860
|
+
__weak __typeof(self) weakSelf = self;
|
861
|
+
self.appOpenAd.paidEventHandler = ^(GADAdValue *_Nonnull value) {
|
862
|
+
__strong __typeof(weakSelf) strongSelf = weakSelf;
|
863
|
+
if (!strongSelf) return;
|
864
|
+
|
865
|
+
NSDecimalNumber *adValue = value.value;
|
866
|
+
NSString *currencyCode = value.currencyCode;
|
867
|
+
GADAdValuePrecision precision = value.precision;
|
868
|
+
|
869
|
+
NSString *adUnitId = strongSelf.appOpenAd.adUnitID;
|
870
|
+
|
871
|
+
NSDictionary *data = @{
|
872
|
+
@"value": adValue,
|
873
|
+
@"currencyCode": currencyCode,
|
874
|
+
@"precision": @(precision),
|
875
|
+
@"adUnitId": adUnitId
|
876
|
+
};
|
877
|
+
NSData *jsonData = [NSJSONSerialization dataWithJSONObject:data options:0 error:nil];
|
878
|
+
NSString *jsonString = [[NSString alloc] initWithData:jsonData encoding:NSUTF8StringEncoding];
|
879
|
+
|
880
|
+
[strongSelf fireEvent:@"" event:@"on.appOpenAd.revenue" withData:jsonString];
|
881
|
+
};
|
882
|
+
|
883
|
+
|
884
|
+
|
885
|
+
|
886
|
+
|
887
|
+
if (auto_Show) {
|
888
|
+
NSError *presentError = nil;
|
889
|
+
if ([self.appOpenAd canPresentFromRootViewController:self.viewController error:&presentError]) {
|
890
|
+
[self.appOpenAd presentFromRootViewController:self.viewController];
|
891
|
+
} else {
|
892
|
+
// Send show error to event
|
893
|
+
NSDictionary *errorData = @{@"error": presentError.localizedDescription ?: @"Unknown error"};
|
894
|
+
NSData *errorJsonData = [NSJSONSerialization dataWithJSONObject:errorData options:0 error:nil];
|
895
|
+
NSString *errorJsonString = [[NSString alloc] initWithData:errorJsonData encoding:NSUTF8StringEncoding];
|
896
|
+
|
897
|
+
[self fireEvent:@"" event:@"on.appOpenAd.failed.show" withData:errorJsonString];
|
898
|
+
}
|
899
|
+
}
|
900
|
+
|
901
|
+
|
902
|
+
if (ResponseInfo) {
|
903
|
+
GADResponseInfo *responseInfo = ad.responseInfo;
|
904
|
+
NSMutableArray *adNetworkInfoArray = [NSMutableArray array];
|
905
|
+
|
906
|
+
for (GADAdNetworkResponseInfo *adNetworkResponseInfo in responseInfo.adNetworkInfoArray) {
|
907
|
+
NSDictionary *adNetworkInfo = @{
|
908
|
+
@"adSourceId": adNetworkResponseInfo.adSourceID ?: @"",
|
909
|
+
@"adSourceInstanceId": adNetworkResponseInfo.adSourceInstanceID ?: @"",
|
910
|
+
@"adSourceInstanceName": adNetworkResponseInfo.adSourceInstanceName ?: @"",
|
911
|
+
@"adSourceName": adNetworkResponseInfo.adSourceName ?: @"",
|
912
|
+
@"adNetworkClassName": adNetworkResponseInfo.adNetworkClassName ?: @"",
|
913
|
+
@"adUnitMapping": adNetworkResponseInfo.adUnitMapping ?: @{},
|
914
|
+
@"latency": @(adNetworkResponseInfo.latency)
|
915
|
+
};
|
916
|
+
[adNetworkInfoArray addObject:adNetworkInfo];
|
917
|
+
}
|
918
|
+
|
919
|
+
NSDictionary *responseInfoData = @{
|
920
|
+
@"responseIdentifier": responseInfo.responseIdentifier ?: @"",
|
921
|
+
@"adNetworkInfoArray": adNetworkInfoArray
|
922
|
+
};
|
923
|
+
|
924
|
+
|
925
|
+
NSError *jsonError = nil;
|
926
|
+
NSData *jsonResponseData = [NSJSONSerialization dataWithJSONObject:responseInfoData options:0 error:&jsonError];
|
927
|
+
if (!jsonError) {
|
928
|
+
NSString *jsonResponseString = [[NSString alloc] initWithData:jsonResponseData encoding:NSUTF8StringEncoding];
|
929
|
+
[self fireEvent:@"" event:@"on.appOpenAd.responseInfo" withData:jsonResponseString];
|
930
|
+
} else {
|
931
|
+
NSLog(@"Error converting response info to JSON: %@", jsonError.localizedDescription);
|
932
|
+
}
|
933
|
+
}
|
934
|
+
|
935
|
+
|
936
|
+
|
937
|
+
}];
|
938
|
+
});
|
939
|
+
|
940
|
+
pluginResult = [CDVPluginResult resultWithStatus:CDVCommandStatus_OK];
|
941
|
+
}
|
942
|
+
|
943
|
+
[self.commandDelegate sendPluginResult:pluginResult callbackId:callbackId];
|
1101
944
|
}
|
945
|
+
|
1102
946
|
- (void)showAppOpenAd:(CDVInvokedUrlCommand *)command {
|
1103
947
|
CDVPluginResult *pluginResult;
|
1104
948
|
NSString *callbackId = command.callbackId;
|
@@ -1122,259 +966,484 @@ BOOL isUsingAdManagerRequest = YES;
|
|
1122
966
|
[self.commandDelegate sendPluginResult:pluginResult callbackId:callbackId];
|
1123
967
|
}
|
1124
968
|
- (void)loadInterstitialAd:(CDVInvokedUrlCommand *)command {
|
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
|
-
|
969
|
+
CDVPluginResult *pluginResult;
|
970
|
+
NSString *callbackId = command.callbackId;
|
971
|
+
|
972
|
+
NSDictionary *options = [command.arguments objectAtIndex:0];
|
973
|
+
NSString *adUnitId = [options valueForKey:@"adUnitId"];
|
974
|
+
BOOL autoShow = [[options valueForKey:@"autoShow"] boolValue];
|
975
|
+
|
976
|
+
auto_Show = autoShow;
|
977
|
+
adFormat = 2;
|
978
|
+
|
979
|
+
if (adFormat == 2) {
|
980
|
+
dispatch_async(dispatch_get_main_queue(), ^{
|
981
|
+
GADRequest *request = [GADRequest request];
|
982
|
+
[GADInterstitialAd loadWithAdUnitID:adUnitId request:request completionHandler:^(GADInterstitialAd *ad, NSError *error) {
|
983
|
+
if (error) {
|
984
|
+
// Send load error to event
|
985
|
+
NSDictionary *errorData = @{@"error": error.localizedDescription ?: @"Unknown error"};
|
986
|
+
NSData *errorJsonData = [NSJSONSerialization dataWithJSONObject:errorData options:0 error:nil];
|
987
|
+
NSString *errorJsonString = [[NSString alloc] initWithData:errorJsonData encoding:NSUTF8StringEncoding];
|
988
|
+
|
989
|
+
[self fireEvent:@"" event:@"on.interstitial.failed.load" withData:errorJsonString];
|
990
|
+
return;
|
991
|
+
}
|
992
|
+
|
993
|
+
self.interstitial = ad;
|
994
|
+
self.interstitial.fullScreenContentDelegate = self;
|
995
|
+
[self fireEvent:@"" event:@"on.interstitial.loaded" withData:nil];
|
996
|
+
|
997
|
+
|
998
|
+
__weak __typeof(self) weakSelf = self;
|
999
|
+
self.interstitial.paidEventHandler = ^(GADAdValue *_Nonnull value) {
|
1000
|
+
__strong __typeof(weakSelf) strongSelf = weakSelf;
|
1001
|
+
if (!strongSelf) return;
|
1002
|
+
|
1003
|
+
NSDecimalNumber *adValue = value.value;
|
1004
|
+
NSString *currencyCode = value.currencyCode;
|
1005
|
+
GADAdValuePrecision precision = value.precision;
|
1006
|
+
|
1007
|
+
NSString *adUnitId = strongSelf.interstitial.adUnitID;
|
1008
|
+
|
1009
|
+
NSDictionary *data = @{
|
1010
|
+
@"value": adValue,
|
1011
|
+
@"currencyCode": currencyCode,
|
1012
|
+
@"precision": @(precision),
|
1013
|
+
@"adUnitId": adUnitId
|
1014
|
+
};
|
1015
|
+
NSData *jsonData = [NSJSONSerialization dataWithJSONObject:data options:0 error:nil];
|
1016
|
+
NSString *jsonString = [[NSString alloc] initWithData:jsonData encoding:NSUTF8StringEncoding];
|
1017
|
+
|
1018
|
+
[strongSelf fireEvent:@"" event:@"on.interstitial.revenue" withData:jsonString];
|
1019
|
+
};
|
1020
|
+
|
1021
|
+
|
1022
|
+
if (auto_Show) {
|
1023
|
+
NSError *presentError = nil;
|
1024
|
+
if ([self.interstitial canPresentFromRootViewController:self.viewController error:&presentError]) {
|
1025
|
+
[self.interstitial presentFromRootViewController:self.viewController];
|
1026
|
+
} else {
|
1027
|
+
// Send present error to event
|
1028
|
+
NSDictionary *errorData = @{@"error": presentError.localizedDescription ?: @"Unknown error"};
|
1029
|
+
NSData *errorJsonData = [NSJSONSerialization dataWithJSONObject:errorData options:0 error:nil];
|
1030
|
+
NSString *errorJsonString = [[NSString alloc] initWithData:errorJsonData encoding:NSUTF8StringEncoding];
|
1031
|
+
|
1032
|
+
[self fireEvent:@"" event:@"on.interstitial.failed.show" withData:errorJsonString];
|
1033
|
+
}
|
1034
|
+
}
|
1035
|
+
|
1036
|
+
|
1037
|
+
|
1038
|
+
if (ResponseInfo) {
|
1039
|
+
GADResponseInfo *responseInfo = ad.responseInfo;
|
1040
|
+
NSMutableArray *adNetworkInfoArray = [NSMutableArray array];
|
1041
|
+
|
1042
|
+
for (GADAdNetworkResponseInfo *adNetworkResponseInfo in responseInfo.adNetworkInfoArray) {
|
1043
|
+
NSDictionary *adNetworkInfo = @{
|
1044
|
+
@"adSourceId": adNetworkResponseInfo.adSourceID ?: @"",
|
1045
|
+
@"adSourceInstanceId": adNetworkResponseInfo.adSourceInstanceID ?: @"",
|
1046
|
+
@"adSourceInstanceName": adNetworkResponseInfo.adSourceInstanceName ?: @"",
|
1047
|
+
@"adSourceName": adNetworkResponseInfo.adSourceName ?: @"",
|
1048
|
+
@"adNetworkClassName": adNetworkResponseInfo.adNetworkClassName ?: @"",
|
1049
|
+
@"adUnitMapping": adNetworkResponseInfo.adUnitMapping ?: @{},
|
1050
|
+
@"latency": @(adNetworkResponseInfo.latency)
|
1051
|
+
};
|
1052
|
+
[adNetworkInfoArray addObject:adNetworkInfo];
|
1053
|
+
}
|
1054
|
+
|
1055
|
+
NSDictionary *responseInfoData = @{
|
1056
|
+
@"responseIdentifier": responseInfo.responseIdentifier ?: @"",
|
1057
|
+
@"adNetworkInfoArray": adNetworkInfoArray
|
1058
|
+
};
|
1059
|
+
|
1060
|
+
|
1061
|
+
NSError *jsonError = nil;
|
1062
|
+
NSData *jsonResponseData = [NSJSONSerialization dataWithJSONObject:responseInfoData options:0 error:&jsonError];
|
1063
|
+
if (!jsonError) {
|
1064
|
+
NSString *jsonResponseString = [[NSString alloc] initWithData:jsonResponseData encoding:NSUTF8StringEncoding];
|
1065
|
+
[self fireEvent:@"" event:@"on.interstitialAd.responseInfo" withData:jsonResponseString];
|
1066
|
+
} else {
|
1067
|
+
NSLog(@"Error converting response info to JSON: %@", jsonError.localizedDescription);
|
1068
|
+
}
|
1069
|
+
}
|
1070
|
+
|
1071
|
+
|
1072
|
+
|
1073
|
+
}];
|
1074
|
+
});
|
1075
|
+
}
|
1076
|
+
|
1171
1077
|
pluginResult = [CDVPluginResult resultWithStatus:CDVCommandStatus_OK];
|
1172
|
-
|
1173
|
-
pluginResult = [CDVPluginResult resultWithStatus:CDVCommandStatus_ERROR];
|
1174
|
-
[self fireEvent:@""
|
1175
|
-
event:@"on."
|
1176
|
-
@"inte"
|
1177
|
-
@"rsti"
|
1178
|
-
@"tial"
|
1179
|
-
@".fai"
|
1180
|
-
@"led."
|
1181
|
-
@"show"
|
1182
|
-
withData:nil];
|
1183
|
-
}
|
1184
|
-
[self.commandDelegate sendPluginResult:pluginResult callbackId:callbackId];
|
1078
|
+
[self.commandDelegate sendPluginResult:pluginResult callbackId:callbackId];
|
1185
1079
|
}
|
1186
|
-
- (void)loadRewardedInterstitialAd:(CDVInvokedUrlCommand *)command {
|
1187
|
-
CDVPluginResult *pluginResult;
|
1188
|
-
NSString *callbackId = command.callbackId;
|
1189
1080
|
|
1190
|
-
|
1191
|
-
|
1192
|
-
|
1081
|
+
- (void)showInterstitialAd:(CDVInvokedUrlCommand *)command {
|
1082
|
+
CDVPluginResult *pluginResult;
|
1083
|
+
NSString *callbackId = command.callbackId;
|
1084
|
+
|
1085
|
+
NSError *presentError = nil;
|
1086
|
+
if (self.interstitial && [self.interstitial canPresentFromRootViewController:self.viewController error:&presentError]) {
|
1087
|
+
[self.interstitial presentFromRootViewController:self.viewController];
|
1088
|
+
pluginResult = [CDVPluginResult resultWithStatus:CDVCommandStatus_OK];
|
1089
|
+
} else {
|
1090
|
+
// Send show error to event
|
1091
|
+
NSDictionary *errorData = @{@"error": presentError.localizedDescription ?: @"Unknown error"};
|
1092
|
+
NSData *errorJsonData = [NSJSONSerialization dataWithJSONObject:errorData options:0 error:nil];
|
1093
|
+
NSString *errorJsonString = [[NSString alloc] initWithData:errorJsonData encoding:NSUTF8StringEncoding];
|
1094
|
+
|
1095
|
+
[self fireEvent:@"" event:@"on.interstitial.failed.show" withData:errorJsonString];
|
1096
|
+
pluginResult = [CDVPluginResult resultWithStatus:CDVCommandStatus_ERROR];
|
1097
|
+
}
|
1098
|
+
|
1099
|
+
[self.commandDelegate sendPluginResult:pluginResult callbackId:callbackId];
|
1100
|
+
}
|
1193
1101
|
|
1194
|
-
|
1195
|
-
|
1196
|
-
|
1197
|
-
|
1198
|
-
|
1199
|
-
|
1200
|
-
|
1201
|
-
|
1202
|
-
|
1203
|
-
|
1204
|
-
|
1205
|
-
|
1206
|
-
|
1207
|
-
|
1208
|
-
|
1209
|
-
|
1210
|
-
|
1211
|
-
|
1212
|
-
|
1213
|
-
|
1214
|
-
|
1215
|
-
|
1216
|
-
|
1217
|
-
|
1218
|
-
|
1219
|
-
|
1220
|
-
|
1221
|
-
|
1222
|
-
|
1223
|
-
|
1224
|
-
|
1225
|
-
|
1226
|
-
|
1227
|
-
|
1228
|
-
|
1229
|
-
|
1230
|
-
|
1231
|
-
|
1232
|
-
|
1233
|
-
|
1234
|
-
|
1235
|
-
|
1236
|
-
|
1237
|
-
|
1238
|
-
|
1239
|
-
|
1240
|
-
|
1241
|
-
|
1242
|
-
|
1243
|
-
|
1244
|
-
|
1245
|
-
|
1102
|
+
- (void)loadRewardedInterstitialAd:(CDVInvokedUrlCommand *)command {
|
1103
|
+
CDVPluginResult *pluginResult;
|
1104
|
+
NSString *callbackId = command.callbackId;
|
1105
|
+
|
1106
|
+
NSDictionary *options = [command.arguments objectAtIndex:0];
|
1107
|
+
NSString *adUnitId = [options valueForKey:@"adUnitId"];
|
1108
|
+
BOOL autoShow = [[options valueForKey:@"autoShow"] boolValue];
|
1109
|
+
|
1110
|
+
auto_Show = autoShow;
|
1111
|
+
adFormat = 4;
|
1112
|
+
|
1113
|
+
if (adFormat == 4) {
|
1114
|
+
dispatch_async(dispatch_get_main_queue(), ^{
|
1115
|
+
GADRequest *request = [GADRequest request];
|
1116
|
+
[GADRewardedInterstitialAd loadWithAdUnitID:adUnitId request:request completionHandler:^(GADRewardedInterstitialAd *ad, NSError *error) {
|
1117
|
+
if (error) {
|
1118
|
+
// Send error data to event
|
1119
|
+
NSDictionary *errorData = @{@"error": error.localizedDescription ?: @"Unknown error"};
|
1120
|
+
NSData *errorJsonData = [NSJSONSerialization dataWithJSONObject:errorData options:0 error:nil];
|
1121
|
+
NSString *errorJsonString = [[NSString alloc] initWithData:errorJsonData encoding:NSUTF8StringEncoding];
|
1122
|
+
|
1123
|
+
[self fireEvent:@"" event:@"on.rewardedInt.failed.load" withData:errorJsonString];
|
1124
|
+
return;
|
1125
|
+
}
|
1126
|
+
|
1127
|
+
self.rewardedInterstitialAd = ad;
|
1128
|
+
isAdSkip = 1;
|
1129
|
+
self.rewardedInterstitialAd.fullScreenContentDelegate = self;
|
1130
|
+
[self fireEvent:@"" event:@"on.rewardedInt.loaded" withData:nil];
|
1131
|
+
|
1132
|
+
|
1133
|
+
|
1134
|
+
__weak __typeof(self) weakSelf = self;
|
1135
|
+
self.rewardedInterstitialAd.paidEventHandler = ^(GADAdValue *_Nonnull value) {
|
1136
|
+
__strong __typeof(weakSelf) strongSelf = weakSelf;
|
1137
|
+
if (!strongSelf) return;
|
1138
|
+
|
1139
|
+
NSDecimalNumber *adValue = value.value;
|
1140
|
+
NSString *currencyCode = value.currencyCode;
|
1141
|
+
GADAdValuePrecision precision = value.precision;
|
1142
|
+
|
1143
|
+
NSString *adUnitId = strongSelf.rewardedInterstitialAd.adUnitID;
|
1144
|
+
|
1145
|
+
NSDictionary *data = @{
|
1146
|
+
@"value": adValue,
|
1147
|
+
@"currencyCode": currencyCode,
|
1148
|
+
@"precision": @(precision),
|
1149
|
+
@"adUnitId": adUnitId
|
1150
|
+
};
|
1151
|
+
NSData *jsonData = [NSJSONSerialization dataWithJSONObject:data options:0 error:nil];
|
1152
|
+
NSString *jsonString = [[NSString alloc] initWithData:jsonData encoding:NSUTF8StringEncoding];
|
1153
|
+
|
1154
|
+
[strongSelf fireEvent:@"" event:@"on.rewardedInt.revenue" withData:jsonString];
|
1155
|
+
};
|
1156
|
+
|
1157
|
+
|
1158
|
+
if (auto_Show) {
|
1159
|
+
NSError *presentError = nil;
|
1160
|
+
if ([self.rewardedInterstitialAd canPresentFromRootViewController:self.viewController error:&presentError]) {
|
1161
|
+
[self.rewardedInterstitialAd presentFromRootViewController:self.viewController userDidEarnRewardHandler:^{
|
1162
|
+
GADAdReward *reward = self.rewardedInterstitialAd.adReward;
|
1163
|
+
|
1164
|
+
// Prepare reward data as JSON
|
1165
|
+
NSDictionary *rewardData = @{
|
1166
|
+
@"currency": reward.type,
|
1167
|
+
@"amount": [reward.amount stringValue]
|
1168
|
+
};
|
1169
|
+
NSData *rewardJsonData = [NSJSONSerialization dataWithJSONObject:rewardData options:0 error:nil];
|
1170
|
+
NSString *rewardJsonString = [[NSString alloc] initWithData:rewardJsonData encoding:NSUTF8StringEncoding];
|
1171
|
+
|
1172
|
+
[self fireEvent:@"" event:@"on.rewardedInt.userEarnedReward" withData:rewardJsonString];
|
1173
|
+
isAdSkip = 2;
|
1174
|
+
NSLog(@"Reward received with currency %@, amount %ld", reward.type, [reward.amount longValue]);
|
1175
|
+
}];
|
1176
|
+
} else {
|
1177
|
+
// Send present error to event
|
1178
|
+
NSDictionary *errorData = @{@"error": presentError.localizedDescription ?: @"Unknown error"};
|
1179
|
+
NSData *errorJsonData = [NSJSONSerialization dataWithJSONObject:errorData options:0 error:nil];
|
1180
|
+
NSString *errorJsonString = [[NSString alloc] initWithData:errorJsonData encoding:NSUTF8StringEncoding];
|
1181
|
+
|
1182
|
+
[self fireEvent:@"" event:@"on.rewardedInt.failed.show" withData:errorJsonString];
|
1183
|
+
}
|
1184
|
+
|
1185
|
+
|
1186
|
+
if (ResponseInfo) {
|
1187
|
+
GADResponseInfo *responseInfo = ad.responseInfo;
|
1188
|
+
NSMutableArray *adNetworkInfoArray = [NSMutableArray array];
|
1189
|
+
|
1190
|
+
for (GADAdNetworkResponseInfo *adNetworkResponseInfo in responseInfo.adNetworkInfoArray) {
|
1191
|
+
NSDictionary *adNetworkInfo = @{
|
1192
|
+
@"adSourceId": adNetworkResponseInfo.adSourceID ?: @"",
|
1193
|
+
@"adSourceInstanceId": adNetworkResponseInfo.adSourceInstanceID ?: @"",
|
1194
|
+
@"adSourceInstanceName": adNetworkResponseInfo.adSourceInstanceName ?: @"",
|
1195
|
+
@"adSourceName": adNetworkResponseInfo.adSourceName ?: @"",
|
1196
|
+
@"adNetworkClassName": adNetworkResponseInfo.adNetworkClassName ?: @"",
|
1197
|
+
@"adUnitMapping": adNetworkResponseInfo.adUnitMapping ?: @{},
|
1198
|
+
@"latency": @(adNetworkResponseInfo.latency)
|
1199
|
+
};
|
1200
|
+
[adNetworkInfoArray addObject:adNetworkInfo];
|
1201
|
+
}
|
1202
|
+
|
1203
|
+
NSDictionary *responseInfoData = @{
|
1204
|
+
@"responseIdentifier": responseInfo.responseIdentifier ?: @"",
|
1205
|
+
@"adNetworkInfoArray": adNetworkInfoArray
|
1206
|
+
};
|
1207
|
+
|
1208
|
+
|
1209
|
+
NSError *jsonError = nil;
|
1210
|
+
NSData *jsonResponseData = [NSJSONSerialization dataWithJSONObject:responseInfoData options:0 error:&jsonError];
|
1211
|
+
if (!jsonError) {
|
1212
|
+
NSString *jsonResponseString = [[NSString alloc] initWithData:jsonResponseData encoding:NSUTF8StringEncoding];
|
1213
|
+
[self fireEvent:@"" event:@"on.rewardedIntAd.responseInfo" withData:jsonResponseString];
|
1214
|
+
} else {
|
1215
|
+
NSLog(@"Error converting response info to JSON: %@", jsonError.localizedDescription);
|
1216
|
+
}
|
1217
|
+
}
|
1218
|
+
|
1219
|
+
|
1220
|
+
|
1221
|
+
|
1222
|
+
}
|
1223
|
+
}];
|
1224
|
+
});
|
1225
|
+
}
|
1226
|
+
|
1227
|
+
pluginResult = [CDVPluginResult resultWithStatus:CDVCommandStatus_OK];
|
1228
|
+
[self.commandDelegate sendPluginResult:pluginResult callbackId:callbackId];
|
1246
1229
|
}
|
1230
|
+
|
1247
1231
|
- (void)showRewardedInterstitialAd:(CDVInvokedUrlCommand *)command {
|
1248
|
-
|
1249
|
-
|
1250
|
-
|
1251
|
-
|
1252
|
-
|
1253
|
-
|
1254
|
-
|
1255
|
-
presentFromRootViewController:self.viewController
|
1256
|
-
|
1257
|
-
|
1258
|
-
|
1259
|
-
|
1260
|
-
|
1261
|
-
|
1262
|
-
|
1263
|
-
|
1264
|
-
|
1265
|
-
|
1266
|
-
|
1267
|
-
|
1268
|
-
|
1269
|
-
|
1270
|
-
|
1271
|
-
|
1272
|
-
|
1273
|
-
|
1274
|
-
|
1275
|
-
|
1276
|
-
|
1277
|
-
|
1278
|
-
|
1279
|
-
|
1280
|
-
|
1281
|
-
|
1282
|
-
|
1283
|
-
[self.commandDelegate sendPluginResult:pluginResult callbackId:callbackId];
|
1232
|
+
CDVPluginResult *pluginResult;
|
1233
|
+
NSString *callbackId = command.callbackId;
|
1234
|
+
|
1235
|
+
NSError *presentError = nil;
|
1236
|
+
if (self.rewardedInterstitialAd &&
|
1237
|
+
[self.rewardedInterstitialAd canPresentFromRootViewController:self.viewController error:&presentError]) {
|
1238
|
+
|
1239
|
+
[self.rewardedInterstitialAd presentFromRootViewController:self.viewController userDidEarnRewardHandler:^{
|
1240
|
+
GADAdReward *reward = self.rewardedInterstitialAd.adReward;
|
1241
|
+
|
1242
|
+
// Prepare reward data as JSON
|
1243
|
+
NSDictionary *rewardData = @{
|
1244
|
+
@"currency": reward.type,
|
1245
|
+
@"amount": [reward.amount stringValue]
|
1246
|
+
};
|
1247
|
+
NSData *rewardJsonData = [NSJSONSerialization dataWithJSONObject:rewardData options:0 error:nil];
|
1248
|
+
NSString *rewardJsonString = [[NSString alloc] initWithData:rewardJsonData encoding:NSUTF8StringEncoding];
|
1249
|
+
|
1250
|
+
[self fireEvent:@"" event:@"on.rewardedInt.userEarnedReward" withData:rewardJsonString];
|
1251
|
+
isAdSkip = 2;
|
1252
|
+
NSLog(@"Reward received with currency %@, amount %ld", reward.type, [reward.amount longValue]);
|
1253
|
+
}];
|
1254
|
+
|
1255
|
+
pluginResult = [CDVPluginResult resultWithStatus:CDVCommandStatus_OK];
|
1256
|
+
} else {
|
1257
|
+
// Prepare error data as JSON
|
1258
|
+
NSDictionary *errorData = @{@"error": presentError.localizedDescription ?: @"Unknown error"};
|
1259
|
+
NSData *errorJsonData = [NSJSONSerialization dataWithJSONObject:errorData options:0 error:nil];
|
1260
|
+
NSString *errorJsonString = [[NSString alloc] initWithData:errorJsonData encoding:NSUTF8StringEncoding];
|
1261
|
+
|
1262
|
+
[self fireEvent:@"" event:@"on.rewardedInt.failed.show" withData:errorJsonString];
|
1263
|
+
pluginResult = [CDVPluginResult resultWithStatus:CDVCommandStatus_ERROR];
|
1264
|
+
}
|
1265
|
+
|
1266
|
+
[self.commandDelegate sendPluginResult:pluginResult callbackId:callbackId];
|
1284
1267
|
}
|
1268
|
+
|
1285
1269
|
- (void)loadRewardedAd:(CDVInvokedUrlCommand *)command {
|
1286
|
-
|
1287
|
-
|
1288
|
-
|
1289
|
-
|
1290
|
-
|
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
|
-
|
1270
|
+
CDVPluginResult *pluginResult;
|
1271
|
+
NSString *callbackId = command.callbackId;
|
1272
|
+
NSDictionary *options = [command.arguments objectAtIndex:0];
|
1273
|
+
NSString *adUnitId = [options valueForKey:@"adUnitId"];
|
1274
|
+
BOOL autoShow = [[options valueForKey:@"autoShow"] boolValue];
|
1275
|
+
auto_Show = autoShow;
|
1276
|
+
adFormat = 3;
|
1277
|
+
|
1278
|
+
if (adFormat == 3) {
|
1279
|
+
dispatch_async(dispatch_get_main_queue(), ^{
|
1280
|
+
GADRequest *request = [GADRequest request];
|
1281
|
+
|
1282
|
+
[GADRewardedAd loadWithAdUnitID:adUnitId request:request completionHandler:^(GADRewardedAd *ad, NSError *error) {
|
1283
|
+
if (error) {
|
1284
|
+
NSDictionary *errorData = @{@"error": error.localizedDescription ?: @"Unknown error"};
|
1285
|
+
NSData *jsonData = [NSJSONSerialization dataWithJSONObject:errorData options:0 error:nil];
|
1286
|
+
NSString *jsonString = [[NSString alloc] initWithData:jsonData encoding:NSUTF8StringEncoding];
|
1287
|
+
[self fireEvent:@"" event:@"on.rewarded.failed.load" withData:jsonString];
|
1288
|
+
return;
|
1289
|
+
}
|
1290
|
+
|
1291
|
+
self.rewardedAd = ad;
|
1292
|
+
|
1293
|
+
isAdSkip = 0;
|
1294
|
+
self.rewardedAd.fullScreenContentDelegate = self;
|
1295
|
+
[self fireEvent:@"" event:@"on.rewarded.loaded" withData:nil];
|
1296
|
+
|
1297
|
+
__weak __typeof(self) weakSelf = self;
|
1298
|
+
self.rewardedAd.paidEventHandler = ^(GADAdValue *_Nonnull value) {
|
1299
|
+
__strong __typeof(weakSelf) strongSelf = weakSelf;
|
1300
|
+
if (!strongSelf) return; // Pastikan strongSelf tidak null
|
1301
|
+
|
1302
|
+
// Mengambil data ad revenue
|
1303
|
+
NSDecimalNumber *adValue = value.value;
|
1304
|
+
NSString *currencyCode = value.currencyCode;
|
1305
|
+
GADAdValuePrecision precision = value.precision;
|
1306
|
+
|
1307
|
+
// Mendapatkan ID unit iklan
|
1308
|
+
NSString *adUnitId = strongSelf.rewardedAd.adUnitID;
|
1309
|
+
|
1310
|
+
// Mengirim data dalam format JSON
|
1311
|
+
NSDictionary *data = @{
|
1312
|
+
@"value": adValue,
|
1313
|
+
@"currencyCode": currencyCode,
|
1314
|
+
@"precision": @(precision),
|
1315
|
+
@"adUnitId": adUnitId
|
1316
|
+
};
|
1317
|
+
NSData *jsonData = [NSJSONSerialization dataWithJSONObject:data options:0 error:nil];
|
1318
|
+
NSString *jsonString = [[NSString alloc] initWithData:jsonData encoding:NSUTF8StringEncoding];
|
1319
|
+
|
1320
|
+
[strongSelf fireEvent:@"" event:@"on.rewarded.revenue" withData:jsonString];
|
1321
|
+
};
|
1322
|
+
|
1323
|
+
|
1324
|
+
|
1325
|
+
if (auto_Show) {
|
1326
|
+
NSError *presentError = nil;
|
1327
|
+
if ([self.rewardedAd canPresentFromRootViewController:self.viewController error:&presentError]) {
|
1328
|
+
[self.rewardedAd presentFromRootViewController:self.viewController userDidEarnRewardHandler:^{
|
1329
|
+
GADAdReward *reward = self.rewardedAd.adReward;
|
1330
|
+
|
1331
|
+
NSDictionary *rewardData = @{
|
1332
|
+
@"currency": reward.type,
|
1333
|
+
@"amount": [reward.amount stringValue]
|
1334
|
+
};
|
1335
|
+
NSData *rewardJsonData = [NSJSONSerialization dataWithJSONObject:rewardData options:0 error:nil];
|
1336
|
+
NSString *rewardJsonString = [[NSString alloc] initWithData:rewardJsonData encoding:NSUTF8StringEncoding];
|
1337
|
+
|
1338
|
+
[self fireEvent:@"" event:@"on.reward.userEarnedReward" withData:rewardJsonString];
|
1339
|
+
isAdSkip = 2;
|
1340
|
+
// NSLog(@"Reward diterima dengan currency %@, amount %lf", reward.type, [reward.amount doubleValue]);
|
1341
|
+
}];
|
1342
|
+
} else {
|
1343
|
+
NSDictionary *errorData = @{@"error": presentError.localizedDescription ?: @"Unknown error"};
|
1344
|
+
NSData *jsonData = [NSJSONSerialization dataWithJSONObject:errorData options:0 error:nil];
|
1345
|
+
NSString *jsonString = [[NSString alloc] initWithData:jsonData encoding:NSUTF8StringEncoding];
|
1346
|
+
[self fireEvent:@"" event:@"on.rewarded.failed.show" withData:jsonString];
|
1347
|
+
}
|
1348
|
+
|
1349
|
+
|
1350
|
+
if (ResponseInfo) {
|
1351
|
+
GADResponseInfo *responseInfo = ad.responseInfo;
|
1352
|
+
NSMutableArray *adNetworkInfoArray = [NSMutableArray array];
|
1353
|
+
|
1354
|
+
for (GADAdNetworkResponseInfo *adNetworkResponseInfo in responseInfo.adNetworkInfoArray) {
|
1355
|
+
NSDictionary *adNetworkInfo = @{
|
1356
|
+
@"adSourceId": adNetworkResponseInfo.adSourceID ?: @"",
|
1357
|
+
@"adSourceInstanceId": adNetworkResponseInfo.adSourceInstanceID ?: @"",
|
1358
|
+
@"adSourceInstanceName": adNetworkResponseInfo.adSourceInstanceName ?: @"",
|
1359
|
+
@"adSourceName": adNetworkResponseInfo.adSourceName ?: @"",
|
1360
|
+
@"adNetworkClassName": adNetworkResponseInfo.adNetworkClassName ?: @"",
|
1361
|
+
@"adUnitMapping": adNetworkResponseInfo.adUnitMapping ?: @{},
|
1362
|
+
@"latency": @(adNetworkResponseInfo.latency)
|
1363
|
+
};
|
1364
|
+
[adNetworkInfoArray addObject:adNetworkInfo];
|
1365
|
+
}
|
1366
|
+
|
1367
|
+
NSDictionary *responseInfoData = @{
|
1368
|
+
@"responseIdentifier": responseInfo.responseIdentifier ?: @"",
|
1369
|
+
@"adNetworkInfoArray": adNetworkInfoArray
|
1370
|
+
};
|
1371
|
+
|
1372
|
+
|
1373
|
+
NSError *jsonError = nil;
|
1374
|
+
NSData *jsonResponseData = [NSJSONSerialization dataWithJSONObject:responseInfoData options:0 error:&jsonError];
|
1375
|
+
if (!jsonError) {
|
1376
|
+
NSString *jsonResponseString = [[NSString alloc] initWithData:jsonResponseData encoding:NSUTF8StringEncoding];
|
1377
|
+
[self fireEvent:@"" event:@"on.rewardedAd.responseInfo" withData:jsonResponseString];
|
1378
|
+
} else {
|
1379
|
+
NSLog(@"Error converting response info to JSON: %@", jsonError.localizedDescription);
|
1380
|
+
}
|
1381
|
+
}
|
1382
|
+
|
1383
|
+
|
1384
|
+
}
|
1385
|
+
}];
|
1386
|
+
});
|
1387
|
+
}
|
1388
|
+
|
1389
|
+
pluginResult = [CDVPluginResult resultWithStatus:CDVCommandStatus_OK];
|
1390
|
+
[self.commandDelegate sendPluginResult:pluginResult callbackId:callbackId];
|
1341
1391
|
}
|
1392
|
+
|
1342
1393
|
- (void)showRewardedAd:(CDVInvokedUrlCommand *)command {
|
1343
|
-
|
1344
|
-
|
1345
|
-
|
1346
|
-
|
1347
|
-
|
1348
|
-
|
1349
|
-
|
1350
|
-
|
1351
|
-
|
1352
|
-
|
1353
|
-
|
1354
|
-
|
1355
|
-
|
1356
|
-
|
1357
|
-
|
1358
|
-
|
1359
|
-
|
1360
|
-
|
1361
|
-
|
1362
|
-
|
1363
|
-
|
1364
|
-
|
1365
|
-
|
1366
|
-
|
1367
|
-
|
1368
|
-
|
1369
|
-
|
1370
|
-
|
1371
|
-
|
1372
|
-
|
1373
|
-
|
1374
|
-
|
1375
|
-
|
1376
|
-
|
1394
|
+
CDVPluginResult *pluginResult;
|
1395
|
+
NSString *callbackId = command.callbackId;
|
1396
|
+
|
1397
|
+
if (self.rewardedAd) {
|
1398
|
+
NSError *presentError = nil;
|
1399
|
+
if ([self.rewardedAd canPresentFromRootViewController:self.viewController error:&presentError]) {
|
1400
|
+
[self.rewardedAd presentFromRootViewController:self.viewController
|
1401
|
+
userDidEarnRewardHandler:^{
|
1402
|
+
GADAdReward *reward = self.rewardedAd.adReward;
|
1403
|
+
|
1404
|
+
NSDictionary *rewardData = @{
|
1405
|
+
@"currency": reward.type,
|
1406
|
+
@"amount": [reward.amount stringValue]
|
1407
|
+
};
|
1408
|
+
NSError *jsonError;
|
1409
|
+
NSData *jsonData = [NSJSONSerialization dataWithJSONObject:rewardData options:0 error:&jsonError];
|
1410
|
+
|
1411
|
+
if (jsonData) {
|
1412
|
+
NSString *jsonString = [[NSString alloc] initWithData:jsonData encoding:NSUTF8StringEncoding];
|
1413
|
+
[self fireEvent:@"" event:@"on.reward.userEarnedReward" withData:jsonString];
|
1414
|
+
} else {
|
1415
|
+
[self fireEvent:@"" event:@"on.reward.userEarnedReward" withData:nil];
|
1416
|
+
}
|
1417
|
+
|
1418
|
+
isAdSkip = 2;
|
1419
|
+
|
1420
|
+
|
1421
|
+
NSLog(@"Reward received with currency %@, amount %lf", reward.type, [reward.amount doubleValue]);
|
1422
|
+
}];
|
1423
|
+
|
1424
|
+
pluginResult = [CDVPluginResult resultWithStatus:CDVCommandStatus_OK];
|
1425
|
+
} else {
|
1426
|
+
|
1427
|
+
pluginResult = [CDVPluginResult resultWithStatus:CDVCommandStatus_ERROR];
|
1428
|
+
NSDictionary *errorData = @{@"error": presentError.localizedDescription ?: @"Unknown error"};
|
1429
|
+
NSError *jsonError;
|
1430
|
+
NSData *jsonData = [NSJSONSerialization dataWithJSONObject:errorData options:0 error:&jsonError];
|
1431
|
+
|
1432
|
+
if (jsonData && !jsonError) {
|
1433
|
+
NSString *jsonString = [[NSString alloc] initWithData:jsonData encoding:NSUTF8StringEncoding];
|
1434
|
+
[self fireEvent:@"" event:@"on.rewarded.failed.show" withData:jsonString];
|
1435
|
+
} else {
|
1436
|
+
[self fireEvent:@"" event:@"on.rewarded.failed.show" withData:nil];
|
1437
|
+
}
|
1438
|
+
}
|
1439
|
+
} else {
|
1440
|
+
pluginResult = [CDVPluginResult resultWithStatus:CDVCommandStatus_ERROR];
|
1441
|
+
[self fireEvent:@"" event:@"on.rewarded.failed.show" withData:nil];
|
1442
|
+
}
|
1443
|
+
|
1444
|
+
[self.commandDelegate sendPluginResult:pluginResult callbackId:callbackId];
|
1377
1445
|
}
|
1446
|
+
|
1378
1447
|
- (void)fireEvent:(NSString *)obj
|
1379
1448
|
event:(NSString *)eventName
|
1380
1449
|
withData:(NSString *)jsonStr {
|
@@ -1446,330 +1515,185 @@ BOOL isUsingAdManagerRequest = YES;
|
|
1446
1515
|
}
|
1447
1516
|
|
1448
1517
|
#pragma mark GADBannerViewDelegate implementation
|
1449
|
-
- (void)bannerViewDidReceiveAd:(GADBannerView *)bannerView {
|
1450
1518
|
|
1451
|
-
|
1452
|
-
|
1453
|
-
|
1454
|
-
|
1455
|
-
|
1456
|
-
|
1457
|
-
|
1458
|
-
|
1459
|
-
|
1460
|
-
|
1461
|
-
} else {
|
1462
|
-
NSString *jsonString = [[NSString alloc] initWithData:jsonData
|
1463
|
-
encoding:NSUTF8StringEncoding];
|
1464
|
-
[self fireEvent:@"" event:@"on.is.collapsible" withData:jsonString];
|
1465
|
-
}
|
1519
|
+
- (void)bannerViewDidReceiveAd:(GADBannerView *)bannerView {
|
1520
|
+
NSString *collapsibleStatus = bannerView.isCollapsible ? @"collapsible" : @"not collapsible";
|
1521
|
+
NSDictionary *eventData = @{@"collapsible" : collapsibleStatus};
|
1522
|
+
NSError *error;
|
1523
|
+
NSData *jsonData = [NSJSONSerialization dataWithJSONObject:eventData options:0 error:&error];
|
1524
|
+
|
1525
|
+
if (jsonData) {
|
1526
|
+
NSString *jsonString = [[NSString alloc] initWithData:jsonData encoding:NSUTF8StringEncoding];
|
1527
|
+
[self fireEvent:@"" event:@"on.is.collapsible" withData:jsonString];
|
1528
|
+
}
|
1466
1529
|
|
1467
|
-
|
1468
|
-
|
1469
|
-
|
1470
|
-
|
1471
|
-
|
1530
|
+
[self fireEvent:@"" event:@"on.banner.load" withData:nil];
|
1531
|
+
|
1532
|
+
|
1533
|
+
if (auto_Show && self.bannerView) {
|
1534
|
+
[self addBannerViewToView:command];
|
1535
|
+
self.bannerView.hidden = NO;
|
1536
|
+
} else {
|
1537
|
+
[self fireEvent:@"" event:@"on.banner.failed.show" withData:nil];
|
1538
|
+
}
|
1539
|
+
|
1540
|
+
|
1541
|
+
__weak __typeof(self) weakSelf = self;
|
1542
|
+
self.bannerView.paidEventHandler = ^(GADAdValue *_Nonnull value) {
|
1543
|
+
__strong __typeof(weakSelf) strongSelf = weakSelf;
|
1544
|
+
if (!strongSelf) return;
|
1545
|
+
|
1546
|
+
NSDecimalNumber *adValue = value.value;
|
1547
|
+
NSString *currencyCode = value.currencyCode;
|
1548
|
+
GADAdValuePrecision precision = value.precision;
|
1549
|
+
|
1550
|
+
NSString *adUnitId = strongSelf.bannerView.adUnitID;
|
1551
|
+
|
1552
|
+
NSDictionary *data = @{
|
1553
|
+
@"value": adValue,
|
1554
|
+
@"currencyCode": currencyCode,
|
1555
|
+
@"precision": @(precision),
|
1556
|
+
@"adUnitId": adUnitId
|
1557
|
+
};
|
1558
|
+
NSData *jsonData = [NSJSONSerialization dataWithJSONObject:data options:0 error:nil];
|
1559
|
+
NSString *jsonString = [[NSString alloc] initWithData:jsonData encoding:NSUTF8StringEncoding];
|
1560
|
+
|
1561
|
+
[strongSelf fireEvent:@"" event:@"on.banner.revenue" withData:jsonString];
|
1562
|
+
};
|
1563
|
+
|
1564
|
+
|
1565
|
+
|
1566
|
+
|
1567
|
+
|
1568
|
+
|
1569
|
+
if (ResponseInfo) {
|
1570
|
+
GADResponseInfo *responseInfo = self.bannerView.responseInfo;
|
1571
|
+
NSMutableArray *adNetworkInfoArray = [NSMutableArray array];
|
1572
|
+
|
1573
|
+
for (GADAdNetworkResponseInfo *adNetworkResponseInfo in responseInfo.adNetworkInfoArray) {
|
1574
|
+
NSDictionary *adNetworkInfo = @{
|
1575
|
+
@"adSourceId": adNetworkResponseInfo.adSourceID ?: @"",
|
1576
|
+
@"adSourceInstanceId": adNetworkResponseInfo.adSourceInstanceID ?: @"",
|
1577
|
+
@"adSourceInstanceName": adNetworkResponseInfo.adSourceInstanceName ?: @"",
|
1578
|
+
@"adSourceName": adNetworkResponseInfo.adSourceName ?: @"",
|
1579
|
+
@"adNetworkClassName": adNetworkResponseInfo.adNetworkClassName ?: @"",
|
1580
|
+
@"adUnitMapping": adNetworkResponseInfo.adUnitMapping ?: @{},
|
1581
|
+
@"latency": @(adNetworkResponseInfo.latency)
|
1582
|
+
};
|
1583
|
+
[adNetworkInfoArray addObject:adNetworkInfo];
|
1584
|
+
}
|
1472
1585
|
|
1473
|
-
|
1474
|
-
|
1475
|
-
|
1476
|
-
|
1586
|
+
NSDictionary *responseInfoData = @{
|
1587
|
+
@"responseIdentifier": responseInfo.responseIdentifier ?: @"",
|
1588
|
+
@"adNetworkInfoArray": adNetworkInfoArray
|
1589
|
+
};
|
1590
|
+
|
1591
|
+
|
1592
|
+
NSError *jsonError = nil;
|
1593
|
+
NSData *jsonResponseData = [NSJSONSerialization dataWithJSONObject:responseInfoData options:0 error:&jsonError];
|
1594
|
+
if (!jsonError) {
|
1595
|
+
NSString *jsonResponseString = [[NSString alloc] initWithData:jsonResponseData encoding:NSUTF8StringEncoding];
|
1596
|
+
[self fireEvent:@"" event:@"on.bannerAd.responseInfo" withData:jsonResponseString];
|
1597
|
+
} else {
|
1598
|
+
NSLog(@"Error converting response info to JSON: %@", jsonError.localizedDescription);
|
1599
|
+
}
|
1477
1600
|
}
|
1478
|
-
|
1479
|
-
|
1480
|
-
event:@"on."
|
1481
|
-
@"bann"
|
1482
|
-
@"er."
|
1483
|
-
@"fail"
|
1484
|
-
@"ed."
|
1485
|
-
@"show"
|
1486
|
-
withData:nil];
|
1487
|
-
}
|
1601
|
+
|
1602
|
+
|
1488
1603
|
}
|
1489
|
-
- (void)bannerView:(GADBannerView *)bannerView
|
1490
|
-
didFailToReceiveAdWithError:(NSError *)error {
|
1491
|
-
[self fireEvent:@""
|
1492
|
-
event:@"on."
|
1493
|
-
@"banner"
|
1494
|
-
@".faile"
|
1495
|
-
@"d.load"
|
1496
|
-
withData:nil];
|
1497
1604
|
|
1605
|
+
- (void)bannerView:(GADBannerView *)bannerView didFailToReceiveAdWithError:(NSError *)error {
|
1606
|
+
NSDictionary *errorData = @{
|
1607
|
+
@"code": @(error.code),
|
1608
|
+
@"message": error.localizedDescription
|
1609
|
+
};
|
1610
|
+
|
1611
|
+
NSError *jsonError;
|
1612
|
+
NSData *jsonData = [NSJSONSerialization dataWithJSONObject:errorData options:0 error:&jsonError];
|
1613
|
+
|
1614
|
+
if (jsonData) {
|
1615
|
+
NSString *jsonString = [[NSString alloc] initWithData:jsonData encoding:NSUTF8StringEncoding];
|
1616
|
+
[self fireEvent:@"" event:@"on.banner.failed.load" withData:jsonString];
|
1617
|
+
} else {
|
1618
|
+
// Fallback in case of JSON serialization failure
|
1619
|
+
[self fireEvent:@"" event:@"on.banner.failed.load" withData:error.localizedDescription];
|
1620
|
+
}
|
1498
1621
|
}
|
1499
|
-
- (void)bannerViewDidRecordImpression:(GADBannerView *)bannerView {
|
1500
|
-
[self fireEvent:@""
|
1501
|
-
event:@"on."
|
1502
|
-
@"banner"
|
1503
|
-
@".impre"
|
1504
|
-
@"ssion"
|
1505
|
-
withData:nil];
|
1506
1622
|
|
1623
|
+
|
1624
|
+
- (void)bannerViewDidRecordImpression:(GADBannerView *)bannerView {
|
1625
|
+
[self fireEvent:@"" event:@"on.banner.impression" withData:nil];
|
1507
1626
|
}
|
1508
|
-
- (void)bannerViewWillPresentScreen:(GADBannerView *)bannerView {
|
1509
|
-
[self fireEvent:@""
|
1510
|
-
event:@"on."
|
1511
|
-
@"banner"
|
1512
|
-
@".open"
|
1513
|
-
withData:nil];
|
1514
1627
|
|
1628
|
+
- (void)bannerViewWillPresentScreen:(GADBannerView *)bannerView {
|
1629
|
+
[self fireEvent:@"" event:@"on.banner.open" withData:nil];
|
1515
1630
|
}
|
1516
|
-
- (void)bannerViewWillDismissScreen:(GADBannerView *)bannerView {
|
1517
|
-
[self fireEvent:@""
|
1518
|
-
event:@"on."
|
1519
|
-
@"banner"
|
1520
|
-
@".close"
|
1521
|
-
withData:nil];
|
1522
1631
|
|
1632
|
+
- (void)bannerViewWillDismissScreen:(GADBannerView *)bannerView {
|
1633
|
+
[self fireEvent:@"" event:@"on.banner.close" withData:nil];
|
1523
1634
|
}
|
1635
|
+
|
1524
1636
|
- (void)bannerViewDidDismissScreen:(GADBannerView *)bannerView {
|
1525
|
-
|
1526
|
-
event:@"on."
|
1527
|
-
@"banner"
|
1528
|
-
@".did."
|
1529
|
-
@"dismis"
|
1530
|
-
@"s"
|
1531
|
-
withData:nil];
|
1532
|
-
|
1637
|
+
[self fireEvent:@"" event:@"on.banner.did.dismiss" withData:nil];
|
1533
1638
|
}
|
1639
|
+
|
1534
1640
|
#pragma GADFullScreeContentDelegate implementation
|
1641
|
+
|
1535
1642
|
- (void)adWillPresentFullScreenContent:(id)ad {
|
1536
|
-
|
1537
|
-
|
1538
|
-
|
1539
|
-
|
1540
|
-
|
1541
|
-
|
1542
|
-
|
1543
|
-
|
1544
|
-
|
1545
|
-
|
1546
|
-
|
1547
|
-
|
1548
|
-
@"Open Ad.");
|
1549
|
-
*/
|
1550
|
-
} else if (adFormat == 2) {
|
1551
|
-
[self fireEvent:@""
|
1552
|
-
event:@"on."
|
1553
|
-
@"inte"
|
1554
|
-
@"rsti"
|
1555
|
-
@"tial"
|
1556
|
-
@".sho"
|
1557
|
-
@"w"
|
1558
|
-
withData:nil];
|
1559
|
-
[self fireEvent:@""
|
1560
|
-
event:@"onPr"
|
1561
|
-
@"esen"
|
1562
|
-
@"tAd"
|
1563
|
-
withData:nil];
|
1564
|
-
/* NSLog(@"Ad will "
|
1565
|
-
@"present "
|
1566
|
-
@"full screen "
|
1567
|
-
@"content "
|
1568
|
-
@"interstitial"
|
1569
|
-
@"."); */
|
1570
|
-
} else if (adFormat == 3) {
|
1571
|
-
[self fireEvent:@""
|
1572
|
-
event:@"on."
|
1573
|
-
@"rewa"
|
1574
|
-
@"rded"
|
1575
|
-
@".sho"
|
1576
|
-
@"w"
|
1577
|
-
withData:nil];
|
1578
|
-
isAdSkip = 1;
|
1579
|
-
/* NSLog(@"Ad will "
|
1580
|
-
@"present "
|
1581
|
-
@"full screen "
|
1582
|
-
@"content "
|
1583
|
-
@"rewarded."); */
|
1584
|
-
} else if (adFormat == 4) {
|
1585
|
-
isAdSkip = 1;
|
1586
|
-
[self fireEvent:@""
|
1587
|
-
event:@"on."
|
1588
|
-
@"rewa"
|
1589
|
-
@"rded"
|
1590
|
-
@"Int."
|
1591
|
-
@"show"
|
1592
|
-
@"ed"
|
1593
|
-
withData:nil];
|
1594
|
-
/* NSLog(@"Ad will "
|
1595
|
-
@"present "
|
1596
|
-
@"full screen "
|
1597
|
-
@"content "
|
1598
|
-
@"interstitial"
|
1599
|
-
@" rewarded."); */
|
1600
|
-
}
|
1643
|
+
if (adFormat == 1) {
|
1644
|
+
[self fireEvent:@"" event:@"on.appOpenAd.show" withData:nil];
|
1645
|
+
} else if (adFormat == 2) {
|
1646
|
+
[self fireEvent:@"" event:@"on.interstitial.show" withData:nil];
|
1647
|
+
[self fireEvent:@"" event:@"onPresentAd" withData:nil];
|
1648
|
+
} else if (adFormat == 3) {
|
1649
|
+
[self fireEvent:@"" event:@"on.rewarded.show" withData:nil];
|
1650
|
+
isAdSkip = 1;
|
1651
|
+
} else if (adFormat == 4) {
|
1652
|
+
isAdSkip = 1;
|
1653
|
+
[self fireEvent:@"" event:@"on.rewardedInt.showed" withData:nil];
|
1654
|
+
}
|
1601
1655
|
}
|
1656
|
+
|
1602
1657
|
- (void)ad:(id)ad didFailToPresentFullScreenContentWithError:(NSError *)error {
|
1603
|
-
|
1604
|
-
|
1605
|
-
|
1606
|
-
|
1607
|
-
|
1608
|
-
|
1609
|
-
|
1610
|
-
|
1611
|
-
|
1612
|
-
|
1613
|
-
|
1614
|
-
|
1615
|
-
|
1616
|
-
|
1617
|
-
|
1618
|
-
|
1619
|
-
|
1620
|
-
|
1621
|
-
[error localizedDescription]); */
|
1622
|
-
} else if (adFormat == 2) {
|
1623
|
-
[self fireEvent:@""
|
1624
|
-
event:@"on."
|
1625
|
-
@"inte"
|
1626
|
-
@"rsti"
|
1627
|
-
@"tial"
|
1628
|
-
@".fai"
|
1629
|
-
@"led."
|
1630
|
-
@"load"
|
1631
|
-
withData:nil];
|
1632
|
-
/* NSLog(@"Ad failed "
|
1633
|
-
@"to present "
|
1634
|
-
@"full screen "
|
1635
|
-
@"content "
|
1636
|
-
@"with error "
|
1637
|
-
@"interstitial"
|
1638
|
-
@" %@.",
|
1639
|
-
[error localizedDescription]); */
|
1640
|
-
} else if (adFormat == 3) {
|
1641
|
-
[self fireEvent:@""
|
1642
|
-
event:@"on."
|
1643
|
-
@"rewa"
|
1644
|
-
@"rded"
|
1645
|
-
@".fai"
|
1646
|
-
@"led."
|
1647
|
-
@"load"
|
1648
|
-
withData:nil];
|
1649
|
-
/* NSLog(@"Ad failed "
|
1650
|
-
@"to present "
|
1651
|
-
@"full screen "
|
1652
|
-
@"content "
|
1653
|
-
@"with error "
|
1654
|
-
@"rewarded "
|
1655
|
-
@"%@.",
|
1656
|
-
[error localizedDescription]); */
|
1657
|
-
} else if (adFormat == 4) {
|
1658
|
-
[self fireEvent:@""
|
1659
|
-
event:@"on."
|
1660
|
-
@"rewa"
|
1661
|
-
@"rded"
|
1662
|
-
@"Int."
|
1663
|
-
@"fail"
|
1664
|
-
@"ed."
|
1665
|
-
@"load"
|
1666
|
-
withData:nil];
|
1667
|
-
/* NSLog(@"Ad failed "
|
1668
|
-
@"to present "
|
1669
|
-
@"full screen "
|
1670
|
-
@"content "
|
1671
|
-
@"with error "
|
1672
|
-
@"interstitial"
|
1673
|
-
@" "
|
1674
|
-
@"rewarded "
|
1675
|
-
@"%@.",
|
1676
|
-
[error localizedDescription]); */
|
1677
|
-
}
|
1658
|
+
NSDictionary *errorData = @{
|
1659
|
+
@"code": @(error.code),
|
1660
|
+
@"message": error.localizedDescription
|
1661
|
+
};
|
1662
|
+
|
1663
|
+
NSError *jsonError;
|
1664
|
+
NSData *jsonData = [NSJSONSerialization dataWithJSONObject:errorData options:0 error:&jsonError];
|
1665
|
+
NSString *jsonString = jsonData ? [[NSString alloc] initWithData:jsonData encoding:NSUTF8StringEncoding] : error.localizedDescription;
|
1666
|
+
|
1667
|
+
if (adFormat == 1) {
|
1668
|
+
[self fireEvent:@"" event:@"on.appOpenAd.failed.loaded" withData:jsonString];
|
1669
|
+
} else if (adFormat == 2) {
|
1670
|
+
[self fireEvent:@"" event:@"on.interstitial.failed.load" withData:jsonString];
|
1671
|
+
} else if (adFormat == 3) {
|
1672
|
+
[self fireEvent:@"" event:@"on.rewarded.failed.load" withData:jsonString];
|
1673
|
+
} else if (adFormat == 4) {
|
1674
|
+
[self fireEvent:@"" event:@"on.rewardedInt.failed.load" withData:jsonString];
|
1675
|
+
}
|
1678
1676
|
}
|
1679
1677
|
|
1678
|
+
|
1680
1679
|
- (void)adDidDismissFullScreenContent:(id)ad {
|
1681
|
-
|
1682
|
-
|
1683
|
-
|
1684
|
-
|
1685
|
-
|
1686
|
-
|
1687
|
-
|
1688
|
-
|
1689
|
-
|
1690
|
-
|
1691
|
-
|
1692
|
-
|
1693
|
-
|
1694
|
-
|
1695
|
-
@"Open Ad."); */
|
1696
|
-
} else if (adFormat == 2) {
|
1697
|
-
[self fireEvent:@""
|
1698
|
-
event:@"on."
|
1699
|
-
@"inte"
|
1700
|
-
@"rsti"
|
1701
|
-
@"tial"
|
1702
|
-
@".dis"
|
1703
|
-
@"miss"
|
1704
|
-
@"ed"
|
1705
|
-
withData:nil];
|
1706
|
-
/* NSLog(@"Ad did "
|
1707
|
-
@"dismiss "
|
1708
|
-
@"full screen "
|
1709
|
-
@"content "
|
1710
|
-
@"interstitial"
|
1711
|
-
@"."); */
|
1712
|
-
} else if (adFormat == 3) {
|
1713
|
-
[self fireEvent:@""
|
1714
|
-
event:@"on."
|
1715
|
-
@"rewa"
|
1716
|
-
@"rded"
|
1717
|
-
@".dis"
|
1718
|
-
@"miss"
|
1719
|
-
@"ed"
|
1720
|
-
withData:nil];
|
1721
|
-
if (isAdSkip != 2) {
|
1722
|
-
[self fireEvent:@""
|
1723
|
-
event:@"on"
|
1724
|
-
@".r"
|
1725
|
-
@"ew"
|
1726
|
-
@"ar"
|
1727
|
-
@"de"
|
1728
|
-
@"d."
|
1729
|
-
@"ad"
|
1730
|
-
@".s"
|
1731
|
-
@"ki"
|
1732
|
-
@"p"
|
1733
|
-
withData:nil];
|
1734
|
-
}
|
1735
|
-
/* NSLog(@"Ad did "
|
1736
|
-
@"dismiss "
|
1737
|
-
@"full screen "
|
1738
|
-
@"content "
|
1739
|
-
@"rewarded."); */
|
1740
|
-
} else if (adFormat == 4) {
|
1741
|
-
if (isAdSkip != 2) {
|
1742
|
-
[self fireEvent:@""
|
1743
|
-
event:@"on"
|
1744
|
-
@".r"
|
1745
|
-
@"ew"
|
1746
|
-
@"ar"
|
1747
|
-
@"de"
|
1748
|
-
@"dI"
|
1749
|
-
@"nt"
|
1750
|
-
@".a"
|
1751
|
-
@"d."
|
1752
|
-
@"sk"
|
1753
|
-
@"ip"
|
1754
|
-
withData:nil];
|
1680
|
+
if (adFormat == 1) {
|
1681
|
+
[self fireEvent:@"" event:@"on.appOpenAd.dismissed" withData:nil];
|
1682
|
+
} else if (adFormat == 2) {
|
1683
|
+
[self fireEvent:@"" event:@"on.interstitial.dismissed" withData:nil];
|
1684
|
+
} else if (adFormat == 3) {
|
1685
|
+
[self fireEvent:@"" event:@"on.rewarded.dismissed" withData:nil];
|
1686
|
+
if (isAdSkip != 2) {
|
1687
|
+
[self fireEvent:@"" event:@"on.rewarded.ad.skip" withData:nil];
|
1688
|
+
}
|
1689
|
+
} else if (adFormat == 4) {
|
1690
|
+
if (isAdSkip != 2) {
|
1691
|
+
[self fireEvent:@"" event:@"on.rewardedInt.ad.skip" withData:nil];
|
1692
|
+
}
|
1693
|
+
[self fireEvent:@"" event:@"on.rewardedInt.dismissed" withData:nil];
|
1755
1694
|
}
|
1756
|
-
[self fireEvent:@""
|
1757
|
-
event:@"on."
|
1758
|
-
@"rewa"
|
1759
|
-
@"rded"
|
1760
|
-
@"Int."
|
1761
|
-
@"dism"
|
1762
|
-
@"isse"
|
1763
|
-
@"d"
|
1764
|
-
withData:nil];
|
1765
|
-
/* NSLog(@"Ad did "
|
1766
|
-
@"dismiss "
|
1767
|
-
@"full screen "
|
1768
|
-
@"content "
|
1769
|
-
@"interstitial"
|
1770
|
-
@" rewarded."); */
|
1771
|
-
}
|
1772
1695
|
}
|
1696
|
+
|
1773
1697
|
#pragma mark Cleanup
|
1774
1698
|
- (void)dealloc {
|
1775
1699
|
self.appOpenAd = nil;
|