com.puzzlescapegames.admob_native 1.0.0

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.
Files changed (156) hide show
  1. package/.github/workflows/release-package.yml +22 -0
  2. package/GoogleMobileAds/CHANGELOG.md +1517 -0
  3. package/GoogleMobileAds/CHANGELOG.md.meta +81 -0
  4. package/GoogleMobileAds/Editor/AndroidBuildPreProcessor.cs +191 -0
  5. package/GoogleMobileAds/Editor/AndroidBuildPreProcessor.cs.meta +7 -0
  6. package/GoogleMobileAds/Editor/BuildPreProcessor.cs +55 -0
  7. package/GoogleMobileAds/Editor/BuildPreProcessor.cs.meta +17 -0
  8. package/GoogleMobileAds/Editor/EditorLocalization.cs +177 -0
  9. package/GoogleMobileAds/Editor/EditorLocalization.cs.meta +17 -0
  10. package/GoogleMobileAds/Editor/EditorLocalizationData.cs +11 -0
  11. package/GoogleMobileAds/Editor/EditorLocalizationData.cs.meta +17 -0
  12. package/GoogleMobileAds/Editor/EditorPathUtils.cs +57 -0
  13. package/GoogleMobileAds/Editor/EditorPathUtils.cs.meta +17 -0
  14. package/GoogleMobileAds/Editor/GoogleMobileAds.Editor.asmdef +20 -0
  15. package/GoogleMobileAds/Editor/GoogleMobileAds.Editor.asmdef.meta +12 -0
  16. package/GoogleMobileAds/Editor/GoogleMobileAdsDependencies.xml +27 -0
  17. package/GoogleMobileAds/Editor/GoogleMobileAdsDependencies.xml.meta +12 -0
  18. package/GoogleMobileAds/Editor/GoogleMobileAdsSKAdNetworkItems.xml +55 -0
  19. package/GoogleMobileAds/Editor/GoogleMobileAdsSKAdNetworkItems.xml.meta +12 -0
  20. package/GoogleMobileAds/Editor/GoogleMobileAdsSettings.cs +115 -0
  21. package/GoogleMobileAds/Editor/GoogleMobileAdsSettings.cs.meta +17 -0
  22. package/GoogleMobileAds/Editor/GoogleMobileAdsSettingsEditor.cs +164 -0
  23. package/GoogleMobileAds/Editor/GoogleMobileAdsSettingsEditor.cs.meta +17 -0
  24. package/GoogleMobileAds/Editor/GoogleUmpDependencies.xml +16 -0
  25. package/GoogleMobileAds/Editor/GoogleUmpDependencies.xml.meta +12 -0
  26. package/GoogleMobileAds/Editor/GradleProcessor.cs +99 -0
  27. package/GoogleMobileAds/Editor/GradleProcessor.cs.meta +17 -0
  28. package/GoogleMobileAds/Editor/ManifestProcessor.cs +249 -0
  29. package/GoogleMobileAds/Editor/ManifestProcessor.cs.meta +17 -0
  30. package/GoogleMobileAds/Editor/PListProcessor.cs +232 -0
  31. package/GoogleMobileAds/Editor/PListProcessor.cs.meta +17 -0
  32. package/GoogleMobileAds/Editor/Resources/PlaceholderAds/AdImages/1024x768.png +0 -0
  33. package/GoogleMobileAds/Editor/Resources/PlaceholderAds/AdImages/1024x768.png.meta +103 -0
  34. package/GoogleMobileAds/Editor/Resources/PlaceholderAds/AdImages/300x250.png +0 -0
  35. package/GoogleMobileAds/Editor/Resources/PlaceholderAds/AdImages/300x250.png.meta +103 -0
  36. package/GoogleMobileAds/Editor/Resources/PlaceholderAds/AdImages/320x100.png +0 -0
  37. package/GoogleMobileAds/Editor/Resources/PlaceholderAds/AdImages/320x100.png.meta +103 -0
  38. package/GoogleMobileAds/Editor/Resources/PlaceholderAds/AdImages/320x480.png +0 -0
  39. package/GoogleMobileAds/Editor/Resources/PlaceholderAds/AdImages/320x480.png.meta +103 -0
  40. package/GoogleMobileAds/Editor/Resources/PlaceholderAds/AdImages/320x50.png +0 -0
  41. package/GoogleMobileAds/Editor/Resources/PlaceholderAds/AdImages/320x50.png.meta +103 -0
  42. package/GoogleMobileAds/Editor/Resources/PlaceholderAds/AdImages/468x60.png +0 -0
  43. package/GoogleMobileAds/Editor/Resources/PlaceholderAds/AdImages/468x60.png.meta +103 -0
  44. package/GoogleMobileAds/Editor/Resources/PlaceholderAds/AdImages/480x320.png +0 -0
  45. package/GoogleMobileAds/Editor/Resources/PlaceholderAds/AdImages/480x320.png.meta +103 -0
  46. package/GoogleMobileAds/Editor/Resources/PlaceholderAds/AdImages/728x90.png +0 -0
  47. package/GoogleMobileAds/Editor/Resources/PlaceholderAds/AdImages/728x90.png.meta +103 -0
  48. package/GoogleMobileAds/Editor/Resources/PlaceholderAds/AdImages/768x1024.png +0 -0
  49. package/GoogleMobileAds/Editor/Resources/PlaceholderAds/AdImages/768x1024.png.meta +103 -0
  50. package/GoogleMobileAds/Editor/Resources/PlaceholderAds/AdImages/AdInspectorHome.png +0 -0
  51. package/GoogleMobileAds/Editor/Resources/PlaceholderAds/AdImages/AdInspectorHome.png.meta +131 -0
  52. package/GoogleMobileAds/Editor/Resources/PlaceholderAds/AdImages.meta +8 -0
  53. package/GoogleMobileAds/Editor/Resources/PlaceholderAds/AdInspector/768x1024.prefab +504 -0
  54. package/GoogleMobileAds/Editor/Resources/PlaceholderAds/AdInspector/768x1024.prefab.meta +12 -0
  55. package/GoogleMobileAds/Editor/Resources/PlaceholderAds/AdInspector.meta +8 -0
  56. package/GoogleMobileAds/Editor/Resources/PlaceholderAds/AppOpen/1024x768.prefab +472 -0
  57. package/GoogleMobileAds/Editor/Resources/PlaceholderAds/AppOpen/1024x768.prefab.meta +12 -0
  58. package/GoogleMobileAds/Editor/Resources/PlaceholderAds/AppOpen/768x1024.prefab +472 -0
  59. package/GoogleMobileAds/Editor/Resources/PlaceholderAds/AppOpen/768x1024.prefab.meta +12 -0
  60. package/GoogleMobileAds/Editor/Resources/PlaceholderAds/AppOpen.meta +8 -0
  61. package/GoogleMobileAds/Editor/Resources/PlaceholderAds/Banners/ADAPTIVE.prefab +292 -0
  62. package/GoogleMobileAds/Editor/Resources/PlaceholderAds/Banners/ADAPTIVE.prefab.meta +13 -0
  63. package/GoogleMobileAds/Editor/Resources/PlaceholderAds/Banners/BANNER.prefab +217 -0
  64. package/GoogleMobileAds/Editor/Resources/PlaceholderAds/Banners/BANNER.prefab.meta +13 -0
  65. package/GoogleMobileAds/Editor/Resources/PlaceholderAds/Banners/CENTER.prefab +292 -0
  66. package/GoogleMobileAds/Editor/Resources/PlaceholderAds/Banners/CENTER.prefab.meta +13 -0
  67. package/GoogleMobileAds/Editor/Resources/PlaceholderAds/Banners/FULL_BANNER.prefab +217 -0
  68. package/GoogleMobileAds/Editor/Resources/PlaceholderAds/Banners/FULL_BANNER.prefab.meta +13 -0
  69. package/GoogleMobileAds/Editor/Resources/PlaceholderAds/Banners/LARGE_BANNER.prefab +217 -0
  70. package/GoogleMobileAds/Editor/Resources/PlaceholderAds/Banners/LARGE_BANNER.prefab.meta +13 -0
  71. package/GoogleMobileAds/Editor/Resources/PlaceholderAds/Banners/LEADERBOARD.prefab +217 -0
  72. package/GoogleMobileAds/Editor/Resources/PlaceholderAds/Banners/LEADERBOARD.prefab.meta +13 -0
  73. package/GoogleMobileAds/Editor/Resources/PlaceholderAds/Banners/MEDIUM_RECTANGLE.prefab +217 -0
  74. package/GoogleMobileAds/Editor/Resources/PlaceholderAds/Banners/MEDIUM_RECTANGLE.prefab.meta +13 -0
  75. package/GoogleMobileAds/Editor/Resources/PlaceholderAds/Banners/SMART_BANNER.prefab +292 -0
  76. package/GoogleMobileAds/Editor/Resources/PlaceholderAds/Banners/SMART_BANNER.prefab.meta +13 -0
  77. package/GoogleMobileAds/Editor/Resources/PlaceholderAds/Banners.meta +8 -0
  78. package/GoogleMobileAds/Editor/Resources/PlaceholderAds/Interstitials/1024x768.prefab +472 -0
  79. package/GoogleMobileAds/Editor/Resources/PlaceholderAds/Interstitials/1024x768.prefab.meta +13 -0
  80. package/GoogleMobileAds/Editor/Resources/PlaceholderAds/Interstitials/768x1024.prefab +472 -0
  81. package/GoogleMobileAds/Editor/Resources/PlaceholderAds/Interstitials/768x1024.prefab.meta +13 -0
  82. package/GoogleMobileAds/Editor/Resources/PlaceholderAds/Interstitials.meta +8 -0
  83. package/GoogleMobileAds/Editor/Resources/PlaceholderAds/Rewarded/1024x768.prefab +547 -0
  84. package/GoogleMobileAds/Editor/Resources/PlaceholderAds/Rewarded/1024x768.prefab.meta +13 -0
  85. package/GoogleMobileAds/Editor/Resources/PlaceholderAds/Rewarded/768x1024.prefab +547 -0
  86. package/GoogleMobileAds/Editor/Resources/PlaceholderAds/Rewarded/768x1024.prefab.meta +13 -0
  87. package/GoogleMobileAds/Editor/Resources/PlaceholderAds/Rewarded.meta +8 -0
  88. package/GoogleMobileAds/Editor/Resources/PlaceholderAds.meta +8 -0
  89. package/GoogleMobileAds/Editor/Resources/Ump/ConsentForm.png +0 -0
  90. package/GoogleMobileAds/Editor/Resources/Ump/ConsentForm.png.meta +145 -0
  91. package/GoogleMobileAds/Editor/Resources/Ump/ConsentForm.prefab +525 -0
  92. package/GoogleMobileAds/Editor/Resources/Ump/ConsentForm.prefab.meta +12 -0
  93. package/GoogleMobileAds/Editor/Resources/Ump.meta +8 -0
  94. package/GoogleMobileAds/Editor/Resources.meta +8 -0
  95. package/GoogleMobileAds/Editor/Utils.cs +91 -0
  96. package/GoogleMobileAds/Editor/Utils.cs.meta +17 -0
  97. package/GoogleMobileAds/Editor.meta +8 -0
  98. package/GoogleMobileAds/GoogleMobileAds.Android.dll +0 -0
  99. package/GoogleMobileAds/GoogleMobileAds.Android.dll.meta +81 -0
  100. package/GoogleMobileAds/GoogleMobileAds.Common.dll +0 -0
  101. package/GoogleMobileAds/GoogleMobileAds.Common.dll.meta +11 -0
  102. package/GoogleMobileAds/GoogleMobileAds.Core.dll +0 -0
  103. package/GoogleMobileAds/GoogleMobileAds.Core.dll.meta +11 -0
  104. package/GoogleMobileAds/GoogleMobileAds.Ump.Android.dll +0 -0
  105. package/GoogleMobileAds/GoogleMobileAds.Ump.Android.dll.meta +81 -0
  106. package/GoogleMobileAds/GoogleMobileAds.Ump.Unity.dll +0 -0
  107. package/GoogleMobileAds/GoogleMobileAds.Ump.Unity.dll.meta +81 -0
  108. package/GoogleMobileAds/GoogleMobileAds.Ump.dll +0 -0
  109. package/GoogleMobileAds/GoogleMobileAds.Ump.dll.meta +11 -0
  110. package/GoogleMobileAds/GoogleMobileAds.Ump.iOS.dll +0 -0
  111. package/GoogleMobileAds/GoogleMobileAds.Ump.iOS.dll.meta +81 -0
  112. package/GoogleMobileAds/GoogleMobileAds.Unity.dll +0 -0
  113. package/GoogleMobileAds/GoogleMobileAds.Unity.dll.meta +81 -0
  114. package/GoogleMobileAds/GoogleMobileAds.dll +0 -0
  115. package/GoogleMobileAds/GoogleMobileAds.dll.meta +11 -0
  116. package/GoogleMobileAds/GoogleMobileAds.iOS.dll +0 -0
  117. package/GoogleMobileAds/GoogleMobileAds.iOS.dll.meta +81 -0
  118. package/GoogleMobileAds/GoogleMobileAds_version-10.7.0_manifest.txt +78 -0
  119. package/GoogleMobileAds/GoogleMobileAds_version-10.7.0_manifest.txt.meta +10 -0
  120. package/GoogleMobileAds/LICENSE +202 -0
  121. package/GoogleMobileAds/LICENSE.meta +81 -0
  122. package/GoogleMobileAds/Resources/GoogleMobileAdsSettings.asset +22 -0
  123. package/GoogleMobileAds/Resources/GoogleMobileAdsSettings.asset.meta +8 -0
  124. package/GoogleMobileAds/Resources/gma_settings_editor_localization_data.json +72 -0
  125. package/GoogleMobileAds/Resources/gma_settings_editor_localization_data.json.meta +12 -0
  126. package/GoogleMobileAds/Resources.meta +8 -0
  127. package/GoogleMobileAds/link.xml +18 -0
  128. package/GoogleMobileAds/link.xml.meta +11 -0
  129. package/GoogleMobileAds.meta +8 -0
  130. package/Plugins/Android/GoogleMobileAdsPlugin.androidlib/AndroidManifest.xml +14 -0
  131. package/Plugins/Android/GoogleMobileAdsPlugin.androidlib/packaging_options.gradle +5 -0
  132. package/Plugins/Android/GoogleMobileAdsPlugin.androidlib/project.properties +2 -0
  133. package/Plugins/Android/GoogleMobileAdsPlugin.androidlib.meta +32 -0
  134. package/Plugins/Android/googlemobileads-unity.aar +0 -0
  135. package/Plugins/Android/googlemobileads-unity.aar.meta +81 -0
  136. package/Plugins/Android.meta +8 -0
  137. package/Plugins/iOS/GADUAdNetworkExtras.h +10 -0
  138. package/Plugins/iOS/GADUAdNetworkExtras.h.meta +81 -0
  139. package/Plugins/iOS/NativeTemplates/GADTMediumTemplateView.xib +192 -0
  140. package/Plugins/iOS/NativeTemplates/GADTMediumTemplateView.xib.meta +81 -0
  141. package/Plugins/iOS/NativeTemplates/GADTSmallTemplateView.xib +119 -0
  142. package/Plugins/iOS/NativeTemplates/GADTSmallTemplateView.xib.meta +81 -0
  143. package/Plugins/iOS/NativeTemplates.meta +8 -0
  144. package/Plugins/iOS/unity-plugin-library.a +0 -0
  145. package/Plugins/iOS/unity-plugin-library.a.meta +81 -0
  146. package/Plugins/iOS.meta +8 -0
  147. package/Plugins.meta +8 -0
  148. package/README.md +4 -0
  149. package/README.md.meta +7 -0
  150. package/Runtime/NativeAdMob.cs +102 -0
  151. package/Runtime/NativeAdMob.cs.meta +3 -0
  152. package/Runtime/Puzzlescape.AdMob.asmdef +3 -0
  153. package/Runtime/Puzzlescape.AdMob.asmdef.meta +7 -0
  154. package/Runtime.meta +8 -0
  155. package/package.json +11 -0
  156. package/package.json.meta +7 -0
@@ -0,0 +1,249 @@
1
+ // Copyright (C) 2020 Google LLC
2
+ //
3
+ // Licensed under the Apache License, Version 2.0 (the "License");
4
+ // you may not use this file except in compliance with the License.
5
+ // You may obtain a copy of the License at
6
+ //
7
+ // http://www.apache.org/licenses/LICENSE-2.0
8
+ //
9
+ // Unless required by applicable law or agreed to in writing, software
10
+ // distributed under the License is distributed on an "AS IS" BASIS,
11
+ // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12
+ // See the License for the specific language governing permissions and
13
+ // limitations under the License.
14
+
15
+ #if UNITY_ANDROID
16
+ using System.Collections.Generic;
17
+ using System.IO;
18
+ using System.Linq;
19
+ using System.Xml.Linq;
20
+
21
+ using UnityEditor;
22
+ using UnityEditor.Build;
23
+ #if UNITY_2018_1_OR_NEWER
24
+ using UnityEditor.Build.Reporting;
25
+ #endif
26
+ using UnityEngine;
27
+ using GoogleMobileAds.Editor;
28
+
29
+ #if UNITY_2018_1_OR_NEWER
30
+ public class ManifestProcessor : IPreprocessBuildWithReport
31
+ #else
32
+ public class ManifestProcessor : IPreprocessBuild
33
+ #endif
34
+ {
35
+ private const string MANIFEST_RELATIVE_PATH =
36
+ "Plugins/Android/GoogleMobileAdsPlugin.androidlib/AndroidManifest.xml";
37
+
38
+ private const string PROPERTIES_RELATIVE_PATH =
39
+ "Plugins/Android/GoogleMobileAdsPlugin.androidlib/project.properties";
40
+
41
+ private const string METADATA_APPLICATION_ID =
42
+ "com.google.android.gms.ads.APPLICATION_ID";
43
+
44
+ private const string METADATA_DELAY_APP_MEASUREMENT_INIT =
45
+ "com.google.android.gms.ads.DELAY_APP_MEASUREMENT_INIT";
46
+
47
+ private const string METADATA_OPTIMIZE_INITIALIZATION =
48
+ "com.google.android.gms.ads.flag.OPTIMIZE_INITIALIZATION";
49
+
50
+ private const string METADATA_OPTIMIZE_AD_LOADING =
51
+ "com.google.android.gms.ads.flag.OPTIMIZE_AD_LOADING";
52
+
53
+ // LINT.IfChange
54
+ private const string METADATA_UNITY_VERSION = "com.google.unity.ads.UNITY_VERSION";
55
+ // LINT.ThenChange(//depot/google3/javatests/com/google/android/gmscore/integ/modules/admob/tests/robolectric/src/com/google/android/gms/ads/nonagon/signals/StaticDeviceSignalSourceTest.java)
56
+
57
+ private XNamespace ns = "http://schemas.android.com/apk/res/android";
58
+
59
+ public int callbackOrder { get { return 0; } }
60
+
61
+ #if UNITY_2018_1_OR_NEWER
62
+ public void OnPreprocessBuild(BuildReport report)
63
+ #else
64
+ public void OnPreprocessBuild(BuildTarget target, string path)
65
+ #endif
66
+ {
67
+ string manifestPath = Path.Combine(Application.dataPath, MANIFEST_RELATIVE_PATH);
68
+ string propertiesPath = Path.Combine(Application.dataPath, PROPERTIES_RELATIVE_PATH);
69
+
70
+ /*
71
+ * Handle importing GMA via Unity Package Manager.
72
+ */
73
+ EditorPathUtils pathUtils =
74
+ ScriptableObject.CreateInstance<EditorPathUtils>();
75
+ if (pathUtils.IsPackageRootPath())
76
+ {
77
+ // pathUtils.GetParentDirectoryAssetPath() returns "Packages/.../GoogleMobileAds" but
78
+ // Plugins is at the same level of GoogleMobileAds so we go up one directory before
79
+ // appending MANIFEST_RELATIVE_PATH.
80
+ string packagesPathPrefix =
81
+ Path.GetDirectoryName(pathUtils.GetParentDirectoryAssetPath());
82
+ manifestPath = Path.Combine(packagesPathPrefix, MANIFEST_RELATIVE_PATH);
83
+ propertiesPath = Path.Combine(packagesPathPrefix, PROPERTIES_RELATIVE_PATH);
84
+ }
85
+
86
+ if (AssetDatabase.IsValidFolder("Packages/com.google.ads.mobile"))
87
+ {
88
+ manifestPath = Path.Combine("Packages/com.google.ads.mobile", MANIFEST_RELATIVE_PATH);
89
+ }
90
+
91
+ if (!File.Exists(manifestPath))
92
+ {
93
+ manifestPath = Path.Combine(Path.GetDirectoryName(manifestPath), "src", "main",
94
+ "AndroidManifest.xml");
95
+ }
96
+
97
+ XDocument manifest = null;
98
+ try
99
+ {
100
+ manifest = XDocument.Load(manifestPath);
101
+ }
102
+ #pragma warning disable 0168
103
+ catch (IOException e)
104
+ #pragma warning restore 0168
105
+ {
106
+ StopBuildWithMessage("AndroidManifest.xml is missing. Try re-importing the plugin.");
107
+ }
108
+
109
+ XElement elemManifest = manifest.Element("manifest");
110
+ if (elemManifest == null)
111
+ {
112
+ StopBuildWithMessage("AndroidManifest.xml is not valid. Try re-importing the plugin.");
113
+ }
114
+
115
+ XElement elemApplication = elemManifest.Element("application");
116
+ if (elemApplication == null)
117
+ {
118
+ StopBuildWithMessage("AndroidManifest.xml is not valid. Try re-importing the plugin.");
119
+ }
120
+
121
+ GoogleMobileAdsSettings instance = GoogleMobileAdsSettings.LoadInstance();
122
+ string appId = instance.GoogleMobileAdsAndroidAppId.Trim();
123
+
124
+ if (appId.Length == 0)
125
+ {
126
+ StopBuildWithMessage(
127
+ "Android Google Mobile Ads app ID is empty. Please enter a valid app ID to run ads properly.");
128
+ }
129
+
130
+ IEnumerable<XElement> metas = elemApplication.Descendants()
131
+ .Where( elem => elem.Name.LocalName.Equals("meta-data"));
132
+
133
+ SetMetadataElement(elemApplication,
134
+ metas,
135
+ METADATA_APPLICATION_ID,
136
+ appId);
137
+
138
+ SetMetadataElement(elemApplication,
139
+ metas,
140
+ METADATA_OPTIMIZE_INITIALIZATION,
141
+ !instance.DisableOptimizeInitialization,
142
+ true);
143
+
144
+ SetMetadataElement(elemApplication,
145
+ metas,
146
+ METADATA_OPTIMIZE_AD_LOADING,
147
+ !instance.DisableOptimizeAdLoading,
148
+ true);
149
+
150
+ SetMetadataElement(elemApplication,
151
+ metas,
152
+ METADATA_UNITY_VERSION,
153
+ Application.unityVersion);
154
+
155
+ elemManifest.Save(manifestPath);
156
+ }
157
+
158
+ private XElement CreateMetaElement(string name, object value)
159
+ {
160
+ return new XElement("meta-data",
161
+ new XAttribute(ns + "name", name), new XAttribute(ns + "value", value));
162
+ }
163
+
164
+ private XElement GetMetaElement(IEnumerable<XElement> metas, string metaName)
165
+ {
166
+ foreach (XElement elem in metas)
167
+ {
168
+ IEnumerable<XAttribute> attrs = elem.Attributes();
169
+ foreach (XAttribute attr in attrs)
170
+ {
171
+ if (attr.Name.Namespace.Equals(ns)
172
+ && attr.Name.LocalName.Equals("name") && attr.Value.Equals(metaName))
173
+ {
174
+ return elem;
175
+ }
176
+ }
177
+ }
178
+ return null;
179
+ }
180
+
181
+ /// <summary>
182
+ /// Utility for setting a metadata element
183
+ /// </summary>
184
+ /// <param name="elemApplication">application element</param>
185
+ /// <param name="metas">all metadata elements</param>
186
+ /// <param name="metadataName">name of the element to set</param>
187
+ /// <param name="metadataValue">value to set</param>
188
+ private void SetMetadataElement(XElement elemApplication,
189
+ IEnumerable<XElement> metas,
190
+ string metadataName,
191
+ string metadataValue)
192
+ {
193
+ XElement element = GetMetaElement(metas, metadataName);
194
+ if (element == null)
195
+ {
196
+ elemApplication.Add(CreateMetaElement(metadataName, metadataValue));
197
+ }
198
+ else
199
+ {
200
+ element.SetAttributeValue(ns + "value", metadataValue);
201
+ }
202
+ }
203
+
204
+ /// <summary>
205
+ /// Utility for setting a metadata element
206
+ /// </summary>
207
+ /// <param name="elemApplication">application element</param>
208
+ /// <param name="metas">all metadata elements</param>
209
+ /// <param name="metadataName">name of the element to set</param>
210
+ /// <param name="metadataValue">value to set</param>
211
+ /// <param name="defaultValue">If metadataValue is default, node will be removed.</param>
212
+ private void SetMetadataElement(XElement elemApplication,
213
+ IEnumerable<XElement> metas,
214
+ string metadataName,
215
+ bool metadataValue,
216
+ bool defaultValue = false)
217
+ {
218
+ XElement element = GetMetaElement(metas, metadataName);
219
+ if (metadataValue != defaultValue)
220
+ {
221
+ if (element == null)
222
+ {
223
+ elemApplication.Add(CreateMetaElement(metadataName, metadataValue));
224
+ }
225
+ else
226
+ {
227
+ element.SetAttributeValue(ns + "value", metadataValue);
228
+ }
229
+ }
230
+ else
231
+ {
232
+ if (element != null)
233
+ {
234
+ element.Remove();
235
+ }
236
+ }
237
+ }
238
+
239
+ private void StopBuildWithMessage(string message)
240
+ {
241
+ string prefix = "[GoogleMobileAds] ";
242
+ #if UNITY_2017_1_OR_NEWER
243
+ throw new BuildPlayerWindow.BuildMethodException(prefix + message);
244
+ #else
245
+ throw new OperationCanceledException(prefix + message);
246
+ #endif
247
+ }
248
+ }
249
+ #endif
@@ -0,0 +1,17 @@
1
+ fileFormatVersion: 2
2
+ guid: c9ee5d47594eb43a19e795c834fdc044
3
+ labels:
4
+ - gvh
5
+ - gvh_version-10.7.0
6
+ - gvhp_exportpath-GoogleMobileAds/Editor/ManifestProcessor.cs
7
+ timeCreated: 1480838400
8
+ MonoImporter:
9
+ externalObjects: {}
10
+ serializedVersion: 2
11
+ defaultReferences: []
12
+ executionOrder: 0
13
+ icon:
14
+ instanceID: 0
15
+ userData:
16
+ assetBundleName:
17
+ assetBundleVariant:
@@ -0,0 +1,232 @@
1
+ // Copyright (C) 2020 Google LLC
2
+ //
3
+ // Licensed under the Apache License, Version 2.0 (the "License");
4
+ // you may not use this file except in compliance with the License.
5
+ // You may obtain a copy of the License at
6
+ //
7
+ // http://www.apache.org/licenses/LICENSE-2.0
8
+ //
9
+ // Unless required by applicable law or agreed to in writing, software
10
+ // distributed under the License is distributed on an "AS IS" BASIS,
11
+ // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12
+ // See the License for the specific language governing permissions and
13
+ // limitations under the License.
14
+
15
+ #if UNITY_IPHONE || UNITY_IOS
16
+ using System;
17
+ using System.Collections.Generic;
18
+ using System.IO;
19
+ using System.Xml;
20
+
21
+ using UnityEditor;
22
+ using UnityEditor.Callbacks;
23
+ using UnityEditor.iOS.Xcode;
24
+ using UnityEngine;
25
+
26
+ using GoogleMobileAds.Editor;
27
+
28
+ public static class PListProcessor
29
+ {
30
+ private const string KEY_SK_ADNETWORK_ITEMS = "SKAdNetworkItems";
31
+
32
+ private const string KEY_SK_ADNETWORK_ID = "SKAdNetworkIdentifier";
33
+
34
+ private const string SKADNETWORKS_RELATIVE_PATH = "GoogleMobileAds/Editor/GoogleMobileAdsSKAdNetworkItems.xml";
35
+
36
+ private const string SKADNETWORKS_FILE_NAME = "GoogleMobileAdsSKAdNetworkItems.xml";
37
+
38
+ [PostProcessBuild]
39
+ public static void OnPostProcessBuild(BuildTarget buildTarget, string path)
40
+ {
41
+ string plistPath = Path.Combine(path, "Info.plist");
42
+ PlistDocument plist = new PlistDocument();
43
+ plist.ReadFromFile(plistPath);
44
+
45
+ GoogleMobileAdsSettings instance = GoogleMobileAdsSettings.LoadInstance();
46
+ string appId = instance.GoogleMobileAdsIOSAppId.Trim();
47
+ if (appId.Length == 0)
48
+ {
49
+ NotifyBuildFailure(
50
+ "iOS Google Mobile Ads app ID is empty. Please enter a valid app ID to run ads properly.");
51
+ }
52
+ else
53
+ {
54
+ plist.root.SetString("GADApplicationIdentifier", appId);
55
+ }
56
+
57
+ string userTrackingDescription = instance.UserTrackingUsageDescription;
58
+ if (!string.IsNullOrEmpty(userTrackingDescription))
59
+ {
60
+ plist.root.SetString("NSUserTrackingUsageDescription", userTrackingDescription);
61
+ }
62
+
63
+ List<string> skNetworkIds = ReadSKAdNetworkIdentifiersFromXML();
64
+ if (skNetworkIds.Count > 0)
65
+ {
66
+ AddSKAdNetworkIdentifier(plist, skNetworkIds);
67
+ }
68
+
69
+ string unityVersion = Application.unityVersion;
70
+ if (!string.IsNullOrEmpty(unityVersion))
71
+ {
72
+ plist.root.SetString("GADUUnityVersion", unityVersion);
73
+ }
74
+
75
+ File.WriteAllText(plistPath, plist.WriteToString());
76
+ }
77
+
78
+ private static PlistElementArray GetSKAdNetworkItemsArray(PlistDocument document)
79
+ {
80
+ PlistElementArray array;
81
+ if (document.root.values.ContainsKey(KEY_SK_ADNETWORK_ITEMS))
82
+ {
83
+ try
84
+ {
85
+ PlistElement element;
86
+ document.root.values.TryGetValue(KEY_SK_ADNETWORK_ITEMS, out element);
87
+ array = element.AsArray();
88
+ }
89
+ #pragma warning disable 0168
90
+ catch (Exception e)
91
+ #pragma warning restore 0168
92
+ {
93
+ // The element is not an array type.
94
+ array = null;
95
+ }
96
+ }
97
+ else
98
+ {
99
+ array = document.root.CreateArray(KEY_SK_ADNETWORK_ITEMS);
100
+ }
101
+ return array;
102
+ }
103
+
104
+ private static List<string> ReadSKAdNetworkIdentifiersFromXML()
105
+ {
106
+ List<string> skAdNetworkItems = new List<string>();
107
+
108
+ string path = Path.Combine(Application.dataPath, SKADNETWORKS_RELATIVE_PATH);
109
+
110
+ /*
111
+ * Handle importing GMA via Unity Package Manager.
112
+ */
113
+ EditorPathUtils pathUtils = ScriptableObject.CreateInstance<EditorPathUtils>();
114
+ if (pathUtils.IsPackageRootPath())
115
+ {
116
+ string parentDirectoryPath = pathUtils.GetDirectoryAssetPath();
117
+ path = Path.Combine(parentDirectoryPath, SKADNETWORKS_FILE_NAME);
118
+ }
119
+
120
+ try
121
+ {
122
+ if (!File.Exists(path))
123
+ {
124
+ throw new FileNotFoundException();
125
+ }
126
+ using (FileStream fs = File.OpenRead(path))
127
+ {
128
+ XmlDocument document = new XmlDocument();
129
+ document.Load(fs);
130
+
131
+ XmlNode root = document.FirstChild;
132
+
133
+ XmlNodeList nodes = root.SelectNodes(KEY_SK_ADNETWORK_ID);
134
+ foreach (XmlNode node in nodes)
135
+ {
136
+ skAdNetworkItems.Add(node.InnerText);
137
+ }
138
+ }
139
+ }
140
+ #pragma warning disable 0168
141
+ catch (FileNotFoundException e)
142
+ #pragma warning restore 0168
143
+ {
144
+ NotifyBuildFailure("GoogleMobileAdsSKAdNetworkItems.xml not found", false);
145
+ }
146
+ catch (IOException e)
147
+ {
148
+ NotifyBuildFailure("Failed to read GoogleMobileAdsSKAdNetworkIds.xml: " + e.Message, false);
149
+ }
150
+
151
+ return skAdNetworkItems;
152
+ }
153
+
154
+ private static void AddSKAdNetworkIdentifier(PlistDocument document, List<string> skAdNetworkIds)
155
+ {
156
+ PlistElementArray array = GetSKAdNetworkItemsArray(document);
157
+ if (array != null)
158
+ {
159
+ foreach (string id in skAdNetworkIds)
160
+ {
161
+ if (!ContainsSKAdNetworkIdentifier(array, id))
162
+ {
163
+ PlistElementDict added = array.AddDict();
164
+ added.SetString(KEY_SK_ADNETWORK_ID, id);
165
+ }
166
+ }
167
+ }
168
+ else
169
+ {
170
+ NotifyBuildFailure("SKAdNetworkItems element already exists in Info.plist, but is not an array.", false);
171
+ }
172
+ }
173
+
174
+ private static bool ContainsSKAdNetworkIdentifier(PlistElementArray skAdNetworkItemsArray, string id)
175
+ {
176
+ foreach (PlistElement elem in skAdNetworkItemsArray.values)
177
+ {
178
+ try
179
+ {
180
+ PlistElementDict elemInDict = elem.AsDict();
181
+ PlistElement value;
182
+ bool identifierExists = elemInDict.values.TryGetValue(KEY_SK_ADNETWORK_ID, out value);
183
+
184
+ if (identifierExists && value.AsString().Equals(id))
185
+ {
186
+ return true;
187
+ }
188
+ }
189
+ #pragma warning disable 0168
190
+ catch (Exception e)
191
+ #pragma warning restore 0168
192
+ {
193
+ // Do nothing
194
+ }
195
+ }
196
+
197
+ return false;
198
+ }
199
+
200
+ private static void NotifyBuildFailure(string message, bool showOpenSettingsButton = true)
201
+ {
202
+ string dialogTitle = "Google Mobile Ads";
203
+ string dialogMessage = "Error: " + message;
204
+
205
+ if (showOpenSettingsButton)
206
+ {
207
+ bool openSettings = EditorUtility.DisplayDialog(
208
+ dialogTitle, dialogMessage, "Open Settings", "Close");
209
+ if (openSettings)
210
+ {
211
+ GoogleMobileAdsSettingsEditor.OpenInspector();
212
+ }
213
+ }
214
+ else
215
+ {
216
+ EditorUtility.DisplayDialog(dialogTitle, dialogMessage, "Close");
217
+ }
218
+
219
+ ThrowBuildException("[GoogleMobileAds] " + message);
220
+ }
221
+
222
+ private static void ThrowBuildException(string message)
223
+ {
224
+ #if UNITY_2017_1_OR_NEWER
225
+ throw new BuildPlayerWindow.BuildMethodException(message);
226
+ #else
227
+ throw new OperationCanceledException(message);
228
+ #endif
229
+ }
230
+ }
231
+
232
+ #endif
@@ -0,0 +1,17 @@
1
+ fileFormatVersion: 2
2
+ guid: d1d26b084dc244c8c818f67662e51f6c
3
+ labels:
4
+ - gvh
5
+ - gvh_version-10.7.0
6
+ - gvhp_exportpath-GoogleMobileAds/Editor/PListProcessor.cs
7
+ timeCreated: 1480838400
8
+ MonoImporter:
9
+ externalObjects: {}
10
+ serializedVersion: 2
11
+ defaultReferences: []
12
+ executionOrder: 0
13
+ icon:
14
+ instanceID: 0
15
+ userData:
16
+ assetBundleName:
17
+ assetBundleVariant:
@@ -0,0 +1,103 @@
1
+ fileFormatVersion: 2
2
+ guid: 4c69db43dbd474a2987be5807129b4cc
3
+ labels:
4
+ - gvh
5
+ - gvh_version-10.7.0
6
+ - gvhp_exportpath-GoogleMobileAds/Editor/Resources/PlaceholderAds/AdImages/1024x768.png
7
+ timeCreated: 1480838400
8
+ TextureImporter:
9
+ internalIDToNameTable: []
10
+ externalObjects: {}
11
+ serializedVersion: 11
12
+ mipmaps:
13
+ mipMapMode: 0
14
+ enableMipMap: 0
15
+ sRGBTexture: 1
16
+ linearTexture: 0
17
+ fadeOut: 0
18
+ borderMipMap: 0
19
+ mipMapsPreserveCoverage: 0
20
+ alphaTestReferenceValue: 0.5
21
+ mipMapFadeDistanceStart: 1
22
+ mipMapFadeDistanceEnd: 3
23
+ bumpmap:
24
+ convertToNormalMap: 0
25
+ externalNormalMap: 0
26
+ heightScale: 0.25
27
+ normalMapFilter: 0
28
+ isReadable: 0
29
+ streamingMipmaps: 0
30
+ streamingMipmapsPriority: 0
31
+ grayScaleToAlpha: 0
32
+ generateCubemap: 6
33
+ cubemapConvolution: 0
34
+ seamlessCubemap: 0
35
+ textureFormat: 1
36
+ maxTextureSize: 2048
37
+ textureSettings:
38
+ serializedVersion: 2
39
+ filterMode: -1
40
+ aniso: -1
41
+ mipBias: -100
42
+ wrapU: 1
43
+ wrapV: 1
44
+ wrapW: 1
45
+ nPOTScale: 0
46
+ lightmap: 0
47
+ compressionQuality: 50
48
+ spriteMode: 1
49
+ spriteExtrude: 1
50
+ spriteMeshType: 1
51
+ alignment: 0
52
+ spritePivot:
53
+ x: 0.5
54
+ y: 0.5
55
+ spritePixelsToUnits: 100
56
+ spriteBorder:
57
+ x: 0
58
+ y: 0
59
+ z: 0
60
+ w: 0
61
+ spriteGenerateFallbackPhysicsShape: 1
62
+ alphaUsage: 1
63
+ alphaIsTransparency: 1
64
+ spriteTessellationDetail: -1
65
+ textureType: 8
66
+ textureShape: 1
67
+ singleChannelComponent: 0
68
+ maxTextureSizeSet: 0
69
+ compressionQualitySet: 0
70
+ textureFormatSet: 0
71
+ applyGammaDecoding: 0
72
+ platformSettings:
73
+ - serializedVersion: 3
74
+ buildTarget: DefaultTexturePlatform
75
+ maxTextureSize: 2048
76
+ resizeAlgorithm: 0
77
+ textureFormat: -1
78
+ textureCompression: 1
79
+ compressionQuality: 50
80
+ crunchedCompression: 0
81
+ allowsAlphaSplitting: 0
82
+ overridden: 0
83
+ androidETC2FallbackOverride: 0
84
+ forceMaximumCompressionQuality_BC6H_BC7: 0
85
+ spriteSheet:
86
+ serializedVersion: 2
87
+ sprites: []
88
+ outline: []
89
+ physicsShape: []
90
+ bones: []
91
+ spriteID: 5e97eb03825dee720800000000000000
92
+ internalID: 0
93
+ vertices: []
94
+ indices:
95
+ edges: []
96
+ weights: []
97
+ secondaryTextures: []
98
+ spritePackingTag:
99
+ pSDRemoveMatte: 0
100
+ pSDShowRemoveMatteOption: 0
101
+ userData:
102
+ assetBundleName:
103
+ assetBundleVariant: