cordova-plugin-admob-nextgen 1.0.1 → 1.0.2

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,6 +1,7 @@
1
1
  # Cordova AdMob Next-Gen Plugin
2
2
 
3
3
  [![Android](https://img.shields.io/badge/Platform-Android-green?logo=android)](https://www.android.com)
4
+ [![iOS](https://img.shields.io/badge/Platform-iOS-lightgrey?logo=apple)](https://www.apple.com/ios)
4
5
  [![AdMob Next Gen](https://img.shields.io/badge/SDK-Google%20Mobile%20Ads%20Next--Gen-blue)](https://ads-developers.googleblog.com/2026/01/announcing-google-mobile-ads-next-gen.html)
5
6
  [![License](https://img.shields.io/badge/License-MIT-yellow)](LICENSE)
6
7
 
@@ -69,15 +70,16 @@ We prioritize the safety of your AdMob account and the stability of your app.
69
70
  ### Option A: Via CLI
70
71
  Install the plugin directly using the Cordova CLI. You must provide your AdMob App ID.
71
72
 
72
- cordova plugin add cordova-plugin-admob-nextgen --save --variable APP_ID_ANDROID="ca-app-pub-xxxxxxxxxxxxxxxx~yyyyyyyyyy"
73
+ cordova plugin add cordova-plugin-admob-nextgen --save --variable APP_ID_ANDROID="ca-app-pub-xxxxxxxxxxxxxxxx~yyyyyyyyyy" --variable APP_ID_IOS="ca-app-pub-xxxxxxxxxxxxxxxx~yyyyyyyyyy"
73
74
 
74
75
  ### Option B: Via config.xml
75
76
  Add this to your `config.xml` to restore the plugin automatically.
76
77
 
77
78
  <plugin name="cordova-plugin-admob-nextgen" spec="latest">
78
79
  <variable name="APP_ID_ANDROID" value="ca-app-pub-xxxxxxxxxxxxxxxx~yyyyyyyyyy" />
80
+ <variable name="APP_ID_IOS" value="ca-app-pub-xxxxxxxxxxxxxxxx~yyyyyyyyyy" />
79
81
 
80
- <variable name="NEXT_GEN_SDK_VERSION" value="0.23.0-beta01" />
82
+ <variable name="NEXT_GEN_SDK_VERSION" value="0.25.0-beta01" />
81
83
  <variable name="UMP_VERSION" value="4.0.0" />
82
84
  </plugin>
83
85
 
@@ -153,7 +155,30 @@ Add this to your `config.xml` to restore the plugin automatically.
153
155
  });
154
156
 
155
157
 
156
-
158
+ ### App Tracking Transparency (ATT / IDFA) - iOS Only
159
+ For iOS 14+, Apple requires you to prompt the user before tracking their IDFA.
160
+ The plugin provides manual control over this prompt so you can display it at the right time in your app's lifecycle.
161
+
162
+ ```
163
+ function checkAppTracking() {
164
+ admobNextGen.requestTrackingAuthorization(
165
+ function(status) {
166
+ console.log("ATT Status: " + status);
167
+ // Returns: 'AUTHORIZED', 'DENIED', 'NOT_DETERMINED', 'RESTRICTED'
168
+
169
+ // Regardless of the ATT choice, initialize the SDK
170
+ startSdk();
171
+ },
172
+ function(err) {
173
+ console.warn("ATT Request Failed", err);
174
+ startSdk();
175
+ }
176
+ );
177
+ }
178
+
179
+ // You can also silently check the status anytime:
180
+ // admobNextGen.getTrackingAuthorizationStatus(success, error);
181
+ ```
157
182
 
158
183
  ### Step 3: Check Consent Status (Smart Analysis)
159
184
  You can check if the user has granted permission for Personalized Ads without parsing complex IAB strings manually.
@@ -8,9 +8,12 @@ const configPath = fs.existsSync(path.join(rootPath, 'capacitor.config.ts'))
8
8
 
9
9
  const manifestPath = path.join(rootPath, 'android/app/src/main/AndroidManifest.xml');
10
10
  const gradlePath = path.join(rootPath, 'android/app/build.gradle');
11
+ const iosPlistPath = path.join(rootPath, 'ios/App/App/Info.plist');
11
12
 
12
13
  /**
13
- * Updates AndroidManifest.xml with the AdMob App ID
14
+ * ---------------------------------------------------------
15
+ * ANDROID HOOKS
16
+ * ---------------------------------------------------------
14
17
  */
15
18
  function updateAndroidManifest(appId) {
16
19
  if (!fs.existsSync(manifestPath)) return;
@@ -24,12 +27,9 @@ function updateAndroidManifest(appId) {
24
27
  content = content.replace('</application>', ` ${newTag}\n </application>`);
25
28
  }
26
29
  fs.writeFileSync(manifestPath, content, 'utf8');
27
- console.log(`[AdMob Hook] Success: Updated App ID to ${appId}`);
30
+ console.log(`[AdMob Hook] Success: Updated Android App ID to ${appId}`);
28
31
  }
29
32
 
30
- /**
31
- * Updates build.gradle with specific SDK and UMP versions
32
- */
33
33
  function updateGradleDependencies(nextGenVersion, umpVersion) {
34
34
  if (!fs.existsSync(gradlePath)) return;
35
35
  let content = fs.readFileSync(gradlePath, 'utf8');
@@ -44,34 +44,104 @@ function updateGradleDependencies(nextGenVersion, umpVersion) {
44
44
  if (umpRegex.test(content)) content = content.replace(umpRegex, newUmp);
45
45
 
46
46
  fs.writeFileSync(gradlePath, content, 'utf8');
47
- console.log(`[AdMob Hook] Success: Updated Next Gen SDK to ${nextGenVersion} and UMP to ${umpVersion}`);
47
+ console.log(`[AdMob Hook] Success: Updated Android Next Gen SDK to ${nextGenVersion} and UMP to ${umpVersion}`);
48
48
  }
49
49
 
50
50
  function injectExclusionRules() {
51
51
  if (!fs.existsSync(gradlePath)) return;
52
52
  let content = fs.readFileSync(gradlePath, 'utf8');
53
53
 
54
- if (content.includes('exclude group: "com.google.android.gms", module: "play-services-ads"')) {
55
- return;
56
- }
54
+ if (content.includes('exclude group: "com.google.android.gms", module: "play-services-ads"')) return;
57
55
 
58
56
  const exclusionBlock = `
59
57
  // [AdMob Next Gen] Exclude Legacy SDK to prevent duplicates
60
58
  configurations.configureEach {
61
- exclude group: "com.google.android.gms", module: "play-services-ads"
62
- exclude group: "com.google.android.gms", module: "play-services-ads-lite"
59
+ exclude group: "com.google.android.gms", module: "play-services-ads"
60
+ exclude group: "com.google.android.gms", module: "play-services-ads-lite"
63
61
  }
64
62
  `;
65
-
66
63
  content += exclusionBlock;
67
-
68
64
  fs.writeFileSync(gradlePath, content, 'utf8');
69
65
  console.log('[AdMob Hook] Success: Injected legacy SDK exclusion rules into build.gradle');
70
66
  }
71
67
 
68
+ /**
69
+ * ---------------------------------------------------------
70
+ * IOS HOOKS (THE NEW SMART ENGINE)
71
+ * ---------------------------------------------------------
72
+ */
73
+ function updateIosInfoPlist(appIdIos) {
74
+ if (!fs.existsSync(iosPlistPath)) {
75
+ console.warn('[AdMob Hook] Warning: ios/App/App/Info.plist not found. Run "npx cap add ios" first.');
76
+ return;
77
+ }
78
+
79
+ let content = fs.readFileSync(iosPlistPath, 'utf8');
80
+
81
+ function setStringKey(key, value) {
82
+ const regex = new RegExp(`<key>${key}</key>\\s*<string>.*?</string>`, 's');
83
+ const replacement = `<key>${key}</key>\n\t<string>${value}</string>`;
84
+ if (regex.test(content)) {
85
+ content = content.replace(regex, replacement);
86
+ } else {
87
+ content = content.replace('</dict>\n</plist>', `\t${replacement}\n</dict>\n</plist>`);
88
+ }
89
+ }
90
+
91
+ function setBoolKey(key, value) {
92
+ const boolStr = value ? '<true/>' : '<false/>';
93
+ const regex = new RegExp(`<key>${key}</key>\\s*<(true|false)\\/>`, 's');
94
+ const replacement = `<key>${key}</key>\n\t${boolStr}`;
95
+ if (regex.test(content)) {
96
+ content = content.replace(regex, replacement);
97
+ } else {
98
+ content = content.replace('</dict>\n</plist>', `\t${replacement}\n</dict>\n</plist>`);
99
+ }
100
+ }
101
+
102
+ setStringKey('GADApplicationIdentifier', appIdIos);
103
+
104
+ setStringKey('NSUserTrackingUsageDescription', 'This identifier will be used to deliver personalized ads to you.');
105
+
106
+ setBoolKey('GADDelayAppMeasurementInit', true);
107
+
108
+ if (!content.includes('<key>SKAdNetworkItems</key>')) {
109
+ const skAdNetworks = [
110
+ 'cstr6suwn9.skadnetwork', '4fzdc2evr5.skadnetwork', '2fnua5tdw4.skadnetwork', 'ydx93a7ass.skadnetwork',
111
+ 'p78axxw29g.skadnetwork', 'v72qych5uu.skadnetwork', 'ludvb6z3bs.skadnetwork', 'cp8zw746q7.skadnetwork',
112
+ '3sh42y64q3.skadnetwork', 'c6k4g5qg8m.skadnetwork', 's39g8k73mm.skadnetwork', 'wg4vff78zm.skadnetwork',
113
+ '3qy4746246.skadnetwork', 'f38h382jlk.skadnetwork', 'hs6bdukanm.skadnetwork', 'mlmmfzh3r3.skadnetwork',
114
+ 'v4nxqhlyqp.skadnetwork', 'wzmmz9fp6w.skadnetwork', 'su67r6k2v3.skadnetwork', 'yclnxrl5pm.skadnetwork',
115
+ 't38b2kh725.skadnetwork', '7ug5zh24hu.skadnetwork', 'gta9lk7p23.skadnetwork', 'vutu7akeur.skadnetwork',
116
+ 'y5ghdn5j9k.skadnetwork', 'v9wttpbfk9.skadnetwork', 'n38lu8286q.skadnetwork', '47vhws6wlr.skadnetwork',
117
+ 'kbd757ywx3.skadnetwork', '9t245vhmpl.skadnetwork', 'a2p9lx4jpn.skadnetwork', '22mmun2rn5.skadnetwork',
118
+ '44jx6755aq.skadnetwork', 'k674qkevps.skadnetwork', '4468km3ulz.skadnetwork', '2u9pt9hc89.skadnetwork',
119
+ '8s468mfl3y.skadnetwork', 'klf5c3l5u5.skadnetwork', 'ppxm28t8ap.skadnetwork', 'uw77j35x4d.skadnetwork',
120
+ '578prtvx9j.skadnetwork', '4dzt52r2t5.skadnetwork', 'tl55sbb4fm.skadnetwork', 'e5fvkxwrpn.skadnetwork',
121
+ '8c4e2ghe7u.skadnetwork', '3rd42ekr43.skadnetwork', '3qcr597p9d.skadnetwork'
122
+ ];
123
+
124
+ let dicts = skAdNetworks.map(id => `\t\t<dict>\n\t\t\t<key>SKAdNetworkIdentifier</key>\n\t\t\t<string>${id}</string>\n\t\t</dict>`).join('\n');
125
+ let arrayBlock = `\t<key>SKAdNetworkItems</key>\n\t<array>\n${dicts}\n\t</array>`;
126
+
127
+ content = content.replace('</dict>\n</plist>', `${arrayBlock}\n</dict>\n</plist>`);
128
+ }
129
+
130
+ fs.writeFileSync(iosPlistPath, content, 'utf8');
131
+ console.log(`[AdMob Hook] Success: Updated iOS Info.plist with App ID (${appIdIos}), ATT prompt, and SKAdNetworks.`);
132
+ }
133
+
134
+ /**
135
+ * ---------------------------------------------------------
136
+ * MAIN RUNNER
137
+ * ---------------------------------------------------------
138
+ */
72
139
  function run() {
73
140
  try {
74
- if (!fs.existsSync(configPath)) return;
141
+ if (!fs.existsSync(configPath)) {
142
+ console.warn('[AdMob Hook] capacitor.config not found. Skipping auto-injection.');
143
+ return;
144
+ }
75
145
 
76
146
  const configContent = fs.readFileSync(configPath, 'utf8');
77
147
  let admob;
@@ -79,28 +149,33 @@ function run() {
79
149
  if (configPath.endsWith('.json')) {
80
150
  admob = JSON.parse(configContent).plugins?.AdMob;
81
151
  } else {
82
- // Extracting values from .ts file using regex
83
- const appId = configContent.match(/APP_ID_ANDROID:\s*['"](.*?)['"]/);
152
+ // Extract from .ts
153
+ const appIdAndroid = configContent.match(/APP_ID_ANDROID:\s*['"](.*?)['"]/);
154
+ const appIdIos = configContent.match(/APP_ID_IOS:\s*['"](.*?)['"]/);
84
155
  const sdk = configContent.match(/NEXT_GEN_SDK_VERSION:\s*['"](.*?)['"]/);
85
156
  const ump = configContent.match(/UMP_VERSION:\s*['"](.*?)['"]/);
157
+
86
158
  admob = {
87
- APP_ID_ANDROID: appId ? appId[1] : null,
88
- NEXT_GEN_SDK_VERSION: sdk ? sdk[1] : "0.23.0-beta01",
159
+ APP_ID_ANDROID: appIdAndroid ? appIdAndroid[1] : "ca-app-pub-3940256099942544~3347511713",
160
+ APP_ID_IOS: appIdIos ? appIdIos[1] : "ca-app-pub-3940256099942544~1458002511",
161
+ NEXT_GEN_SDK_VERSION: sdk ? sdk[1] : "0.25.0-beta01",
89
162
  UMP_VERSION: ump ? ump[1] : "4.0.0"
90
163
  };
91
164
  }
92
165
 
93
166
  if (admob?.APP_ID_ANDROID) updateAndroidManifest(admob.APP_ID_ANDROID);
94
-
95
167
  injectExclusionRules();
96
-
97
168
  if (admob?.NEXT_GEN_SDK_VERSION || admob?.UMP_VERSION) {
98
169
  updateGradleDependencies(
99
- admob.NEXT_GEN_SDK_VERSION || "0.23.0-beta01",
170
+ admob.NEXT_GEN_SDK_VERSION || "0.25.0-beta01",
100
171
  admob.UMP_VERSION || "4.0.0"
101
172
  );
102
173
  }
103
174
 
175
+ if (admob?.APP_ID_IOS) {
176
+ updateIosInfoPlist(admob.APP_ID_IOS);
177
+ }
178
+
104
179
  } catch (err) {
105
180
  console.error('[AdMob Hook] Error:', err.message);
106
181
  }
package/package.json CHANGED
@@ -1,11 +1,12 @@
1
1
  {
2
2
  "name": "cordova-plugin-admob-nextgen",
3
- "version": "1.0.1",
3
+ "version": "1.0.2",
4
4
  "description": "Google Mobile Ads Next Gen SDK for Cordova. High performance and modular architecture. ",
5
5
  "cordova": {
6
6
  "id": "cordova-plugin-admob-nextgen",
7
7
  "platforms": [
8
- "android"
8
+ "android",
9
+ "ios"
9
10
  ]
10
11
  },
11
12
  "repository": {
package/plugin.xml CHANGED
@@ -1,11 +1,11 @@
1
1
  <?xml version='1.0' encoding='utf-8'?>
2
2
  <plugin id="cordova-plugin-admob-nextgen"
3
- version="1.0.1"
3
+ version="1.0.2"
4
4
  xmlns="http://apache.org/cordova/ns/plugins/1.0"
5
5
  xmlns:android="http://schemas.android.com/apk/res/android">
6
6
 
7
7
  <name>AdMob Next Gen</name>
8
- <description>Google Mobile Ads Next Gen SDK for Cordova</description>
8
+ <description>Google Mobile Ads Next Gen SDK for Cordova including capacitors</description>
9
9
  <author>EMI INDO</author>
10
10
  <license>MIT</license>
11
11
 
@@ -47,8 +47,110 @@
47
47
 
48
48
  </platform>
49
49
 
50
- <preference name="NEXT_GEN_SDK_VERSION" default="0.23.0-beta01" />
50
+ <preference name="NEXT_GEN_SDK_VERSION" default="0.25.0-beta01" />
51
51
  <preference name="UMP_VERSION" default="4.0.0" />
52
52
  <preference name="APP_ID_ANDROID" default="ca-app-pub-3940256099942544~3347511713" />
53
53
 
54
+ <platform name="ios">
55
+ <config-file target="config.xml" parent="/*">
56
+ <feature name="AdMobNextGen">
57
+ <param name="ios-package" value="AdMobNextGen" />
58
+ <param name="onload" value="true" />
59
+ </feature>
60
+ </config-file>
61
+
62
+ <config-file target="*-Info.plist" parent="GADApplicationIdentifier">
63
+ <string>$APP_ID_IOS</string>
64
+ </config-file>
65
+
66
+ <config-file target="*-Info.plist" parent="NSUserTrackingUsageDescription">
67
+ <string>This identifier will be used to deliver personalized ads to you.</string>
68
+ </config-file>
69
+
70
+ <config-file target="*-Info.plist" parent="SKAdNetworkItems">
71
+ <array>
72
+ <dict><key>SKAdNetworkIdentifier</key><string>cstr6suwn9.skadnetwork</string></dict>
73
+ <dict><key>SKAdNetworkIdentifier</key><string>4fzdc2evr5.skadnetwork</string></dict>
74
+ <dict><key>SKAdNetworkIdentifier</key><string>2fnua5tdw4.skadnetwork</string></dict>
75
+ <dict><key>SKAdNetworkIdentifier</key><string>ydx93a7ass.skadnetwork</string></dict>
76
+ <dict><key>SKAdNetworkIdentifier</key><string>p78axxw29g.skadnetwork</string></dict>
77
+ <dict><key>SKAdNetworkIdentifier</key><string>v72qych5uu.skadnetwork</string></dict>
78
+ <dict><key>SKAdNetworkIdentifier</key><string>ludvb6z3bs.skadnetwork</string></dict>
79
+ <dict><key>SKAdNetworkIdentifier</key><string>cp8zw746q7.skadnetwork</string></dict>
80
+ <dict><key>SKAdNetworkIdentifier</key><string>3sh42y64q3.skadnetwork</string></dict>
81
+ <dict><key>SKAdNetworkIdentifier</key><string>c6k4g5qg8m.skadnetwork</string></dict>
82
+ <dict><key>SKAdNetworkIdentifier</key><string>s39g8k73mm.skadnetwork</string></dict>
83
+ <dict><key>SKAdNetworkIdentifier</key><string>wg4vff78zm.skadnetwork</string></dict>
84
+ <dict><key>SKAdNetworkIdentifier</key><string>3qy4746246.skadnetwork</string></dict>
85
+ <dict><key>SKAdNetworkIdentifier</key><string>f38h382jlk.skadnetwork</string></dict>
86
+ <dict><key>SKAdNetworkIdentifier</key><string>hs6bdukanm.skadnetwork</string></dict>
87
+ <dict><key>SKAdNetworkIdentifier</key><string>mlmmfzh3r3.skadnetwork</string></dict>
88
+ <dict><key>SKAdNetworkIdentifier</key><string>v4nxqhlyqp.skadnetwork</string></dict>
89
+ <dict><key>SKAdNetworkIdentifier</key><string>wzmmz9fp6w.skadnetwork</string></dict>
90
+ <dict><key>SKAdNetworkIdentifier</key><string>su67r6k2v3.skadnetwork</string></dict>
91
+ <dict><key>SKAdNetworkIdentifier</key><string>yclnxrl5pm.skadnetwork</string></dict>
92
+ <dict><key>SKAdNetworkIdentifier</key><string>t38b2kh725.skadnetwork</string></dict>
93
+ <dict><key>SKAdNetworkIdentifier</key><string>7ug5zh24hu.skadnetwork</string></dict>
94
+ <dict><key>SKAdNetworkIdentifier</key><string>gta9lk7p23.skadnetwork</string></dict>
95
+ <dict><key>SKAdNetworkIdentifier</key><string>vutu7akeur.skadnetwork</string></dict>
96
+ <dict><key>SKAdNetworkIdentifier</key><string>y5ghdn5j9k.skadnetwork</string></dict>
97
+ <dict><key>SKAdNetworkIdentifier</key><string>v9wttpbfk9.skadnetwork</string></dict>
98
+ <dict><key>SKAdNetworkIdentifier</key><string>n38lu8286q.skadnetwork</string></dict>
99
+ <dict><key>SKAdNetworkIdentifier</key><string>47vhws6wlr.skadnetwork</string></dict>
100
+ <dict><key>SKAdNetworkIdentifier</key><string>kbd757ywx3.skadnetwork</string></dict>
101
+ <dict><key>SKAdNetworkIdentifier</key><string>9t245vhmpl.skadnetwork</string></dict>
102
+ <dict><key>SKAdNetworkIdentifier</key><string>a2p9lx4jpn.skadnetwork</string></dict>
103
+ <dict><key>SKAdNetworkIdentifier</key><string>22mmun2rn5.skadnetwork</string></dict>
104
+ <dict><key>SKAdNetworkIdentifier</key><string>44jx6755aq.skadnetwork</string></dict>
105
+ <dict><key>SKAdNetworkIdentifier</key><string>k674qkevps.skadnetwork</string></dict>
106
+ <dict><key>SKAdNetworkIdentifier</key><string>4468km3ulz.skadnetwork</string></dict>
107
+ <dict><key>SKAdNetworkIdentifier</key><string>2u9pt9hc89.skadnetwork</string></dict>
108
+ <dict><key>SKAdNetworkIdentifier</key><string>8s468mfl3y.skadnetwork</string></dict>
109
+ <dict><key>SKAdNetworkIdentifier</key><string>klf5c3l5u5.skadnetwork</string></dict>
110
+ <dict><key>SKAdNetworkIdentifier</key><string>ppxm28t8ap.skadnetwork</string></dict>
111
+ <dict><key>SKAdNetworkIdentifier</key><string>kbmxgpxpgc.skadnetwork</string></dict>
112
+ <dict><key>SKAdNetworkIdentifier</key><string>uw77j35x4d.skadnetwork</string></dict>
113
+ <dict><key>SKAdNetworkIdentifier</key><string>578prtvx9j.skadnetwork</string></dict>
114
+ <dict><key>SKAdNetworkIdentifier</key><string>4dzt52r2t5.skadnetwork</string></dict>
115
+ <dict><key>SKAdNetworkIdentifier</key><string>tl55sbb4fm.skadnetwork</string></dict>
116
+ <dict><key>SKAdNetworkIdentifier</key><string>c3frkrj4fj.skadnetwork</string></dict>
117
+ <dict><key>SKAdNetworkIdentifier</key><string>e5fvkxwrpn.skadnetwork</string></dict>
118
+ <dict><key>SKAdNetworkIdentifier</key><string>8c4e2ghe7u.skadnetwork</string></dict>
119
+ <dict><key>SKAdNetworkIdentifier</key><string>3rd42ekr43.skadnetwork</string></dict>
120
+ <dict><key>SKAdNetworkIdentifier</key><string>97r2b46745.skadnetwork</string></dict>
121
+ <dict><key>SKAdNetworkIdentifier</key><string>3qcr597p9d.skadnetwork</string></dict>
122
+ </array>
123
+ </config-file>
124
+
125
+ <framework src="AdSupport.framework" weak="true" />
126
+ <framework src="AppTrackingTransparency.framework" weak="true" />
127
+
128
+ <podspec>
129
+ <config>
130
+ <source url="https://cdn.cocoapods.org/"/>
131
+ </config>
132
+ <pods use-frameworks="true">
133
+ <pod name="GoogleUserMessagingPlatform" spec="~> 3.1.0" />
134
+ <pod name="Google-Mobile-Ads-SDK" spec="~> 13.1.0" />
135
+ </pods>
136
+ </podspec>
137
+
138
+ <header-file src="src/ios/AdMobNextGen.h" />
139
+ <source-file src="src/ios/AdMobNextGen.m" />
140
+ <header-file src="src/ios/ConsentExecutor.h" />
141
+ <source-file src="src/ios/ConsentExecutor.m" />
142
+ <header-file src="src/ios/AppOpenAdExecutor.h" />
143
+ <source-file src="src/ios/AppOpenAdExecutor.m" />
144
+ <header-file src="src/ios/BannerExecutor.h" />
145
+ <source-file src="src/ios/BannerExecutor.m" />
146
+ <header-file src="src/ios/InterstitialExecutor.h" />
147
+ <source-file src="src/ios/InterstitialExecutor.m" />
148
+ <header-file src="src/ios/RewardedExecutor.h" />
149
+ <source-file src="src/ios/RewardedExecutor.m" />
150
+ <header-file src="src/ios/RewardedInterstitialExecutor.h" />
151
+ <source-file src="src/ios/RewardedInterstitialExecutor.m" />
152
+ </platform>
153
+
154
+ <preference name="APP_ID_IOS" default="ca-app-pub-3940256099942544~1458002511" />
155
+
54
156
  </plugin>
@@ -0,0 +1,34 @@
1
+ #import <Cordova/CDV.h>
2
+ #import <GoogleMobileAds/GoogleMobileAds.h>
3
+
4
+ @interface AdMobNextGen : CDVPlugin
5
+
6
+ - (void)initialize:(CDVInvokedUrlCommand*)command;
7
+
8
+ - (void)requestConsentInfo:(CDVInvokedUrlCommand*)command;
9
+ - (void)showPrivacyOptionsForm:(CDVInvokedUrlCommand*)command;
10
+ - (void)getTCData:(CDVInvokedUrlCommand*)command;
11
+ - (void)canRequestAds:(CDVInvokedUrlCommand*)command;
12
+ - (void)requestTrackingAuthorization:(CDVInvokedUrlCommand*)command;
13
+ - (void)getTrackingAuthorizationStatus:(CDVInvokedUrlCommand*)command;
14
+
15
+ - (void)createBanner:(CDVInvokedUrlCommand*)command;
16
+ - (void)showBanner:(CDVInvokedUrlCommand*)command;
17
+ - (void)hideBanner:(CDVInvokedUrlCommand*)command;
18
+ - (void)removeBanner:(CDVInvokedUrlCommand*)command;
19
+
20
+ - (void)createInterstitial:(CDVInvokedUrlCommand*)command;
21
+ - (void)showInterstitial:(CDVInvokedUrlCommand*)command;
22
+
23
+ - (void)createRewarded:(CDVInvokedUrlCommand*)command;
24
+ - (void)showRewarded:(CDVInvokedUrlCommand*)command;
25
+
26
+ - (void)loadAppOpenAd:(CDVInvokedUrlCommand*)command;
27
+ - (void)showAppOpenAd:(CDVInvokedUrlCommand*)command;
28
+
29
+ - (void)createRewardedInterstitial:(CDVInvokedUrlCommand*)command;
30
+ - (void)showRewardedInterstitial:(CDVInvokedUrlCommand*)command;
31
+
32
+ - (void)fireEvent:(NSString *)obj event:(NSString *)eventName withData:(NSString *)jsonStr;
33
+
34
+ @end
@@ -0,0 +1,160 @@
1
+ #import "AdMobNextGen.h"
2
+ #import "ConsentExecutor.h"
3
+ #import "BannerExecutor.h"
4
+ #import "InterstitialExecutor.h"
5
+ #import "RewardedExecutor.h"
6
+ #import "AppOpenAdExecutor.h"
7
+ #import "RewardedInterstitialExecutor.h"
8
+
9
+ @interface AdMobNextGen()
10
+ @property (nonatomic, strong) ConsentExecutor *consentExecutor;
11
+ @property (nonatomic, strong) BannerExecutor *bannerExecutor;
12
+ @property (nonatomic, strong) InterstitialExecutor *interstitialExecutor;
13
+ @property (nonatomic, strong) RewardedExecutor *rewardedExecutor;
14
+ @property (nonatomic, strong) RewardedInterstitialExecutor *rewardedInterstitialExecutor;
15
+ @end
16
+
17
+ @implementation AdMobNextGen
18
+
19
+ - (void)pluginInitialize {
20
+ [super pluginInitialize];
21
+ self.consentExecutor = [[ConsentExecutor alloc] initWithPlugin:self];
22
+ self.bannerExecutor = [[BannerExecutor alloc] initWithPlugin:self];
23
+ self.interstitialExecutor = [[InterstitialExecutor alloc] initWithPlugin:self];
24
+ self.rewardedExecutor = [[RewardedExecutor alloc] initWithPlugin:self];
25
+ [[AppOpenAdExecutor sharedInstance] initializeWithPlugin:self];
26
+ self.rewardedInterstitialExecutor = [[RewardedInterstitialExecutor alloc] initWithPlugin:self];
27
+ }
28
+
29
+ - (void)initialize:(CDVInvokedUrlCommand*)command {
30
+ [self.commandDelegate runInBackground:^{
31
+ [[GADMobileAds sharedInstance] startWithCompletionHandler:^(GADInitializationStatus * _Nonnull status) {
32
+ CDVPluginResult* pluginResult = [CDVPluginResult resultWithStatus:CDVCommandStatus_OK messageAsString:@"Initialization complete."];
33
+ [self.commandDelegate sendPluginResult:pluginResult callbackId:command.callbackId];
34
+ }];
35
+ }];
36
+ }
37
+
38
+ #pragma mark - Consent (UMP) Routing
39
+
40
+ - (void)requestConsentInfo:(CDVInvokedUrlCommand*)command {
41
+ NSDictionary *options = nil;
42
+ if (command.arguments.count > 0) {
43
+ options = [command.arguments objectAtIndex:0];
44
+ }
45
+ [self.consentExecutor requestConsentInfo:options command:command];
46
+ }
47
+
48
+ - (void)showPrivacyOptionsForm:(CDVInvokedUrlCommand*)command {
49
+ [self.consentExecutor showPrivacyOptionsForm:command];
50
+ }
51
+
52
+ - (void)getTCData:(CDVInvokedUrlCommand*)command {
53
+ [self.consentExecutor getTCData:command];
54
+ }
55
+
56
+ - (void)requestTrackingAuthorization:(CDVInvokedUrlCommand *)command {
57
+ [self.consentExecutor requestTrackingAuthorization:command];
58
+ }
59
+
60
+ - (void)getTrackingAuthorizationStatus:(CDVInvokedUrlCommand *)command {
61
+ [self.consentExecutor getTrackingAuthorizationStatus:command];
62
+ }
63
+
64
+ #pragma mark - AppOpenAd Routing
65
+
66
+ - (void)loadAppOpenAd:(CDVInvokedUrlCommand*)command {
67
+ NSDictionary *options = [command.arguments objectAtIndex:0];
68
+ if (options != nil) {
69
+ [[AppOpenAdExecutor sharedInstance] loadAppOpenAd:options command:command];
70
+ }
71
+ }
72
+
73
+ - (void)showAppOpenAd:(CDVInvokedUrlCommand*)command {
74
+ [[AppOpenAdExecutor sharedInstance] showAppOpenAd:command];
75
+ }
76
+
77
+ #pragma mark - Banner Routing
78
+
79
+ - (void)createBanner:(CDVInvokedUrlCommand*)command {
80
+ NSDictionary *options = [command.arguments objectAtIndex:0];
81
+ if (options != nil && [options isKindOfClass:[NSDictionary class]]) {
82
+ [self.bannerExecutor createBanner:options command:command];
83
+ } else {
84
+ CDVPluginResult* pluginResult = [CDVPluginResult resultWithStatus:CDVCommandStatus_ERROR messageAsString:@"Invalid options object."];
85
+ [self.commandDelegate sendPluginResult:pluginResult callbackId:command.callbackId];
86
+ }
87
+ }
88
+
89
+ - (void)showBanner:(CDVInvokedUrlCommand*)command {
90
+ [self.bannerExecutor showBanner:command];
91
+ }
92
+
93
+ - (void)hideBanner:(CDVInvokedUrlCommand*)command {
94
+ [self.bannerExecutor hideBanner:command];
95
+ }
96
+
97
+ - (void)removeBanner:(CDVInvokedUrlCommand*)command {
98
+ [self.bannerExecutor removeBanner:command];
99
+ }
100
+
101
+ #pragma mark - Interstitial Routing
102
+
103
+ - (void)createInterstitial:(CDVInvokedUrlCommand*)command {
104
+ NSDictionary *options = [command.arguments objectAtIndex:0];
105
+ if (options != nil && [options isKindOfClass:[NSDictionary class]]) {
106
+ [self.interstitialExecutor createInterstitial:options command:command];
107
+ } else {
108
+ CDVPluginResult* pluginResult = [CDVPluginResult resultWithStatus:CDVCommandStatus_ERROR messageAsString:@"Invalid options object."];
109
+ [self.commandDelegate sendPluginResult:pluginResult callbackId:command.callbackId];
110
+ }
111
+ }
112
+
113
+ - (void)showInterstitial:(CDVInvokedUrlCommand*)command {
114
+ [self.interstitialExecutor showInterstitial:command];
115
+ }
116
+
117
+ #pragma mark - Rewarded Routing
118
+
119
+ - (void)createRewarded:(CDVInvokedUrlCommand*)command {
120
+ NSDictionary *options = [command.arguments objectAtIndex:0];
121
+ if (options != nil) {
122
+ [self.rewardedExecutor createRewarded:options command:command];
123
+ }
124
+ }
125
+
126
+ - (void)showRewarded:(CDVInvokedUrlCommand*)command {
127
+ [self.rewardedExecutor showRewarded:command];
128
+ }
129
+
130
+ #pragma mark - Rewarded Interstitial Routing
131
+
132
+ - (void)createRewardedInterstitial:(CDVInvokedUrlCommand*)command {
133
+ NSDictionary *options = [command.arguments objectAtIndex:0];
134
+ if (options != nil) {
135
+ [self.rewardedInterstitialExecutor createRewardedInterstitial:options command:command];
136
+ }
137
+ }
138
+
139
+ - (void)showRewardedInterstitial:(CDVInvokedUrlCommand*)command {
140
+ [self.rewardedInterstitialExecutor showRewardedInterstitial:command];
141
+ }
142
+
143
+ #pragma mark - Event Emitter
144
+
145
+ - (void)fireEvent:(NSString *)obj event:(NSString *)eventName withData:(NSString *)jsonStr {
146
+ NSString* js;
147
+ if(obj && [obj isEqualToString:@"window"]) {
148
+ js = [NSString stringWithFormat:@"var evt=document.createEvent(\"UIEvents\");evt.initUIEvent(\"%@\",true,false,window,0);window.dispatchEvent(evt);", eventName];
149
+ } else if(jsonStr && [jsonStr length] > 0) {
150
+ js = [NSString stringWithFormat:@"javascript:cordova.fireDocumentEvent('%@',%@);", eventName, jsonStr];
151
+ } else {
152
+ js = [NSString stringWithFormat:@"javascript:cordova.fireDocumentEvent('%@');", eventName];
153
+ }
154
+
155
+ dispatch_async(dispatch_get_main_queue(), ^{
156
+ [self.commandDelegate evalJs:js];
157
+ });
158
+ }
159
+
160
+ @end
@@ -0,0 +1,15 @@
1
+ #import <Foundation/Foundation.h>
2
+ #import <Cordova/CDV.h>
3
+ #import <GoogleMobileAds/GoogleMobileAds.h>
4
+
5
+ @class AdMobNextGen;
6
+
7
+ @interface AppOpenAdExecutor : NSObject <GADFullScreenContentDelegate>
8
+
9
+ + (instancetype)sharedInstance;
10
+
11
+ - (void)initializeWithPlugin:(AdMobNextGen *)plugin;
12
+ - (void)loadAppOpenAd:(NSDictionary *)options command:(CDVInvokedUrlCommand *)command;
13
+ - (void)showAppOpenAd:(CDVInvokedUrlCommand *)command;
14
+
15
+ @end