emi-indo-cordova-plugin-admob 1.6.2 → 1.6.3
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/README.md +5 -2
- package/example/package.json +1 -1
- package/example/www/js/deviceready.js +7 -1
- package/package.json +1 -1
- package/plugin.xml +3 -3
- package/src/ios/emiAdmobPlugin.h +1 -1
- package/src/ios/emiAdmobPlugin.m +119 -151
package/README.md
CHANGED
@@ -11,9 +11,9 @@
|
|
11
11
|
### Mobile Ads SDK (Android: 23.5.0) [Release Notes:](https://developers.google.com/admob/android/rel-notes)
|
12
12
|
### User Messaging Platform (UMP Android: 3.1.0) [Release Notes:](https://developers.google.com/admob/android/privacy/release-notes)
|
13
13
|
|
14
|
-
### Mobile Ads SDK (IOS: 11.
|
14
|
+
### Mobile Ads SDK (IOS: 11.12.0) [Release Notes:](https://developers.google.com/admob/ios/rel-notes)
|
15
15
|
|
16
|
-
### User Messaging Platform (UMP IOS: 2.
|
16
|
+
### User Messaging Platform (UMP IOS: 2.7.0) [Release Notes:](https://developers.google.com/ad-manager/mobile-ads-sdk/ios/privacy/download)
|
17
17
|
### IAB Europe Transparency & Consent Framework (CPM: 2.2.0)
|
18
18
|
|
19
19
|
## New example
|
@@ -31,7 +31,10 @@
|
|
31
31
|
|
32
32
|
|
33
33
|
## IOS Ad Support IOS 18 *
|
34
|
+
- Mobile Ads SDK (IOS: 11.12.0)
|
35
|
+
- emi-indo-cordova-plugin-admob@1.6.3 or higher requires cocoapods 1.16.2 or higher
|
34
36
|
> [!WARNING]
|
37
|
+
> - Mobile Ads SDK (IOS: 11.10.0)
|
35
38
|
> - emi-indo-cordova-plugin-admob@1.5.2 or higher
|
36
39
|
> - Minimum supported Xcode version up to 15.3 or higher
|
37
40
|
> - minimum deployment-target: 12.2
|
package/example/package.json
CHANGED
@@ -87,7 +87,7 @@ document.addEventListener("deviceready", function () {
|
|
87
87
|
|
88
88
|
cordova.plugins.emiAdmobPlugin.initialize({
|
89
89
|
|
90
|
-
isUsingAdManagerRequest: true, //
|
90
|
+
isUsingAdManagerRequest: true, // true = AdManager | false = AdMob (Default true)
|
91
91
|
isResponseInfo: true, // debug Default false
|
92
92
|
isConsentDebug: true, // debug Default false
|
93
93
|
|
@@ -101,6 +101,7 @@ document.addEventListener("deviceready", function () {
|
|
101
101
|
const sdkVersion = data.version;
|
102
102
|
// const adAdapter = data.adapters;
|
103
103
|
const conStatus = data.consentStatus;
|
104
|
+
const attStatus = data.attStatus;
|
104
105
|
// const gdprApplie = data.gdprApplies;
|
105
106
|
// const purposeConsent = data.purposeConsents;
|
106
107
|
// const vendorConsents = data.vendorConsents;
|
@@ -108,6 +109,11 @@ document.addEventListener("deviceready", function () {
|
|
108
109
|
// const additionalConsent = data.additionalConsent;
|
109
110
|
log.value += ("\n On Sdk Initialization version: " + sdkVersion);
|
110
111
|
log.value += ("\n On Consent Status: " + conStatus);
|
112
|
+
|
113
|
+
if (isPlatformIOS){
|
114
|
+
|
115
|
+
log.value += ("\n On Authorization Status: " + attStatus);
|
116
|
+
}
|
111
117
|
|
112
118
|
loadBanner(); // auto show
|
113
119
|
|
package/package.json
CHANGED
package/plugin.xml
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
<plugin xmlns="http://apache.org/cordova/ns/plugins/1.0"
|
2
2
|
xmlns:android="http://schemas.android.com/apk/res/android"
|
3
|
-
id="emi-indo-cordova-plugin-admob" version="1.6.
|
3
|
+
id="emi-indo-cordova-plugin-admob" version="1.6.3">
|
4
4
|
|
5
5
|
<name>emiAdmobPlugin</name>
|
6
6
|
<description>Cordova Plugin Admob Android IOS</description>
|
@@ -296,8 +296,8 @@
|
|
296
296
|
</config>
|
297
297
|
<pods use-frameworks="true">
|
298
298
|
<!--minimum macOS 14.4 > Xcode 15.3 -->
|
299
|
-
<pod name="GoogleUserMessagingPlatform" spec="~> 2.
|
300
|
-
|
299
|
+
<pod name="GoogleUserMessagingPlatform" spec="~> 2.7.0" />
|
300
|
+
<pod name="Google-Mobile-Ads-SDK" spec="~> 11.12.0" />
|
301
301
|
|
302
302
|
</pods>
|
303
303
|
</podspec>
|
package/src/ios/emiAdmobPlugin.h
CHANGED
@@ -4,6 +4,7 @@
|
|
4
4
|
#import <UserMessagingPlatform/UserMessagingPlatform.h>
|
5
5
|
#import <CommonCrypto/CommonDigest.h>
|
6
6
|
@interface emiAdmobPlugin : CDVPlugin<GADBannerViewDelegate, GADFullScreenContentDelegate>{}
|
7
|
+
@property(nonatomic, strong) GADRequest *globalRequest;
|
7
8
|
@property(nonatomic, strong) GADAppOpenAd *appOpenAd;
|
8
9
|
@property(nonatomic, strong) GADBannerView *bannerView;
|
9
10
|
@property(nonatomic, strong) GADInterstitialAd *interstitial;
|
@@ -20,7 +21,6 @@
|
|
20
21
|
- (void)initialize:(CDVInvokedUrlCommand *)command;
|
21
22
|
- (void)requestIDFA:(CDVInvokedUrlCommand *)command;
|
22
23
|
- (void)showPrivacyOptionsForm:(CDVInvokedUrlCommand *)command;
|
23
|
-
// - (void)getConsentRequest:(CDVInvokedUrlCommand *)command;
|
24
24
|
- (void)forceDisplayPrivacyForm:(CDVInvokedUrlCommand *)command;
|
25
25
|
- (void)consentReset:(CDVInvokedUrlCommand *)command;
|
26
26
|
- (void)getIabTfc:(CDVInvokedUrlCommand *)command;
|
package/src/ios/emiAdmobPlugin.m
CHANGED
@@ -13,25 +13,24 @@
|
|
13
13
|
@synthesize command;
|
14
14
|
@synthesize responseInfo;
|
15
15
|
@synthesize isPrivacyOptionsRequired;
|
16
|
-
int
|
16
|
+
int attStatus = 0;
|
17
17
|
// int fromStatus = 0; // Deprecated
|
18
18
|
int Consent_Status = 0;
|
19
19
|
int adFormat = 0;
|
20
|
-
int adWidth = 320; //
|
20
|
+
int adWidth = 320; // Default
|
21
21
|
BOOL auto_Show = NO;
|
22
22
|
// NSString *Npa = @"1"; // Deprecated
|
23
|
-
NSString *
|
23
|
+
NSString *setPosition = @"bottom-center"; // Default
|
24
24
|
NSString *bannerSaveAdUnitId = @""; // autoResize dependency = true
|
25
25
|
|
26
|
-
BOOL
|
26
|
+
BOOL isCollapsible = NO;
|
27
27
|
BOOL isAutoResize = NO;
|
28
28
|
|
29
29
|
int isAdSkip = 0;
|
30
|
-
BOOL isIAB = NO;
|
31
30
|
BOOL UnderAgeOfConsent = NO;
|
32
31
|
BOOL isPrivacyOptions = NO;
|
33
32
|
BOOL isDebugGeography = NO;
|
34
|
-
BOOL
|
33
|
+
BOOL isResponseInfo = NO;
|
35
34
|
BOOL isUsingAdManagerRequest = YES;
|
36
35
|
|
37
36
|
- (BOOL)canRequestAds {
|
@@ -40,8 +39,20 @@ BOOL isUsingAdManagerRequest = YES;
|
|
40
39
|
- (void)setUsingAdManagerRequest:(BOOL)value {
|
41
40
|
isUsingAdManagerRequest = value;
|
42
41
|
}
|
43
|
-
|
44
|
-
|
42
|
+
|
43
|
+
- (void)setAdRequest {
|
44
|
+
if (isUsingAdManagerRequest) {
|
45
|
+
self.globalRequest = [GAMRequest request];
|
46
|
+
NSLog(@"Using AdManager request");
|
47
|
+
} else {
|
48
|
+
self.globalRequest = [GADRequest request];
|
49
|
+
NSLog(@"Using AdMob request");
|
50
|
+
}
|
51
|
+
}
|
52
|
+
|
53
|
+
|
54
|
+
- (void)isResponseInfo:(BOOL)value {
|
55
|
+
isResponseInfo = value;
|
45
56
|
}
|
46
57
|
- (void)isDebugGeography:(BOOL)value {
|
47
58
|
isDebugGeography = value;
|
@@ -55,7 +66,7 @@ BOOL isUsingAdManagerRequest = YES;
|
|
55
66
|
BOOL setDebugGeography = [[options valueForKey:@"isConsentDebug"] boolValue];
|
56
67
|
|
57
68
|
[self setUsingAdManagerRequest:setAdRequest];
|
58
|
-
[self
|
69
|
+
[self isResponseInfo:responseInfo];
|
59
70
|
[self isDebugGeography:setDebugGeography];
|
60
71
|
|
61
72
|
__block CDVPluginResult *pluginResult;
|
@@ -132,42 +143,28 @@ BOOL isUsingAdManagerRequest = YES;
|
|
132
143
|
[ATTrackingManager requestTrackingAuthorizationWithCompletionHandler:^(
|
133
144
|
ATTrackingManagerAuthorizationStatus status) {
|
134
145
|
if (status == ATTrackingManagerAuthorizationStatusDenied) {
|
135
|
-
|
146
|
+
attStatus = ATTrackingManagerAuthorizationStatusDenied;
|
136
147
|
} else if (status == ATTrackingManagerAuthorizationStatusAuthorized) {
|
137
|
-
|
148
|
+
attStatus = ATTrackingManagerAuthorizationStatusAuthorized;
|
138
149
|
} else if (status == ATTrackingManagerAuthorizationStatusRestricted) {
|
139
|
-
|
150
|
+
attStatus = ATTrackingManagerAuthorizationStatusRestricted;
|
140
151
|
} else if (status ==
|
141
152
|
ATTrackingManagerAuthorizationStatusNotDetermined) {
|
142
|
-
|
153
|
+
attStatus = ATTrackingManagerAuthorizationStatusNotDetermined;
|
143
154
|
}
|
144
155
|
}];
|
145
156
|
});
|
146
|
-
|
147
|
-
|
148
|
-
@"getI"
|
149
|
-
@"DFA."
|
150
|
-
@"stat"
|
151
|
-
@"us"
|
152
|
-
withData:nil];
|
157
|
+
[self fireEvent:@"" event:@"on.getIDFA.status" withData:nil];
|
158
|
+
|
153
159
|
pluginResult = [CDVPluginResult resultWithStatus:CDVCommandStatus_OK
|
154
|
-
messageAsInt:
|
160
|
+
messageAsInt:attStatus];
|
155
161
|
} else {
|
156
|
-
|
157
|
-
event:@"on."
|
158
|
-
@"getI"
|
159
|
-
@"DFA."
|
160
|
-
@"erro"
|
161
|
-
@"r"
|
162
|
-
withData:nil];
|
162
|
+
[self fireEvent:@"" event:@"on.getIDFA.error" withData:nil];
|
163
163
|
pluginResult = [CDVPluginResult resultWithStatus:CDVCommandStatus_ERROR];
|
164
164
|
}
|
165
165
|
[self.commandDelegate sendPluginResult:pluginResult callbackId:callbackId];
|
166
166
|
}
|
167
|
-
|
168
|
-
- (void)getConsentRequest:(CDVInvokedUrlCommand *)command {
|
169
|
-
}
|
170
|
-
*/
|
167
|
+
|
171
168
|
- (void)startGoogleMobileAdsSDK {
|
172
169
|
static dispatch_once_t onceToken;
|
173
170
|
dispatch_once(&onceToken, ^{
|
@@ -187,22 +184,21 @@ BOOL isUsingAdManagerRequest = YES;
|
|
187
184
|
[adaptersArray addObject:adapterInfo];
|
188
185
|
}
|
189
186
|
|
190
|
-
NSString *sdkVersion = GADGetStringFromVersionNumber(
|
191
|
-
|
192
|
-
int
|
193
|
-
(int)UMPConsentInformation.sharedInstance.consentStatus;
|
187
|
+
NSString *sdkVersion = GADGetStringFromVersionNumber(GADMobileAds.sharedInstance.versionNumber);
|
188
|
+
int Consent_Status = (int)UMPConsentInformation.sharedInstance.consentStatus;
|
189
|
+
int initAttStatus = (int)attStatus;
|
194
190
|
|
195
191
|
NSMutableDictionary *result = [[NSMutableDictionary alloc] init];
|
196
192
|
NSUserDefaults *prefs = [NSUserDefaults standardUserDefaults];
|
197
193
|
NSNumber *CmpSdkID = [prefs valueForKey:@"IABTCF_CmpSdkID"];
|
198
194
|
NSString *gdprApplies = [prefs stringForKey:@"IABTCF_gdprApplies"];
|
199
|
-
NSString *PurposeConsents =
|
200
|
-
[prefs stringForKey:@"IABTCF_PurposeConsents"];
|
195
|
+
NSString *PurposeConsents = [prefs stringForKey:@"IABTCF_PurposeConsents"];
|
201
196
|
NSString *TCString = [prefs stringForKey:@"IABTCF_TCString"];
|
202
197
|
NSString *additionalConsent = [prefs stringForKey:@"IABTCF_AddtlConsent"];
|
203
198
|
|
204
199
|
result[@"version"] = sdkVersion;
|
205
200
|
result[@"consentStatus"] = @(Consent_Status);
|
201
|
+
result[@"attStatus"] = @(initAttStatus);
|
206
202
|
result[@"adapter"] = adaptersArray;
|
207
203
|
result[@"CmpSdkID"] = CmpSdkID;
|
208
204
|
result[@"gdprApplies"] = gdprApplies;
|
@@ -366,7 +362,7 @@ BOOL isUsingAdManagerRequest = YES;
|
|
366
362
|
CDVPluginResult *pluginResult;
|
367
363
|
NSString *callbackId = command.callbackId;
|
368
364
|
|
369
|
-
|
365
|
+
|
370
366
|
NSMutableDictionary *result = [[NSMutableDictionary alloc] init];
|
371
367
|
NSUserDefaults *prefs = [NSUserDefaults standardUserDefaults];
|
372
368
|
|
@@ -386,9 +382,7 @@ BOOL isUsingAdManagerRequest = YES;
|
|
386
382
|
|
387
383
|
pluginResult = [CDVPluginResult resultWithStatus:CDVCommandStatus_OK messageAsDictionary:result];
|
388
384
|
[self fireEvent:@"" event:@"onGetIabTfc" withData:nil];
|
389
|
-
|
390
|
-
pluginResult = [CDVPluginResult resultWithStatus:CDVCommandStatus_ERROR];
|
391
|
-
}
|
385
|
+
|
392
386
|
|
393
387
|
[self.commandDelegate sendPluginResult:pluginResult callbackId:callbackId];
|
394
388
|
}
|
@@ -468,47 +462,33 @@ BOOL isUsingAdManagerRequest = YES;
|
|
468
462
|
}
|
469
463
|
|
470
464
|
- (void)pluginInitialize {
|
471
|
-
|
465
|
+
[super pluginInitialize];
|
472
466
|
|
473
|
-
|
474
|
-
|
475
|
-
|
476
|
-
|
477
|
-
|
478
|
-
|
479
|
-
|
480
|
-
|
481
|
-
|
482
|
-
|
483
|
-
|
484
|
-
|
485
|
-
|
486
|
-
|
487
|
-
|
488
|
-
|
489
|
-
|
490
|
-
|
491
|
-
|
492
|
-
|
493
|
-
|
494
|
-
|
495
|
-
@"ing"];
|
496
|
-
result[@"IABTCF_"
|
497
|
-
@"CmpSdkID"] = CmpSdkID;
|
498
|
-
result[@"IABTCF_"
|
499
|
-
@"gdprApplies"] = gdprApplies;
|
500
|
-
result[@"IABTCF_"
|
501
|
-
@"PurposeCons"
|
502
|
-
@"ents"] = PurposeConsents;
|
503
|
-
result[@"IABTCF_"
|
504
|
-
@"TCString"] = TCString;
|
505
|
-
// NSLog(@"%@",
|
506
|
-
// [[NSUserDefaults
|
507
|
-
// standardUserDefaults]
|
508
|
-
// dictionaryRepresentation]);
|
509
|
-
[prefs synchronize];
|
467
|
+
[[NSNotificationCenter defaultCenter]
|
468
|
+
addObserver:self
|
469
|
+
selector:@selector(orientationDidChange:)
|
470
|
+
name:UIDeviceOrientationDidChangeNotification
|
471
|
+
object:nil];
|
472
|
+
|
473
|
+
NSMutableDictionary *result = [[NSMutableDictionary alloc] init];
|
474
|
+
NSUserDefaults *prefs = [NSUserDefaults standardUserDefaults];
|
475
|
+
|
476
|
+
NSNumber *CmpSdkID = [prefs valueForKey:@"IABTCF_CmpSdkID"];
|
477
|
+
NSString *gdprApplies = [prefs stringForKey:@"IABTCF_gdprApplies"];
|
478
|
+
NSString *PurposeConsents = [prefs stringForKey:@"IABTCF_PurposeConsents"];
|
479
|
+
NSString *TCString = [prefs stringForKey:@"IABTCF_TCString"];
|
480
|
+
|
481
|
+
result[@"IABTCF_CmpSdkID"] = CmpSdkID;
|
482
|
+
result[@"IABTCF_gdprApplies"] = gdprApplies;
|
483
|
+
result[@"IABTCF_PurposeConsents"] = PurposeConsents;
|
484
|
+
result[@"IABTCF_TCString"] = TCString;
|
485
|
+
|
486
|
+
// NSLog(@"%@", [[NSUserDefaults standardUserDefaults] dictionaryRepresentation]);
|
487
|
+
|
488
|
+
[prefs synchronize];
|
510
489
|
}
|
511
490
|
|
491
|
+
|
512
492
|
- (void)orientationDidChange:(NSNotification *)notification {
|
513
493
|
// NSLog(@"Orientation changed");
|
514
494
|
[self fireEvent:@"" event:@"on.screen.rotated" withData:nil];
|
@@ -522,6 +502,8 @@ BOOL isUsingAdManagerRequest = YES;
|
|
522
502
|
[self.bannerView removeFromSuperview];
|
523
503
|
}
|
524
504
|
}
|
505
|
+
|
506
|
+
[self setAdRequest];
|
525
507
|
|
526
508
|
self.bannerViewLayout = [[UIView alloc] initWithFrame:CGRectZero];
|
527
509
|
self.bannerViewLayout.translatesAutoresizingMaskIntoConstraints = NO;
|
@@ -549,7 +531,7 @@ BOOL isUsingAdManagerRequest = YES;
|
|
549
531
|
rootView.frame.size.width)];
|
550
532
|
self.bannerView.adUnitID = bannerSaveAdUnitId;
|
551
533
|
self.bannerView.delegate = self;
|
552
|
-
[self.bannerView loadRequest:
|
534
|
+
[self.bannerView loadRequest:self.globalRequest];
|
553
535
|
|
554
536
|
[self.bannerViewLayout addSubview:self.bannerView];
|
555
537
|
[self.bannerViewLayout bringSubviewToFront:self.bannerView];
|
@@ -563,11 +545,15 @@ BOOL isUsingAdManagerRequest = YES;
|
|
563
545
|
}
|
564
546
|
}
|
565
547
|
|
548
|
+
|
549
|
+
|
550
|
+
|
551
|
+
/*
|
552
|
+
|
566
553
|
- (void)addBannerConstraints {
|
567
554
|
self.bannerView.translatesAutoresizingMaskIntoConstraints = NO;
|
568
555
|
|
569
|
-
|
570
|
-
if ([Position isEqualToString:@"bottom-center"]) {
|
556
|
+
if ([setPosition isEqualToString:@"bottom-center"]) {
|
571
557
|
[self.viewController.view addConstraints:@[
|
572
558
|
[NSLayoutConstraint
|
573
559
|
constraintWithItem:self.bannerView
|
@@ -585,7 +571,7 @@ BOOL isUsingAdManagerRequest = YES;
|
|
585
571
|
multiplier:1
|
586
572
|
constant:0]
|
587
573
|
]];
|
588
|
-
} else if ([
|
574
|
+
} else if ([setPosition isEqualToString:@"top-center"]) {
|
589
575
|
[self.viewController.view addConstraints:@[
|
590
576
|
[NSLayoutConstraint
|
591
577
|
constraintWithItem:self.bannerView
|
@@ -606,10 +592,13 @@ BOOL isUsingAdManagerRequest = YES;
|
|
606
592
|
}
|
607
593
|
}
|
608
594
|
|
595
|
+
*/
|
596
|
+
|
597
|
+
|
598
|
+
|
609
599
|
- (void)loadBannerAd:(CDVInvokedUrlCommand *)command {
|
610
600
|
CDVPluginResult *pluginResult;
|
611
601
|
NSString *callbackId = command.callbackId;
|
612
|
-
adFormat = 3;
|
613
602
|
NSDictionary *options = [command.arguments objectAtIndex:0];
|
614
603
|
NSString *adUnitId = [options valueForKey:@"adUnitId"];
|
615
604
|
NSString *position = [options valueForKey:@"position"];
|
@@ -620,6 +609,10 @@ BOOL isUsingAdManagerRequest = YES;
|
|
620
609
|
|
621
610
|
bannerSaveAdUnitId = adUnitId;
|
622
611
|
|
612
|
+
setPosition = position;
|
613
|
+
|
614
|
+
adFormat = 3;
|
615
|
+
|
623
616
|
if (adUnitId == nil || [adUnitId length] == 0) {
|
624
617
|
pluginResult = [CDVPluginResult resultWithStatus:CDVCommandStatus_ERROR
|
625
618
|
messageAsString:@"Ad unit ID is required"];
|
@@ -628,15 +621,16 @@ BOOL isUsingAdManagerRequest = YES;
|
|
628
621
|
}
|
629
622
|
|
630
623
|
if (collapsible != nil && [collapsible length] > 0) {
|
631
|
-
|
624
|
+
isCollapsible = YES;
|
632
625
|
} else {
|
633
|
-
|
626
|
+
isCollapsible = YES;
|
634
627
|
}
|
635
628
|
|
636
629
|
if (autoResize) {
|
637
|
-
|
638
630
|
isAutoResize = YES;
|
639
631
|
}
|
632
|
+
|
633
|
+
[self setAdRequest];
|
640
634
|
|
641
635
|
if (adFormat == 3) {
|
642
636
|
dispatch_async(dispatch_get_main_queue(), ^{
|
@@ -649,28 +643,26 @@ BOOL isUsingAdManagerRequest = YES;
|
|
649
643
|
}
|
650
644
|
|
651
645
|
self.viewWidth = frame.size.width;
|
652
|
-
|
646
|
+
|
653
647
|
auto_Show = autoShow;
|
654
648
|
adWidth = self.viewWidth;
|
655
649
|
|
656
|
-
|
657
|
-
|
658
|
-
|
659
|
-
self.bannerView = [[GADBannerView alloc] initWithAdSize:sizes];
|
660
|
-
|
661
|
-
GADRequest *request = [GADRequest request];
|
650
|
+
GADAdSize siz = [self __AdSizeFromString:size];
|
651
|
+
self.bannerView = [[GADBannerView alloc] initWithAdSize:siz];
|
652
|
+
|
662
653
|
GADExtras *extras = [[GADExtras alloc] init];
|
663
654
|
|
664
|
-
if (
|
655
|
+
if (isCollapsible) {
|
665
656
|
extras.additionalParameters = @{@"collapsible" : collapsible};
|
657
|
+
|
658
|
+
[self.globalRequest registerAdNetworkExtras:extras];
|
659
|
+
|
666
660
|
}
|
667
661
|
|
668
|
-
[request registerAdNetworkExtras:extras];
|
669
|
-
|
670
662
|
self.bannerView.adUnitID = adUnitId;
|
671
663
|
self.bannerView.rootViewController = self.viewController;
|
672
664
|
self.bannerView.delegate = self;
|
673
|
-
[self.bannerView loadRequest:
|
665
|
+
[self.bannerView loadRequest:self.globalRequest];
|
674
666
|
self.bannerView.hidden = YES;
|
675
667
|
[parentView addSubview:self.bannerView];
|
676
668
|
[parentView bringSubviewToFront:self.bannerView];
|
@@ -685,6 +677,8 @@ BOOL isUsingAdManagerRequest = YES;
|
|
685
677
|
[self.commandDelegate sendPluginResult:pluginResult callbackId:callbackId];
|
686
678
|
}
|
687
679
|
|
680
|
+
|
681
|
+
|
688
682
|
- (GADAdSize)__AdSizeFromString:(NSString *)size {
|
689
683
|
|
690
684
|
if (self.viewWidth == 0) {
|
@@ -718,14 +712,7 @@ BOOL isUsingAdManagerRequest = YES;
|
|
718
712
|
[self addBannerViewToView:command];
|
719
713
|
pluginResult = [CDVPluginResult resultWithStatus:CDVCommandStatus_OK];
|
720
714
|
} else {
|
721
|
-
|
722
|
-
event:@"on."
|
723
|
-
@"bann"
|
724
|
-
@"er."
|
725
|
-
@"fail"
|
726
|
-
@"ed."
|
727
|
-
@"show"
|
728
|
-
withData:nil];
|
715
|
+
[self fireEvent:@"" event:@"on.banner.failed.show" withData:nil];
|
729
716
|
pluginResult = [CDVPluginResult resultWithStatus:CDVCommandStatus_ERROR];
|
730
717
|
}
|
731
718
|
[self.commandDelegate sendPluginResult:pluginResult callbackId:callbackId];
|
@@ -734,7 +721,7 @@ BOOL isUsingAdManagerRequest = YES;
|
|
734
721
|
- (void)addBannerViewToView:(CDVInvokedUrlCommand *)command {
|
735
722
|
bannerView.translatesAutoresizingMaskIntoConstraints = NO;
|
736
723
|
[self.viewController.view addSubview:bannerView];
|
737
|
-
if ([
|
724
|
+
if ([setPosition isEqualToString:@"bottom-center"]) {
|
738
725
|
[self.viewController.view addConstraints:@[
|
739
726
|
[NSLayoutConstraint
|
740
727
|
constraintWithItem:bannerView
|
@@ -752,7 +739,7 @@ BOOL isUsingAdManagerRequest = YES;
|
|
752
739
|
multiplier:1
|
753
740
|
constant:0]
|
754
741
|
]];
|
755
|
-
} else if ([
|
742
|
+
} else if ([setPosition isEqualToString:@"top-center"]) {
|
756
743
|
|
757
744
|
[self.viewController.view addConstraints:@[
|
758
745
|
[NSLayoutConstraint
|
@@ -834,13 +821,15 @@ BOOL isUsingAdManagerRequest = YES;
|
|
834
821
|
adFormat = 1;
|
835
822
|
self.appOpenAd = nil;
|
836
823
|
|
824
|
+
[self setAdRequest];
|
825
|
+
|
837
826
|
if (adFormat == 1) {
|
838
827
|
dispatch_async(dispatch_get_main_queue(), ^{
|
839
|
-
|
828
|
+
|
840
829
|
GADExtras *extras = [[GADExtras alloc] init];
|
841
|
-
[
|
830
|
+
[self.globalRequest registerAdNetworkExtras:extras];
|
842
831
|
|
843
|
-
[GADAppOpenAd loadWithAdUnitID:adUnitId request:
|
832
|
+
[GADAppOpenAd loadWithAdUnitID:adUnitId request:self.globalRequest completionHandler:^(GADAppOpenAd *ad, NSError *error) {
|
844
833
|
if (error) {
|
845
834
|
// Send load error to event
|
846
835
|
NSDictionary *errorData = @{@"error": error.localizedDescription ?: @"Unknown error"};
|
@@ -881,9 +870,6 @@ BOOL isUsingAdManagerRequest = YES;
|
|
881
870
|
};
|
882
871
|
|
883
872
|
|
884
|
-
|
885
|
-
|
886
|
-
|
887
873
|
if (auto_Show) {
|
888
874
|
NSError *presentError = nil;
|
889
875
|
if ([self.appOpenAd canPresentFromRootViewController:self.viewController error:&presentError]) {
|
@@ -899,7 +885,7 @@ BOOL isUsingAdManagerRequest = YES;
|
|
899
885
|
}
|
900
886
|
|
901
887
|
|
902
|
-
if (
|
888
|
+
if (isResponseInfo) {
|
903
889
|
GADResponseInfo *responseInfo = ad.responseInfo;
|
904
890
|
NSMutableArray *adNetworkInfoArray = [NSMutableArray array];
|
905
891
|
|
@@ -953,15 +939,7 @@ BOOL isUsingAdManagerRequest = YES;
|
|
953
939
|
pluginResult = [CDVPluginResult resultWithStatus:CDVCommandStatus_OK];
|
954
940
|
} else {
|
955
941
|
pluginResult = [CDVPluginResult resultWithStatus:CDVCommandStatus_ERROR];
|
956
|
-
|
957
|
-
event:@"on."
|
958
|
-
@"appO"
|
959
|
-
@"penA"
|
960
|
-
@"d."
|
961
|
-
@"fail"
|
962
|
-
@"ed."
|
963
|
-
@"show"
|
964
|
-
withData:nil];
|
942
|
+
[self fireEvent:@"" event:@"on.appOpened.failed.show" withData:nil];
|
965
943
|
}
|
966
944
|
[self.commandDelegate sendPluginResult:pluginResult callbackId:callbackId];
|
967
945
|
}
|
@@ -975,11 +953,11 @@ BOOL isUsingAdManagerRequest = YES;
|
|
975
953
|
|
976
954
|
auto_Show = autoShow;
|
977
955
|
adFormat = 2;
|
978
|
-
|
956
|
+
[self setAdRequest];
|
979
957
|
if (adFormat == 2) {
|
980
958
|
dispatch_async(dispatch_get_main_queue(), ^{
|
981
|
-
|
982
|
-
[GADInterstitialAd loadWithAdUnitID:adUnitId request:
|
959
|
+
|
960
|
+
[GADInterstitialAd loadWithAdUnitID:adUnitId request:self.globalRequest completionHandler:^(GADInterstitialAd *ad, NSError *error) {
|
983
961
|
if (error) {
|
984
962
|
// Send load error to event
|
985
963
|
NSDictionary *errorData = @{@"error": error.localizedDescription ?: @"Unknown error"};
|
@@ -1035,7 +1013,7 @@ BOOL isUsingAdManagerRequest = YES;
|
|
1035
1013
|
|
1036
1014
|
|
1037
1015
|
|
1038
|
-
if (
|
1016
|
+
if (isResponseInfo) {
|
1039
1017
|
GADResponseInfo *responseInfo = ad.responseInfo;
|
1040
1018
|
NSMutableArray *adNetworkInfoArray = [NSMutableArray array];
|
1041
1019
|
|
@@ -1109,11 +1087,10 @@ BOOL isUsingAdManagerRequest = YES;
|
|
1109
1087
|
|
1110
1088
|
auto_Show = autoShow;
|
1111
1089
|
adFormat = 4;
|
1112
|
-
|
1090
|
+
[self setAdRequest];
|
1113
1091
|
if (adFormat == 4) {
|
1114
1092
|
dispatch_async(dispatch_get_main_queue(), ^{
|
1115
|
-
|
1116
|
-
[GADRewardedInterstitialAd loadWithAdUnitID:adUnitId request:request completionHandler:^(GADRewardedInterstitialAd *ad, NSError *error) {
|
1093
|
+
[GADRewardedInterstitialAd loadWithAdUnitID:adUnitId request:self.globalRequest completionHandler:^(GADRewardedInterstitialAd *ad, NSError *error) {
|
1117
1094
|
if (error) {
|
1118
1095
|
// Send error data to event
|
1119
1096
|
NSDictionary *errorData = @{@"error": error.localizedDescription ?: @"Unknown error"};
|
@@ -1130,7 +1107,6 @@ BOOL isUsingAdManagerRequest = YES;
|
|
1130
1107
|
[self fireEvent:@"" event:@"on.rewardedInt.loaded" withData:nil];
|
1131
1108
|
|
1132
1109
|
|
1133
|
-
|
1134
1110
|
__weak __typeof(self) weakSelf = self;
|
1135
1111
|
self.rewardedInterstitialAd.paidEventHandler = ^(GADAdValue *_Nonnull value) {
|
1136
1112
|
__strong __typeof(weakSelf) strongSelf = weakSelf;
|
@@ -1183,7 +1159,7 @@ BOOL isUsingAdManagerRequest = YES;
|
|
1183
1159
|
}
|
1184
1160
|
|
1185
1161
|
|
1186
|
-
if (
|
1162
|
+
if (isResponseInfo) {
|
1187
1163
|
GADResponseInfo *responseInfo = ad.responseInfo;
|
1188
1164
|
NSMutableArray *adNetworkInfoArray = [NSMutableArray array];
|
1189
1165
|
|
@@ -1216,9 +1192,6 @@ BOOL isUsingAdManagerRequest = YES;
|
|
1216
1192
|
}
|
1217
1193
|
}
|
1218
1194
|
|
1219
|
-
|
1220
|
-
|
1221
|
-
|
1222
1195
|
}
|
1223
1196
|
}];
|
1224
1197
|
});
|
@@ -1274,12 +1247,10 @@ BOOL isUsingAdManagerRequest = YES;
|
|
1274
1247
|
BOOL autoShow = [[options valueForKey:@"autoShow"] boolValue];
|
1275
1248
|
auto_Show = autoShow;
|
1276
1249
|
adFormat = 3;
|
1277
|
-
|
1250
|
+
[self setAdRequest];
|
1278
1251
|
if (adFormat == 3) {
|
1279
1252
|
dispatch_async(dispatch_get_main_queue(), ^{
|
1280
|
-
|
1281
|
-
|
1282
|
-
[GADRewardedAd loadWithAdUnitID:adUnitId request:request completionHandler:^(GADRewardedAd *ad, NSError *error) {
|
1253
|
+
[GADRewardedAd loadWithAdUnitID:adUnitId request:self.globalRequest completionHandler:^(GADRewardedAd *ad, NSError *error) {
|
1283
1254
|
if (error) {
|
1284
1255
|
NSDictionary *errorData = @{@"error": error.localizedDescription ?: @"Unknown error"};
|
1285
1256
|
NSData *jsonData = [NSJSONSerialization dataWithJSONObject:errorData options:0 error:nil];
|
@@ -1297,17 +1268,14 @@ BOOL isUsingAdManagerRequest = YES;
|
|
1297
1268
|
__weak __typeof(self) weakSelf = self;
|
1298
1269
|
self.rewardedAd.paidEventHandler = ^(GADAdValue *_Nonnull value) {
|
1299
1270
|
__strong __typeof(weakSelf) strongSelf = weakSelf;
|
1300
|
-
if (!strongSelf) return;
|
1271
|
+
if (!strongSelf) return;
|
1301
1272
|
|
1302
|
-
// Mengambil data ad revenue
|
1303
1273
|
NSDecimalNumber *adValue = value.value;
|
1304
1274
|
NSString *currencyCode = value.currencyCode;
|
1305
1275
|
GADAdValuePrecision precision = value.precision;
|
1306
1276
|
|
1307
|
-
// Mendapatkan ID unit iklan
|
1308
1277
|
NSString *adUnitId = strongSelf.rewardedAd.adUnitID;
|
1309
1278
|
|
1310
|
-
// Mengirim data dalam format JSON
|
1311
1279
|
NSDictionary *data = @{
|
1312
1280
|
@"value": adValue,
|
1313
1281
|
@"currencyCode": currencyCode,
|
@@ -1337,7 +1305,7 @@ BOOL isUsingAdManagerRequest = YES;
|
|
1337
1305
|
|
1338
1306
|
[self fireEvent:@"" event:@"on.reward.userEarnedReward" withData:rewardJsonString];
|
1339
1307
|
isAdSkip = 2;
|
1340
|
-
|
1308
|
+
|
1341
1309
|
}];
|
1342
1310
|
} else {
|
1343
1311
|
NSDictionary *errorData = @{@"error": presentError.localizedDescription ?: @"Unknown error"};
|
@@ -1347,7 +1315,7 @@ BOOL isUsingAdManagerRequest = YES;
|
|
1347
1315
|
}
|
1348
1316
|
|
1349
1317
|
|
1350
|
-
if (
|
1318
|
+
if (isResponseInfo) {
|
1351
1319
|
GADResponseInfo *responseInfo = ad.responseInfo;
|
1352
1320
|
NSMutableArray *adNetworkInfoArray = [NSMutableArray array];
|
1353
1321
|
|
@@ -1514,9 +1482,10 @@ BOOL isUsingAdManagerRequest = YES;
|
|
1514
1482
|
return hexString;
|
1515
1483
|
}
|
1516
1484
|
|
1517
|
-
#pragma mark GADBannerViewDelegate implementation
|
1485
|
+
#pragma mark GADBannerViewDelegate implementation
|
1518
1486
|
|
1519
1487
|
- (void)bannerViewDidReceiveAd:(GADBannerView *)bannerView {
|
1488
|
+
// NSLog(@"The last loaded banner is %@collapsible.", (bannerView.isCollapsible ? @"" : @"not "));
|
1520
1489
|
NSString *collapsibleStatus = bannerView.isCollapsible ? @"collapsible" : @"not collapsible";
|
1521
1490
|
NSDictionary *eventData = @{@"collapsible" : collapsibleStatus};
|
1522
1491
|
NSError *error;
|
@@ -1529,7 +1498,6 @@ BOOL isUsingAdManagerRequest = YES;
|
|
1529
1498
|
|
1530
1499
|
[self fireEvent:@"" event:@"on.banner.load" withData:nil];
|
1531
1500
|
|
1532
|
-
|
1533
1501
|
if (auto_Show && self.bannerView) {
|
1534
1502
|
[self addBannerViewToView:command];
|
1535
1503
|
self.bannerView.hidden = NO;
|
@@ -1566,7 +1534,7 @@ BOOL isUsingAdManagerRequest = YES;
|
|
1566
1534
|
|
1567
1535
|
|
1568
1536
|
|
1569
|
-
if (
|
1537
|
+
if (isResponseInfo) {
|
1570
1538
|
GADResponseInfo *responseInfo = self.bannerView.responseInfo;
|
1571
1539
|
NSMutableArray *adNetworkInfoArray = [NSMutableArray array];
|
1572
1540
|
|
@@ -1637,7 +1605,7 @@ BOOL isUsingAdManagerRequest = YES;
|
|
1637
1605
|
[self fireEvent:@"" event:@"on.banner.did.dismiss" withData:nil];
|
1638
1606
|
}
|
1639
1607
|
|
1640
|
-
#pragma GADFullScreeContentDelegate implementation
|
1608
|
+
#pragma mark GADFullScreeContentDelegate implementation
|
1641
1609
|
|
1642
1610
|
- (void)adWillPresentFullScreenContent:(id)ad {
|
1643
1611
|
if (adFormat == 1) {
|