emi-indo-cordova-plugin-admob 2.0.4 → 2.0.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/example/www/index.html +5 -1
- package/example/www/js/bannerAd.js +18 -3
- package/example/www/js/deviceready.js +6 -6
- package/example/www/js/privacyOptionsFormShow.js +33 -0
- package/package.json +1 -1
- package/plugin.xml +1 -1
- package/src/ios/emiAdmobPlugin.h +1 -0
- package/src/ios/emiAdmobPlugin.m +58 -15
package/example/www/index.html
CHANGED
@@ -8,9 +8,10 @@
|
|
8
8
|
<script src="js/rewardedAd.js" defer></script>
|
9
9
|
<script src="js/rewardedInterstitialAd.js" defer></script>
|
10
10
|
<script src="js/adSense.js" defer></script>
|
11
|
+
<script src="js/privacyOptionsFormShow.js" defer></script>
|
11
12
|
</head>
|
12
13
|
<body>
|
13
|
-
|
14
|
+
|
14
15
|
|
15
16
|
<label for="event">Debug Event All response :</label>
|
16
17
|
<textarea id="log" name="log" rows="20" cols="40"></textarea>
|
@@ -34,6 +35,9 @@
|
|
34
35
|
<p> <button onclick="registerWebView();">AdSense Register</button></p>
|
35
36
|
<p> <button onclick="loadUrl();">AdSense load Url</button></p>
|
36
37
|
|
38
|
+
<p> <button onclick="showPrivacyOptionsForm();">Show Privacy Options Form</button></p>
|
39
|
+
<p> <button onclick="forceDisplayPrivacyForm();">Force Display Privacy Form</button></p>
|
40
|
+
|
37
41
|
<p> <button onclick="cleanText();">Clean response Text</button></p>
|
38
42
|
|
39
43
|
</body>
|
@@ -10,15 +10,30 @@ function loadBanner() {
|
|
10
10
|
|
11
11
|
if (typeof cordova !== 'undefined') {
|
12
12
|
|
13
|
-
|
14
|
-
|
13
|
+
// IOS Still under development
|
14
|
+
if (isPlatformIOS){
|
15
|
+
// If there is a problem isOverlapping: false
|
16
|
+
cordova.plugins.emiAdmobPlugin.styleBannerAd({
|
17
|
+
isOverlapping: true, // default false IOS | Android
|
18
|
+
paddingWebView: 1.0 // Only IOS
|
19
|
+
});
|
20
|
+
|
21
|
+
} else {
|
22
|
+
|
23
|
+
// Android
|
24
|
+
|
25
|
+
cordova.plugins.emiAdmobPlugin.styleBannerAd({
|
15
26
|
isOverlapping: true, // default false IOS | Android
|
16
27
|
isStatusBarShow: true, // default true Only Android
|
17
|
-
paddingWebView: 1.0, // Only IOS > padding banner Container and webView Container
|
18
28
|
overlappingHeight: 0, // default 0 (Automatic) Only Android
|
19
29
|
padding: 0, // default 0 Only Android
|
20
30
|
margins: 0 // default 0 (Automatic) Only Android
|
21
31
|
});
|
32
|
+
|
33
|
+
|
34
|
+
}
|
35
|
+
|
36
|
+
|
22
37
|
|
23
38
|
|
24
39
|
|
@@ -83,14 +83,14 @@ document.addEventListener("deviceready", function () {
|
|
83
83
|
}
|
84
84
|
|
85
85
|
|
86
|
-
// (Optional)
|
87
|
-
|
86
|
+
// (Optional IOS | ANDROID)
|
87
|
+
// Documentation: https://github.com/EMI-INDO/emi-indo-cordova-plugin-admob/discussions/54
|
88
|
+
/*
|
88
89
|
cordova.plugins.emiAdmobPlugin.metaData({
|
89
90
|
|
90
|
-
useCustomConsentManager: false, // deactivate Google's consent Default false
|
91
|
-
|
92
|
-
|
93
|
-
setKeyword: "" // https://github.com/EMI-INDO/emi-indo-cordova-plugin-admob/discussions/54
|
91
|
+
useCustomConsentManager: false, // deactivate Google's consent Default false (IOS | ANDROID)
|
92
|
+
isEnabledKeyword: false, // Default false (IOS | ANDROID)
|
93
|
+
setKeyword: "" // string separated by commas without spaces (IOS | ANDROID)
|
94
94
|
|
95
95
|
});
|
96
96
|
*/
|
@@ -0,0 +1,33 @@
|
|
1
|
+
|
2
|
+
|
3
|
+
|
4
|
+
function showPrivacyOptionsForm() {
|
5
|
+
|
6
|
+
if (typeof cordova !== 'undefined') {
|
7
|
+
cordova.plugins.emiAdmobPlugin.showPrivacyOptionsForm(); // IOS | Android
|
8
|
+
}
|
9
|
+
|
10
|
+
}
|
11
|
+
|
12
|
+
|
13
|
+
|
14
|
+
|
15
|
+
/*
|
16
|
+
There is a method to force the show Privacy Options Form
|
17
|
+
|
18
|
+
NOTE forceDisplayPrivacyForm
|
19
|
+
|
20
|
+
This method is not recommended, as no matter what country the form is in, it will still be displayed.
|
21
|
+
So this method must be called with an on-click, so that it is not triggered continuously.
|
22
|
+
use this method wisely.
|
23
|
+
|
24
|
+
*/
|
25
|
+
|
26
|
+
|
27
|
+
function forceDisplayPrivacyForm() {
|
28
|
+
|
29
|
+
if (typeof cordova !== 'undefined') {
|
30
|
+
cordova.plugins.emiAdmobPlugin.forceDisplayPrivacyForm(); // Only IOS
|
31
|
+
}
|
32
|
+
|
33
|
+
}
|
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="2.0.
|
3
|
+
id="emi-indo-cordova-plugin-admob" version="2.0.5">
|
4
4
|
|
5
5
|
<name>emiAdmobPlugin</name>
|
6
6
|
<description>Cordova/Quasar/Capacitor Plugin Admob Android IOS</description>
|
package/src/ios/emiAdmobPlugin.h
CHANGED
@@ -25,6 +25,7 @@
|
|
25
25
|
- (void)showPrivacyOptionsForm:(CDVInvokedUrlCommand *)command;
|
26
26
|
- (void)forceDisplayPrivacyForm:(CDVInvokedUrlCommand *)command;
|
27
27
|
- (void)consentReset:(CDVInvokedUrlCommand *)command;
|
28
|
+
- (void)metaData:(CDVInvokedUrlCommand *)command;
|
28
29
|
- (void)getIabTfc:(CDVInvokedUrlCommand *)command;
|
29
30
|
- (void)loadAppOpenAd:(CDVInvokedUrlCommand *)command;
|
30
31
|
- (void)showAppOpenAd:(CDVInvokedUrlCommand *)command;
|
package/src/ios/emiAdmobPlugin.m
CHANGED
@@ -25,6 +25,8 @@ BOOL auto_Show = NO;
|
|
25
25
|
NSString *setPosition = @"bottom-center"; // Default
|
26
26
|
NSString *bannerSaveAdUnitId = @""; // autoResize dependency = true
|
27
27
|
|
28
|
+
|
29
|
+
|
28
30
|
BOOL isCollapsible = NO;
|
29
31
|
BOOL isAutoResize = NO;
|
30
32
|
|
@@ -41,6 +43,11 @@ BOOL isResponseInfo = NO;
|
|
41
43
|
BOOL isUsingAdManagerRequest = YES;
|
42
44
|
|
43
45
|
|
46
|
+
BOOL isCustomConsentManager = NO;
|
47
|
+
BOOL isEnabledKeyword = NO;
|
48
|
+
NSString *setKeyword = @"";
|
49
|
+
|
50
|
+
|
44
51
|
- (BOOL)canRequestAds {
|
45
52
|
return UMPConsentInformation.sharedInstance.canRequestAds;
|
46
53
|
}
|
@@ -48,6 +55,7 @@ BOOL isUsingAdManagerRequest = YES;
|
|
48
55
|
isUsingAdManagerRequest = value;
|
49
56
|
}
|
50
57
|
|
58
|
+
|
51
59
|
- (void)setAdRequest {
|
52
60
|
if (isUsingAdManagerRequest) {
|
53
61
|
self.globalRequest = [GAMRequest request];
|
@@ -56,9 +64,23 @@ BOOL isUsingAdManagerRequest = YES;
|
|
56
64
|
self.globalRequest = [GADRequest request];
|
57
65
|
NSLog(@"Using AdMob request");
|
58
66
|
}
|
67
|
+
|
68
|
+
if (isEnabledKeyword && setKeyword.length > 0) {
|
69
|
+
NSArray *keywords = [setKeyword componentsSeparatedByString:@","];
|
70
|
+
for (NSString *keyword in keywords) {
|
71
|
+
NSString *trimmedKeyword = [keyword stringByTrimmingCharactersInSet:[NSCharacterSet whitespaceCharacterSet]];
|
72
|
+
if (trimmedKeyword.length > 0) {
|
73
|
+
NSLog(@"Adding keyword: %@", trimmedKeyword);
|
74
|
+
[self.globalRequest setKeywords:[self.globalRequest.keywords arrayByAddingObject:trimmedKeyword]];
|
75
|
+
}
|
76
|
+
}
|
77
|
+
}
|
78
|
+
|
59
79
|
}
|
60
80
|
|
61
81
|
|
82
|
+
|
83
|
+
|
62
84
|
- (void)isResponseInfo:(BOOL)value {
|
63
85
|
isResponseInfo = value;
|
64
86
|
}
|
@@ -76,12 +98,19 @@ BOOL isUsingAdManagerRequest = YES;
|
|
76
98
|
[self setUsingAdManagerRequest:setAdRequest];
|
77
99
|
[self isResponseInfo:responseInfo];
|
78
100
|
[self isDebugGeography:setDebugGeography];
|
101
|
+
|
102
|
+
if (isCustomConsentManager) {
|
103
|
+
[self startGoogleMobileAdsSDK];
|
104
|
+
[self fireEvent:@"" event:@"on.custom.consent.manager.used" withData:nil];
|
105
|
+
return;
|
106
|
+
}
|
79
107
|
|
80
108
|
__block CDVPluginResult *pluginResult;
|
81
109
|
NSString *callbackId = command.callbackId;
|
82
110
|
NSString *deviceId = [self __getAdMobDeviceId];
|
83
111
|
UMPRequestParameters *parameters = [[UMPRequestParameters alloc] init];
|
84
|
-
|
112
|
+
|
113
|
+
|
85
114
|
if (setDebugGeography) {
|
86
115
|
UMPDebugSettings *debugSettings = [[UMPDebugSettings alloc] init];
|
87
116
|
parameters.debugSettings = debugSettings;
|
@@ -330,6 +359,10 @@ BOOL isUsingAdManagerRequest = YES;
|
|
330
359
|
|
331
360
|
|
332
361
|
|
362
|
+
|
363
|
+
|
364
|
+
|
365
|
+
|
333
366
|
- (BOOL)isPrivacyOptionsRequired {
|
334
367
|
UMPPrivacyOptionsRequirementStatus status = UMPConsentInformation.sharedInstance.privacyOptionsRequirementStatus;
|
335
368
|
|
@@ -632,21 +665,21 @@ BOOL isUsingAdManagerRequest = YES;
|
|
632
665
|
}
|
633
666
|
|
634
667
|
|
635
|
-
|
636
668
|
- (void)showBannerAd:(CDVInvokedUrlCommand *)command {
|
637
|
-
|
638
|
-
|
639
|
-
|
640
|
-
|
641
|
-
|
642
|
-
|
643
|
-
|
644
|
-
|
645
|
-
|
646
|
-
|
647
|
-
|
669
|
+
@try {
|
670
|
+
if (self.bannerView) {
|
671
|
+
self.bannerView.hidden = NO;
|
672
|
+
[self addBannerViewToView:command];
|
673
|
+
} else {
|
674
|
+
[self fireEvent:@"" event:@"on.banner.failed.show" withData:nil];
|
675
|
+
}
|
676
|
+
}
|
677
|
+
@catch (NSException *exception) {
|
678
|
+
NSLog(@"[AdPlugin] Error in showBannerAd: %@", exception.reason);
|
679
|
+
}
|
648
680
|
}
|
649
681
|
|
682
|
+
|
650
683
|
- (void)addBannerViewToView:(CDVInvokedUrlCommand *)command {
|
651
684
|
bannerView.translatesAutoresizingMaskIntoConstraints = NO;
|
652
685
|
[self.viewController.view addSubview:bannerView];
|
@@ -707,7 +740,9 @@ BOOL isUsingAdManagerRequest = YES;
|
|
707
740
|
constant:0]
|
708
741
|
]];
|
709
742
|
}
|
710
|
-
|
743
|
+
if (isSetOverlapping){
|
744
|
+
[self bannerOverlapping];
|
745
|
+
}
|
711
746
|
}
|
712
747
|
|
713
748
|
|
@@ -785,7 +820,16 @@ BOOL isUsingAdManagerRequest = YES;
|
|
785
820
|
}
|
786
821
|
|
787
822
|
|
823
|
+
- (void)metaData:(CDVInvokedUrlCommand *)command {
|
824
|
+
NSDictionary *options = [command.arguments objectAtIndex:0];
|
825
|
+
BOOL useCustomConsentManager = [[options valueForKey:@"useCustomConsentManager"] boolValue];
|
826
|
+
BOOL useCustomKeyword = [[options valueForKey:@"isEnabledKeyword"] boolValue];
|
827
|
+
NSString *keywordValue = [options valueForKey:@"setKeyword"];
|
788
828
|
|
829
|
+
isCustomConsentManager = useCustomConsentManager;
|
830
|
+
isEnabledKeyword = useCustomKeyword;
|
831
|
+
setKeyword = keywordValue;
|
832
|
+
}
|
789
833
|
|
790
834
|
|
791
835
|
- (void)styleBannerAd:(CDVInvokedUrlCommand *)command {
|
@@ -1600,7 +1644,6 @@ BOOL isUsingAdManagerRequest = YES;
|
|
1600
1644
|
[self fireEvent:@"" event:@"on.banner.load" withData:bannerLoadJsonString];
|
1601
1645
|
|
1602
1646
|
if (auto_Show && self.bannerView) {
|
1603
|
-
[self addBannerViewToView:command];
|
1604
1647
|
[self showBannerAd:command];
|
1605
1648
|
} else {
|
1606
1649
|
[self fireEvent:@"" event:@"on.banner.failed.show" withData:nil];
|