emi-indo-cordova-plugin-admob 1.5.4 → 1.5.6

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.
@@ -0,0 +1,145 @@
1
+
2
+
3
+ /*
4
+
5
+ Best practices
6
+ App open ads help you monetize your app's loading screen, when the app first launches and during app switches,
7
+ but it's important to keep best practices in mind so that your users enjoy using your app. It's best to:
8
+
9
+ Show your first app open ad after your users have used your app a few times.
10
+ Show app open ads during times when your users would otherwise be waiting for your app to load.
11
+ If you have a loading screen under the app open ad,
12
+ and your loading screen completes loading before the ad is dismissed,
13
+ you may want to dismiss your loading screen in the on.appOpenAd.dismissed method.
14
+
15
+ */
16
+
17
+
18
+
19
+
20
+
21
+
22
+
23
+
24
+ let isAppOpenAdLoad = false;
25
+
26
+ function loadAppOpen() {
27
+
28
+ if (typeof cordova !== 'undefined') {
29
+ cordova.plugins.emiAdmobPlugin.loadAppOpenAd({ adUnitId: App_Open_ID, autoShow: true });
30
+ }
31
+
32
+ }
33
+
34
+
35
+ /*
36
+ function showAppOpen() {
37
+
38
+ if (typeof cordova !== 'undefined') {
39
+ if (isAppOpenAdLoad) {
40
+ cordova.plugins.emiAdmobPlugin.showAppOpenAd();
41
+ }
42
+ }
43
+
44
+ }
45
+
46
+ */
47
+
48
+
49
+ /*
50
+ on.appOpenAd.loaded
51
+ on.appOpenAd.failed.loaded
52
+ on.appOpenAd.dismissed
53
+ on.appOpenAd.failed.show
54
+ on.appOpenAd.show
55
+
56
+ // New event plugin v1.5.5 or higher
57
+
58
+ on.appOpenAd.revenue
59
+ on.appOpenAd.responseInfo
60
+
61
+
62
+ */
63
+
64
+
65
+ document.addEventListener('on.appOpenAd.loaded', () => {
66
+ isAppOpenAdLoad = true;
67
+ console.log("on.appOpenAd.loaded");
68
+ window.log.value += ("\n on.appOpenAd.loaded");
69
+ });
70
+
71
+
72
+ document.addEventListener('on.appOpenAd.failed.loaded', (error) => {
73
+ isAppOpenAdLoad = false;
74
+ console.log("on.appOpenAd.failed.loaded" + JSON.stringify(error));
75
+
76
+ window.log.value += ("\n on.appOpenAd.failed.loaded" + JSON.stringify(error));
77
+ });
78
+
79
+
80
+ document.addEventListener('on.appOpenAd.failed.show', (error) => {
81
+ isAppOpenAdLoad = false;
82
+ console.log("on.appOpenAd.failed.show" + JSON.stringify(error));
83
+
84
+ window.log.value += ("\n on.appOpenAd.failed.show" + JSON.stringify(error));
85
+ });
86
+
87
+
88
+
89
+ // all events that contain the keyword dismissed there is a block to load the ad after it is closed by the user.
90
+ document.addEventListener('on.appOpenAd.dismissed', () => {
91
+ // Stop loading the app, go straight to the main menu of the app.
92
+ isAppOpenAdLoad = false;
93
+ console.log("Stop loading the app, go straight to the main menu of the app.");
94
+ console.log("you can load ads automatically after the ads are closed by users");
95
+
96
+
97
+ window.log.value += ("\n you can load ads automatically after the ads are closed by users");
98
+
99
+ });
100
+
101
+
102
+
103
+
104
+
105
+
106
+
107
+
108
+
109
+
110
+
111
+ /*
112
+ // DEBUG
113
+ // isResponseInfo: true, // debug Default false
114
+ document.addEventListener('on.appOpenAd.responseInfo', (data) => {
115
+
116
+ console.log("on.appOpenAd.responseInfo" + JSON.stringify(data));
117
+ if (window.log) window.log.value += ("\n on.appOpenAd.responseInfo" + JSON.stringify(data));
118
+ });
119
+
120
+ */
121
+
122
+
123
+
124
+
125
+
126
+ /*
127
+ https://support.google.com/admob/answer/11322405
128
+
129
+ Turn on the setting for impression-level ad revenue in your AdMob account:
130
+ Sign in to your AdMob account at https://apps.admob.com.
131
+ Click Settings in the sidebar.
132
+ Click the Account tab.
133
+ In the Account controls section, click the Impression-level ad revenue toggle to turn on this setting.
134
+ */
135
+
136
+ document.addEventListener('on.appOpenAd.revenue', (data) => {
137
+
138
+ console.log(data.value)
139
+ console.log(data.currencyCode)
140
+ console.log(data.precision)
141
+ console.log(data.adUnitId)
142
+
143
+ // console.log("on.appOpenAd.revenue" + JSON.stringify(data));
144
+ if (window.log) window.log.value += ("\n on.appOpenAd.revenue" + JSON.stringify(data));
145
+ });
@@ -0,0 +1,155 @@
1
+ // cordova.plugins.emiAdmobPlugin.styleBannerAd({ padding: 50, margins: 50 }); // (Optional only android)
2
+ //cordova.plugins.emiAdmobPlugin.loadBannerAd({config});
3
+ //cordova.plugins.emiAdmobPlugin.showBannerAd(); // default
4
+ //cordova.plugins.emiAdmobPlugin.hideBannerAd(); // default
5
+ //cordova.plugins.emiAdmobPlugin.removeBannerAd(); // default
6
+
7
+
8
+
9
+ function loadBanner() {
10
+
11
+ if (typeof cordova !== 'undefined') {
12
+
13
+ cordova.plugins.emiAdmobPlugin.loadBannerAd({
14
+ adUnitId: Banner_ID, //Banner_ID,
15
+ position: "bottom-center",
16
+ size: "responsive_adaptive", // autoResize: true (only responsive_adaptive)
17
+ collapsible: "bottom", // position: top | bottom (disable, empty string)
18
+ autoResize: true, // default false
19
+ autoShow: true, // default false
20
+
21
+ });
22
+ }
23
+
24
+ }
25
+
26
+
27
+
28
+
29
+
30
+ /* ///////<<<< bannerAd position >>>>>>\\\\\\\
31
+
32
+ (ANDROID)
33
+
34
+ top-right
35
+ top-center
36
+ left
37
+ center
38
+ right
39
+ bottom-center
40
+ bottom-right
41
+
42
+ (IOS)
43
+
44
+ bottom-center
45
+ top-center
46
+
47
+ */
48
+
49
+ /* ///////<<<< bannerAd size >>>>>>\\\\\\\
50
+
51
+ (ANDROID)
52
+
53
+ responsive_adaptive
54
+ anchored_adaptive
55
+ full_width_adaptive
56
+ in_line_adaptive
57
+ banner
58
+ large_banner
59
+ medium_rectangle
60
+ full_banner
61
+ leaderboard
62
+ fluid
63
+
64
+ (IOS)
65
+
66
+ responsive_adaptive
67
+ in_line_adaptive
68
+ banner
69
+ large_banner
70
+ full_banner
71
+ leaderboard
72
+
73
+
74
+
75
+ */
76
+
77
+
78
+
79
+
80
+ /* ///////<<<< bannerAd event >>>>>>\\\\\\\
81
+
82
+ on.banner.load
83
+ on.banner.failed.load
84
+ on.banner.click
85
+ on.banner.close
86
+ on.banner.impression
87
+ on.banner.open
88
+
89
+ on.banner.revenue
90
+ on.banner.remove
91
+ on.banner.hide
92
+
93
+ // New event plugin v1.5.5 or higher
94
+
95
+ on.is.collapsible
96
+ on.bannerAd.responseInfo
97
+
98
+ */
99
+
100
+
101
+
102
+
103
+ // EVENT For example
104
+
105
+ document.addEventListener('on.banner.load', () => {
106
+ console.log("on banner load");
107
+ });
108
+
109
+
110
+ document.addEventListener('on.is.collapsible', function (event) {
111
+ // bannerConfig collapsible: "bottom", // position: top | bottom (disable, empty string)
112
+ console.log("Collapsible Status: " + event.collapsible);
113
+
114
+
115
+ });
116
+
117
+ document.addEventListener('on.banner.failed.load', (error) => {
118
+ console.log("on.banner.failed.load" + JSON.stringify(error));
119
+ });
120
+
121
+
122
+
123
+ /*
124
+ // DEBUG
125
+ // isResponseInfo: true, // debug Default false
126
+ document.addEventListener('on.bannerAd.responseInfo', (data) => {
127
+ console.log("on.bannerAd.responseInfo" + JSON.stringify(data));
128
+ if (window.log) window.log.value += ("\n on.bannerAd.responseInfo" + JSON.stringify(data));
129
+ });
130
+
131
+ */
132
+
133
+
134
+
135
+
136
+ /*
137
+ https://support.google.com/admob/answer/11322405
138
+
139
+ Turn on the setting for impression-level ad revenue in your AdMob account:
140
+ Sign in to your AdMob account at https://apps.admob.com.
141
+ Click Settings in the sidebar.
142
+ Click the Account tab.
143
+ In the Account controls section, click the Impression-level ad revenue toggle to turn on this setting.
144
+ */
145
+
146
+ document.addEventListener('on.banner.revenue', (data) => {
147
+
148
+ console.log(data.value)
149
+ console.log(data.currencyCode)
150
+ console.log(data.precision)
151
+ console.log(data.adUnitId)
152
+
153
+ //console.log("on.banner.revenue" + JSON.stringify(data));
154
+ if (window.log) window.log.value += ("\n on.banner.revenue" + JSON.stringify(data));
155
+ });
@@ -0,0 +1,111 @@
1
+
2
+ window.log = document.getElementById('log');
3
+
4
+ var App_Open_ID;
5
+ var Banner_ID;
6
+ var Interstitial_ID;
7
+ var Rewarded_ID;
8
+ var Rewarded_Interstitial_ID;
9
+
10
+ // Ad format Demo ad unit ID
11
+ // https://developers.google.com/admob/android/test-ads
12
+ // https://developers.google.com/admob/ios/test-ads
13
+
14
+
15
+ /* https://support.google.com/admob/answer/9493252?hl=en
16
+ Best practice when using ad original ID unit,
17
+ the app must be uploaded to the play store or app store,
18
+ and you must upload it from there,
19
+ otherwise you may be subject to ad serving restrictions,
20
+ if it happens often, it is possible that your admob account will be permanently disabled.
21
+ */
22
+
23
+
24
+
25
+ if (window.cordova.platformId === 'ios') {
26
+
27
+ App_Open_ID = 'ca-app-pub-3940256099942544/5575463023';
28
+ Banner_ID = 'ca-app-pub-3940256099942544/2934735716';
29
+ Interstitial_ID = 'ca-app-pub-3940256099942544/4411468910';
30
+ Rewarded_ID = 'ca-app-pub-3940256099942544/1712485313';
31
+ Rewarded_Interstitial_ID = 'ca-app-pub-3940256099942544/6978759866';
32
+
33
+ } else {
34
+ // Assume Android
35
+ App_Open_ID = 'ca-app-pub-3940256099942544/9257395921';
36
+ Banner_ID = 'ca-app-pub-3940256099942544/9214589741';
37
+ Interstitial_ID = 'ca-app-pub-3940256099942544/1033173712';
38
+ Rewarded_ID = 'ca-app-pub-3940256099942544/5224354917';
39
+ Rewarded_Interstitial_ID = 'ca-app-pub-3940256099942544/5354046379';
40
+ }
41
+
42
+
43
+
44
+
45
+ function cleanText(){
46
+
47
+ window.log.value = "";
48
+
49
+ }
50
+
51
+
52
+
53
+ //////////////////////
54
+ // cordova deviceready
55
+ /////////////////////
56
+ document.addEventListener("deviceready", function () {
57
+
58
+
59
+ // targeting
60
+ cordova.plugins.emiAdmobPlugin.targeting({
61
+ childDirectedTreatment: false, // default: false
62
+ underAgeOfConsent: false, // default: false
63
+ contentRating: "MA", // value: G | MA | PG | T | ""
64
+ });
65
+
66
+
67
+
68
+ // globalSettings
69
+ cordova.plugins.emiAdmobPlugin.globalSettings({
70
+ setAppMuted: false, // Type Boolean default: false
71
+ setAppVolume: 1.0, // Type float
72
+ pubIdEnabled: false, // default: false
73
+ });
74
+
75
+
76
+
77
+
78
+
79
+ // AdMob Sdk initialize
80
+
81
+ cordova.plugins.emiAdmobPlugin.initialize({
82
+
83
+ isUsingAdManagerRequest: true, // AdManagerAdRequest.Builder | AdRequest.Builder (Default true)
84
+ isResponseInfo: true, // debug Default false
85
+ isConsentDebug: true, // debug Default false
86
+
87
+ });
88
+
89
+
90
+ // SDK EVENT Initialization
91
+ // Optional
92
+ document.addEventListener('on.sdkInitialization', (data) => {
93
+ // JSON.stringify(data)
94
+ const sdkVersion = data.version;
95
+ // const adAdapter = data.adapters;
96
+ const conStatus = data.consentStatus;
97
+ // const gdprApplie = data.gdprApplies;
98
+ // const purposeConsent = data.purposeConsents;
99
+ // const vendorConsents = data.vendorConsents;
100
+ // const conTCString = data.consentTCString;
101
+ // const additionalConsent = data.additionalConsent;
102
+ log.value += ("\n On Sdk Initialization version: " + sdkVersion);
103
+ log.value += ("\n On Consent Status: " + conStatus);
104
+
105
+ loadBanner(); // auto show
106
+
107
+ });
108
+
109
+
110
+
111
+ }, false);
@@ -0,0 +1,122 @@
1
+
2
+
3
+
4
+ let isInterstitialLoad = false;
5
+
6
+ function loadInterstitial() {
7
+
8
+ if (typeof cordova !== 'undefined') {
9
+
10
+ cordova.plugins.emiAdmobPlugin.loadInterstitialAd({ adUnitId: Interstitial_ID, autoShow: false });
11
+
12
+ }
13
+ }
14
+
15
+ function showInterstitial() {
16
+
17
+ if (typeof cordova !== 'undefined') {
18
+
19
+ if (isInterstitialLoad) {
20
+ cordova.plugins.emiAdmobPlugin.showInterstitialAd();
21
+ }
22
+ }
23
+
24
+ }
25
+
26
+ /*
27
+
28
+ on.interstitial.loaded
29
+ on.interstitial.failed.load
30
+ on.interstitial.click
31
+ on.interstitial.dismissed
32
+ on.interstitial.failed.show
33
+ on.interstitial.impression
34
+ on.interstitial.show
35
+
36
+ // New event plugin v1.5.5 or higher
37
+
38
+ on.interstitial.revenue
39
+ on.interstitialAd.responseInfo
40
+
41
+ */
42
+
43
+
44
+ // EVENT For example
45
+
46
+ document.addEventListener('on.interstitial.loaded', () => {
47
+ isInterstitialLoad = true;
48
+ console.log("on interstitial Ad loaded");
49
+
50
+ window.log.value += ("\n on interstitial Ad loaded");
51
+ });
52
+
53
+
54
+ // all events that contain the keyword dismissed there is a block to load the ad after it is closed by the user.
55
+ document.addEventListener('on.interstitial.dismissed', () => {
56
+ isInterstitialLoad = false;
57
+ console.log("on interstitial Ad dismissed");
58
+ console.log("you can load ads automatically after the ads are closed by users");
59
+
60
+ loadInterstitial();
61
+
62
+ window.log.value += ("\n you can load ads automatically after the ads are closed by users");
63
+
64
+ });
65
+
66
+
67
+ document.addEventListener('on.interstitial.failed.load', (error) => {
68
+ isInterstitialLoad = false;
69
+ console.log("on.interstitial.failed.load" + JSON.stringify(error));
70
+
71
+ window.log.value += ("\n on.interstitial.failed.load" + JSON.stringify(error));
72
+ });
73
+
74
+
75
+ document.addEventListener('on.interstitial.failed.show', (error) => {
76
+ isInterstitialLoad = false;
77
+ console.log("on.interstitial.failed.show" + JSON.stringify(error));
78
+
79
+ window.log.value += ("\n on.interstitial.failed.show" + JSON.stringify(error));
80
+ });
81
+
82
+
83
+ /*
84
+ // DEBUG
85
+ // isResponseInfo: true, // debug Default false
86
+ document.addEventListener('on.interstitialAd.responseInfo', (data) => {
87
+
88
+ console.log("on.interstitialAd.responseInfo" + JSON.stringify(data));
89
+ if (window.log) window.log.value += ("\n on.interstitialAd.responseInfo" + JSON.stringify(data));
90
+ });
91
+
92
+ */
93
+
94
+
95
+
96
+
97
+
98
+
99
+
100
+ /*
101
+ https://support.google.com/admob/answer/11322405
102
+
103
+ Turn on the setting for impression-level ad revenue in your AdMob account:
104
+ Sign in to your AdMob account at https://apps.admob.com.
105
+ Click Settings in the sidebar.
106
+ Click the Account tab.
107
+ In the Account controls section, click the Impression-level ad revenue toggle to turn on this setting.
108
+ */
109
+
110
+ document.addEventListener('on.interstitial.revenue', (data) => {
111
+
112
+ console.log(data.value)
113
+ console.log(data.currencyCode)
114
+ console.log(data.precision)
115
+ console.log(data.adUnitId)
116
+
117
+ // console.log("on.interstitial.revenue" + JSON.stringify(data));
118
+ if (window.log) window.log.value += ("\n on.interstitial.revenue" + JSON.stringify(data));
119
+ });
120
+
121
+
122
+
@@ -0,0 +1,126 @@
1
+
2
+
3
+ let isRewardedLoad = false;
4
+
5
+ function loadRewarded() {
6
+
7
+ if (typeof cordova !== 'undefined') {
8
+ cordova.plugins.emiAdmobPlugin.loadRewardedAd({ adUnitId: Rewarded_ID, autoShow: false });
9
+ }
10
+
11
+ }
12
+
13
+ function showRewarded() {
14
+
15
+ if (typeof cordova !== 'undefined') {
16
+ if (isRewardedLoad) {
17
+ cordova.plugins.emiAdmobPlugin.showRewardedAd();
18
+ }
19
+ }
20
+
21
+ }
22
+
23
+
24
+ /*
25
+ on.rewarded.loaded
26
+ on.rewarded.failed.load
27
+ on.rewarded.click
28
+ on.rewarded.dismissed
29
+ on.rewarded.failed.show
30
+ on.rewarded.impression
31
+ on.rewarded.show
32
+ on.reward.userEarnedReward
33
+ on.rewarded.ad.skip
34
+
35
+ // New event plugin v1.5.5 or higher
36
+
37
+ on.rewarded.revenue
38
+ on.rewardedAd.responseInfo
39
+
40
+ */
41
+
42
+
43
+
44
+ document.addEventListener('on.rewarded.loaded', () => {
45
+ isRewardedLoad = true;
46
+ console.log("on rewarded Ad loaded");
47
+ window.log.value += ("\n on rewarded Ad loaded");
48
+ });
49
+
50
+
51
+ document.addEventListener('on.rewarded.failed.load', (error) => {
52
+ isRewardedLoad = false;
53
+ console.log("on.rewarded.failed.load" + JSON.stringify(error));
54
+
55
+ window.log.value += ("\n on.rewarded.failed.load" + JSON.stringify(error));
56
+ });
57
+
58
+
59
+ document.addEventListener('on.rewarded.failed.show', (error) => {
60
+ isRewardedLoad = false;
61
+ console.log("on.rewarded.failed.show" + JSON.stringify(error));
62
+
63
+ window.log.value += ("\n on.rewarded.failed.show" + JSON.stringify(error));
64
+ });
65
+
66
+
67
+ document.addEventListener('on.reward.userEarnedReward', (rewarded) => {
68
+ // Give gifts to users here
69
+ isRewardedLoad = false;
70
+ console.log("Give gifts to users here" + JSON.stringify(rewarded));
71
+ // const rewardAmount = rewarded.amount;
72
+ // const rewardType = rewarded.currency;
73
+ window.log.value += ("\n Give gifts to users here" + JSON.stringify(rewarded));
74
+ });
75
+
76
+
77
+ // all events that contain the keyword dismissed there is a block to load the ad after it is closed by the user.
78
+ document.addEventListener('on.rewarded.dismissed', () => {
79
+ isRewardedLoad = false;
80
+ console.log("on interstitial Ad dismissed");
81
+ console.log("you can load ads automatically after the ads are closed by users");
82
+ loadRewarded();
83
+
84
+ window.log.value += ("\n you can load ads automatically after the ads are closed by users");
85
+
86
+ });
87
+
88
+
89
+
90
+
91
+
92
+ /*
93
+ // DEBUG
94
+ // isResponseInfo: true, // debug Default false
95
+ document.addEventListener('on.rewardedAd.responseInfo', (data) => {
96
+
97
+ console.log("on.rewardedAd.responseInfo" + JSON.stringify(data));
98
+ if (window.log) window.log.value += ("\n on.rewardedAd.responseInfo" + JSON.stringify(data));
99
+ });
100
+
101
+ */
102
+
103
+
104
+
105
+
106
+
107
+ /*
108
+ https://support.google.com/admob/answer/11322405
109
+
110
+ Turn on the setting for impression-level ad revenue in your AdMob account:
111
+ Sign in to your AdMob account at https://apps.admob.com.
112
+ Click Settings in the sidebar.
113
+ Click the Account tab.
114
+ In the Account controls section, click the Impression-level ad revenue toggle to turn on this setting.
115
+ */
116
+
117
+ document.addEventListener('on.rewarded.revenue', (data) => {
118
+
119
+ console.log(data.value)
120
+ console.log(data.currencyCode)
121
+ console.log(data.precision)
122
+ console.log(data.adUnitId)
123
+
124
+ // console.log("on.rewarded.revenue" + JSON.stringify(data));
125
+ if (window.log) window.log.value += ("\n on.rewarded.revenue" + JSON.stringify(data));
126
+ });
package/package.json CHANGED
@@ -1,12 +1,12 @@
1
1
  {
2
2
  "name": "emi-indo-cordova-plugin-admob",
3
- "version": "1.5.4",
3
+ "version": "1.5.6",
4
4
  "description": "Cordova Plugin Admob Android IOS",
5
5
  "cordova": {
6
6
  "id": "emi-indo-cordova-plugin-admob",
7
7
  "platforms": [
8
8
  "android",
9
- "ios"
9
+ "ios"
10
10
  ]
11
11
  },
12
12
  "keywords": [
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.5.4">
3
+ id="emi-indo-cordova-plugin-admob" version="1.5.6">
4
4
 
5
5
  <name>emiAdmobPlugin</name>
6
6
  <description>Cordova Plugin Admob Android IOS</description>
@@ -61,11 +61,11 @@
61
61
  <!-- Sample AdMob app ID: ca-app-pub-3940256099942544~3347511713 -->
62
62
 
63
63
  <preference name="APP_ID_ANDROID" default="ca-app-pub-3940256099942544~3347511713" />
64
- <preference name="PLAY_SERVICES_VERSION" default="23.4.0" />
64
+ <preference name="PLAY_SERVICES_VERSION" default="23.5.0" />
65
65
 
66
66
  <framework src="com.google.android.gms:play-services-ads:$PLAY_SERVICES_VERSION" />
67
67
 
68
- <preference name="UMP" default="3.0.0" />
68
+ <preference name="UMP" default="3.1.0" />
69
69
  <framework src="com.google.android.ump:user-messaging-platform:$UMP" />
70
70
 
71
71
  <!-- Dependency Consent status will automatically reset after 12 months -->
@@ -74,8 +74,7 @@
74
74
 
75
75
 
76
76
  <config-file parent="/*" target="AndroidManifest.xml" />
77
- <source-file src="src/android/emiAdmobPlugin.kt"
78
- target-dir="app/src/main/kotlin/emi/indo/cordova/plugin/admob" />
77
+ <source-file src="src/android/emiAdmobPlugin.kt" target-dir="app/src/main/kotlin/emi/indo/cordova/plugin/admob" />
79
78
 
80
79
  </platform>
81
80