emi-indo-cordova-plugin-admob 1.6.0 → 1.6.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -1,4 +1,9 @@
1
1
 
2
+ ## New feature suggestion
3
+ > [!TIP]
4
+ > - Funding is needed to add a new feature of native ads that can be scrolled within html content elements.
5
+ > - I will not settle how much funding is needed to add this feature.
6
+
2
7
 
3
8
  # emi-indo-cordova-plugin-admob
4
9
  Cordova Plugin Admob Android and IOS
@@ -11,11 +16,15 @@
11
16
  ### User Messaging Platform (UMP IOS: 2.6.0) [Release Notes:](https://developers.google.com/ad-manager/mobile-ads-sdk/ios/privacy/download)
12
17
  ### IAB Europe Transparency & Consent Framework (CPM: 2.2.0)
13
18
 
14
-
15
19
  ## New example
16
20
  - https://github.com/EMI-INDO/emi-indo-cordova-plugin-admob/tree/main/example/www
17
21
 
18
22
 
23
+ ## Documentation Capacitor example
24
+ - [Documentation Capacitor example: ](https://github.com/EMI-INDO/emi-indo-cordova-plugin-admob/discussions/29)
25
+
26
+
27
+
19
28
  ## Minimum Cordova Engines
20
29
  - cordova-android version = 12.0.0
21
30
  - cordova-ios version = 7.0.0
@@ -333,7 +342,7 @@ document.addEventListener('on.appOpenAd.loaded', () => {
333
342
  </pre>
334
343
  </details>
335
344
 
336
- - [FULL AppOpenAd basic:](https://github.com/EMI-INDO/emi-indo-cordova-plugin-admob/blob/main/example/www/js/appOpenAd.js)
345
+ - [FULL AppOpenAd basic:](https://github.com/EMI-INDO/emi-indo-cordova-plugin-admob/blob/main/Example/www/js/appOpenAd.js)
337
346
 
338
347
 
339
348
 
@@ -436,7 +445,7 @@ console.log("Collapsible Status: " + event.collapsible);
436
445
  </pre>
437
446
  </details>
438
447
 
439
- [FULL Banner basic:](https://github.com/EMI-INDO/emi-indo-cordova-plugin-admob/blob/main/example/www/js/bannerAd.js)
448
+ [FULL Banner basic:](https://github.com/EMI-INDO/emi-indo-cordova-plugin-admob/blob/main/Example/www/js/bannerAd.js)
440
449
 
441
450
 
442
451
  ## Interstitial ADS
@@ -499,7 +508,7 @@ document.addEventListener('on.interstitial.dismissed', () => {
499
508
  </details>
500
509
 
501
510
 
502
- [FULL Interstitial basic: ](https://github.com/EMI-INDO/emi-indo-cordova-plugin-admob/blob/main/example/www/js/interstitialAd.js)
511
+ [FULL Interstitial basic: ](https://github.com/EMI-INDO/emi-indo-cordova-plugin-admob/blob/main/Example/www/js/interstitialAd.js)
503
512
 
504
513
 
505
514
 
@@ -628,7 +637,7 @@ document.addEventListener('on.rewarded.dismissed', () => {
628
637
  </pre>
629
638
  </details>
630
639
 
631
- [FULL Rewarded basic: ](https://github.com/EMI-INDO/emi-indo-cordova-plugin-admob/blob/main/example/www/js/rewardedAd.js)
640
+ [FULL Rewarded basic: ](https://github.com/EMI-INDO/emi-indo-cordova-plugin-admob/blob/main/Example/www/js/rewardedAd.js)
632
641
 
633
642
 
634
643
 
@@ -0,0 +1,95 @@
1
+ const fs = require('fs');
2
+ const path = require('path');
3
+ const plist = require('plist');
4
+
5
+ const configPath = path.join(process.cwd(), 'capacitor.config.json');
6
+ const androidPlatformPath = path.join(process.cwd(), 'android');
7
+ const iosPlatformPath = path.join(process.cwd(), 'ios');
8
+ const pluginPath = path.join(process.cwd(), 'node_modules', 'emi-indo-cordova-plugin-admob', 'plugin.xml');
9
+ const infoPlistPath = path.join(process.cwd(), 'ios', 'App', 'App', 'Info.plist');
10
+
11
+
12
+ function fileExists(filePath) {
13
+ return fs.existsSync(filePath);
14
+ }
15
+
16
+
17
+ function getAdMobConfig() {
18
+ if (!fileExists(configPath)) {
19
+ throw new Error('capacitor.config.json not found. Ensure this is a Capacitor project.');
20
+ }
21
+
22
+ const config = JSON.parse(fs.readFileSync(configPath, 'utf8'));
23
+ const admobConfig = config.plugins?.AdMob;
24
+
25
+ if (!admobConfig || !admobConfig.APP_ID_ANDROID || !admobConfig.APP_ID_IOS) {
26
+ throw new Error('AdMob configuration is missing in capacitor.config.json. Ensure APP_ID_ANDROID and APP_ID_IOS are defined.');
27
+ }
28
+
29
+ return {
30
+ APP_ID_ANDROID: admobConfig.APP_ID_ANDROID,
31
+ APP_ID_IOS: admobConfig.APP_ID_IOS,
32
+ };
33
+ }
34
+
35
+
36
+ function updatePluginXml(admobConfig) {
37
+ if (!fileExists(pluginPath)) {
38
+ console.error('plugin.xml not found. Ensure the plugin is installed.');
39
+ return;
40
+ }
41
+
42
+ let pluginContent = fs.readFileSync(pluginPath, 'utf8');
43
+
44
+ pluginContent = pluginContent
45
+ .replace(/<preference name="APP_ID_ANDROID" default=".*?" \/>/, `<preference name="APP_ID_ANDROID" default="${admobConfig.APP_ID_ANDROID}" />`)
46
+ .replace(/<preference name="APP_ID_IOS" default=".*?" \/>/, `<preference name="APP_ID_IOS" default="${admobConfig.APP_ID_IOS}" />`);
47
+
48
+ fs.writeFileSync(pluginPath, pluginContent, 'utf8');
49
+ console.log('AdMob IDs successfully updated in plugin.xml');
50
+ }
51
+
52
+
53
+ function updateInfoPlist(admobConfig) {
54
+ if (!fileExists(infoPlistPath)) {
55
+ console.error('Info.plist not found. Ensure you have built the iOS project.');
56
+ return;
57
+ }
58
+
59
+ const plistContent = fs.readFileSync(infoPlistPath, 'utf8');
60
+ const plistData = plist.parse(plistContent);
61
+
62
+
63
+ plistData.GADApplicationIdentifier = admobConfig.APP_ID_IOS;
64
+
65
+ const updatedPlistContent = plist.build(plistData);
66
+ fs.writeFileSync(infoPlistPath, updatedPlistContent, 'utf8');
67
+ console.log('AdMob IDs successfully updated in Info.plist');
68
+ }
69
+
70
+
71
+ try {
72
+
73
+ if (!fileExists(configPath)) {
74
+ throw new Error('capacitor.config.json not found. Skipping setup.');
75
+ }
76
+
77
+ if (!fileExists(androidPlatformPath) && !fileExists(iosPlatformPath)) {
78
+ throw new Error('Neither Android nor iOS platforms are found. Ensure platforms are added to your Capacitor project.');
79
+ }
80
+
81
+
82
+ const admobConfig = getAdMobConfig();
83
+
84
+
85
+ if (fileExists(androidPlatformPath)) {
86
+ updatePluginXml(admobConfig);
87
+ }
88
+
89
+
90
+ if (fileExists(iosPlatformPath)) {
91
+ updateInfoPlist(admobConfig);
92
+ }
93
+ } catch (error) {
94
+ console.error(error.message);
95
+ }
@@ -0,0 +1,12 @@
1
+ {
2
+ "appId": "io.cordova.hellocordova",
3
+ "appName": "HelloCordova",
4
+ "webDir": "www",
5
+ "bundledWebRuntime": false,
6
+ "plugins": {
7
+ "AdMob": {
8
+ "APP_ID_ANDROID": "ca-app-pub-3940256099942544~3347511713",
9
+ "APP_ID_IOS": "ca-app-pub-3940256099942544~1458002511"
10
+ }
11
+ }
12
+ }
@@ -0,0 +1,11 @@
1
+ <?xml version='1.0' encoding='utf-8'?>
2
+ <widget id="io.cordova.hellocordova" version="1.0.0" xmlns="http://www.w3.org/ns/widgets" xmlns:cdv="http://cordova.apache.org/ns/1.0">
3
+ <name>HelloCordova</name>
4
+ <description>Sample Apache Cordova App</description>
5
+ <author email="dev@cordova.apache.org" href="https://cordova.apache.org">
6
+ Apache Cordova Team
7
+ </author>
8
+ <content src="index.html" />
9
+ <allow-intent href="http://*/*" />
10
+ <allow-intent href="https://*/*" />
11
+ </widget>
@@ -0,0 +1,30 @@
1
+ {
2
+ "name": "io.cordova.hellocordova",
3
+ "displayName": "HelloCordova",
4
+ "version": "1.0.0",
5
+ "description": "A sample Apache Cordova application that responds to the deviceready event.",
6
+ "main": "index.js",
7
+ "scripts": {
8
+ "test": "echo \"Error: no test specified\" && exit 1",
9
+ "update-admob": "node node_modules/emi-indo-cordova-plugin-admob/capacitor-hook-admob-ids.js"
10
+ },
11
+ "keywords": [
12
+ "ecosystem:cordova"
13
+ ],
14
+ "author": "Apache Cordova Team",
15
+ "license": "Apache-2.0",
16
+ "devDependencies": {
17
+ "emi-indo-cordova-plugin-admob": "^1.6.1"
18
+ },
19
+ "cordova": {
20
+ "plugins": {
21
+ "emi-indo-cordova-plugin-admob": {}
22
+ }
23
+ },
24
+ "dependencies": {
25
+ "@capacitor/android": "^6.2.0",
26
+ "@capacitor/ios": "^6.2.0",
27
+ "@capacitor/cli": "^6.2.0",
28
+ "@capacitor/core": "^6.2.0"
29
+ }
30
+ }
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "emi-indo-cordova-plugin-admob",
3
- "version": "1.6.0",
4
- "description": "Cordova Plugin Admob Android IOS",
3
+ "version": "1.6.1",
4
+ "description": "Cordova Plugin Admob Android IOS Support Capacitor",
5
5
  "cordova": {
6
6
  "id": "emi-indo-cordova-plugin-admob",
7
7
  "platforms": [
@@ -20,7 +20,11 @@
20
20
  "admob-plus-cordova",
21
21
  "cordova-admob-pro",
22
22
  "cordova-admob-ios",
23
- "cordova-admob-android"
23
+ "cordova-admob-android",
24
+ "capacitor",
25
+ "capacitor-admob",
26
+ "capacitor-android",
27
+ "capacitor-ios"
24
28
  ],
25
29
  "author": "EMI INDO",
26
30
  "email": "cordova.c3addon@gmail.com",
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.0">
3
+ id="emi-indo-cordova-plugin-admob" version="1.6.1">
4
4
 
5
5
  <name>emiAdmobPlugin</name>
6
6
  <description>Cordova Plugin Admob Android IOS</description>
@@ -1,3 +0,0 @@
1
- {
2
- "xml.downloadExternalResources.enabled": true
3
- }