react-native-google-mobile-ads 4.1.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 (373) hide show
  1. package/LICENSE +32 -0
  2. package/README.md +65 -0
  3. package/RNGoogleMobileAds.podspec +42 -0
  4. package/__tests__/consent.test.ts +25 -0
  5. package/__tests__/googleMobileAds.test.ts +63 -0
  6. package/__tests__/interstitial.test.ts +53 -0
  7. package/__tests__/requestOptions.test.tsx +4 -0
  8. package/__tests__/rewarded.test.tsx +4 -0
  9. package/__tests__/showOptions.test.tsx +4 -0
  10. package/android/.editorconfig +10 -0
  11. package/android/app-json.gradle +69 -0
  12. package/android/build.gradle +98 -0
  13. package/android/lint.xml +5 -0
  14. package/android/settings.gradle +1 -0
  15. package/android/src/main/AndroidManifest.xml +17 -0
  16. package/android/src/main/java/io/invertase/googlemobileads/ReactNativeAppModule.java +169 -0
  17. package/android/src/main/java/io/invertase/googlemobileads/ReactNativeGoogleMobileAdsAppOpenModule.java +161 -0
  18. package/android/src/main/java/io/invertase/googlemobileads/ReactNativeGoogleMobileAdsBannerAdViewManager.java +209 -0
  19. package/android/src/main/java/io/invertase/googlemobileads/ReactNativeGoogleMobileAdsCommon.java +256 -0
  20. package/android/src/main/java/io/invertase/googlemobileads/ReactNativeGoogleMobileAdsConsentModule.java +226 -0
  21. package/android/src/main/java/io/invertase/googlemobileads/ReactNativeGoogleMobileAdsEvent.java +72 -0
  22. package/android/src/main/java/io/invertase/googlemobileads/ReactNativeGoogleMobileAdsInterstitialModule.java +159 -0
  23. package/android/src/main/java/io/invertase/googlemobileads/ReactNativeGoogleMobileAdsModule.java +143 -0
  24. package/android/src/main/java/io/invertase/googlemobileads/ReactNativeGoogleMobileAdsPackage.java +48 -0
  25. package/android/src/main/java/io/invertase/googlemobileads/ReactNativeGoogleMobileAdsRewardedModule.java +177 -0
  26. package/android/src/main/java/io/invertase/googlemobileads/common/RCTConvert.java +111 -0
  27. package/android/src/main/java/io/invertase/googlemobileads/common/ReactNativeApp.java +34 -0
  28. package/android/src/main/java/io/invertase/googlemobileads/common/ReactNativeEvent.java +41 -0
  29. package/android/src/main/java/io/invertase/googlemobileads/common/ReactNativeEventEmitter.java +150 -0
  30. package/android/src/main/java/io/invertase/googlemobileads/common/ReactNativeInitProvider.java +77 -0
  31. package/android/src/main/java/io/invertase/googlemobileads/common/ReactNativeJSON.java +107 -0
  32. package/android/src/main/java/io/invertase/googlemobileads/common/ReactNativeMeta.java +92 -0
  33. package/android/src/main/java/io/invertase/googlemobileads/common/ReactNativeModule.java +96 -0
  34. package/android/src/main/java/io/invertase/googlemobileads/common/ReactNativePreferences.java +86 -0
  35. package/android/src/main/java/io/invertase/googlemobileads/common/SharedUtils.java +427 -0
  36. package/android/src/main/java/io/invertase/googlemobileads/common/TaskExecutorService.java +124 -0
  37. package/android/src/main/java/io/invertase/googlemobileads/interfaces/ContextProvider.java +30 -0
  38. package/android/src/main/java/io/invertase/googlemobileads/interfaces/NativeError.java +28 -0
  39. package/android/src/main/java/io/invertase/googlemobileads/interfaces/NativeEvent.java +26 -0
  40. package/babel.config.js +18 -0
  41. package/docs/displaying-ads.mdx +319 -0
  42. package/docs/european-user-consent.mdx +258 -0
  43. package/docs/img/logo_admob_192px.svg +19 -0
  44. package/docs/index.mdx +168 -0
  45. package/docs.json +9 -0
  46. package/ios/RNGoogleMobileAds/RNGoogleMobileAdsAppOpenModule.h +29 -0
  47. package/ios/RNGoogleMobileAds/RNGoogleMobileAdsAppOpenModule.m +98 -0
  48. package/ios/RNGoogleMobileAds/RNGoogleMobileAdsBannerViewManager.h +23 -0
  49. package/ios/RNGoogleMobileAds/RNGoogleMobileAdsBannerViewManager.m +153 -0
  50. package/ios/RNGoogleMobileAds/RNGoogleMobileAdsCommon.h +60 -0
  51. package/ios/RNGoogleMobileAds/RNGoogleMobileAdsCommon.m +201 -0
  52. package/ios/RNGoogleMobileAds/RNGoogleMobileAdsConsentModule.h +26 -0
  53. package/ios/RNGoogleMobileAds/RNGoogleMobileAdsConsentModule.m +179 -0
  54. package/ios/RNGoogleMobileAds/RNGoogleMobileAdsFullScreenContentDelegate.h +32 -0
  55. package/ios/RNGoogleMobileAds/RNGoogleMobileAdsFullScreenContentDelegate.m +57 -0
  56. package/ios/RNGoogleMobileAds/RNGoogleMobileAdsInterstitialModule.h +25 -0
  57. package/ios/RNGoogleMobileAds/RNGoogleMobileAdsInterstitialModule.m +124 -0
  58. package/ios/RNGoogleMobileAds/RNGoogleMobileAdsModule.h +24 -0
  59. package/ios/RNGoogleMobileAds/RNGoogleMobileAdsModule.m +104 -0
  60. package/ios/RNGoogleMobileAds/RNGoogleMobileAdsRewardedModule.h +25 -0
  61. package/ios/RNGoogleMobileAds/RNGoogleMobileAdsRewardedModule.m +173 -0
  62. package/ios/RNGoogleMobileAds/common/RNAppModule.h +24 -0
  63. package/ios/RNGoogleMobileAds/common/RNAppModule.m +158 -0
  64. package/ios/RNGoogleMobileAds/common/RNJSON.h +34 -0
  65. package/ios/RNGoogleMobileAds/common/RNJSON.m +93 -0
  66. package/ios/RNGoogleMobileAds/common/RNMeta.h +30 -0
  67. package/ios/RNGoogleMobileAds/common/RNMeta.m +61 -0
  68. package/ios/RNGoogleMobileAds/common/RNPreferences.h +44 -0
  69. package/ios/RNGoogleMobileAds/common/RNPreferences.m +94 -0
  70. package/ios/RNGoogleMobileAds/common/RNRCTEventEmitter.h +73 -0
  71. package/ios/RNGoogleMobileAds/common/RNRCTEventEmitter.m +150 -0
  72. package/ios/RNGoogleMobileAds/common/RNSharedUtils.h +48 -0
  73. package/ios/RNGoogleMobileAds/common/RNSharedUtils.m +56 -0
  74. package/ios/RNGoogleMobileAds.xcodeproj/project.pbxproj +377 -0
  75. package/ios/RNGoogleMobileAds.xcodeproj/xcshareddata/IDETemplateMacros.plist +24 -0
  76. package/ios_config.sh +140 -0
  77. package/jest.config.js +6 -0
  78. package/jest.setup.ts +29 -0
  79. package/lib/commonjs/AdEventType.js +34 -0
  80. package/lib/commonjs/AdEventType.js.map +1 -0
  81. package/lib/commonjs/AdsConsent.js +160 -0
  82. package/lib/commonjs/AdsConsent.js.map +1 -0
  83. package/lib/commonjs/AdsConsentDebugGeography.js +38 -0
  84. package/lib/commonjs/AdsConsentDebugGeography.js.map +1 -0
  85. package/lib/commonjs/AdsConsentStatus.js +36 -0
  86. package/lib/commonjs/AdsConsentStatus.js.map +1 -0
  87. package/lib/commonjs/BannerAdSize.js +38 -0
  88. package/lib/commonjs/BannerAdSize.js.map +1 -0
  89. package/lib/commonjs/MaxAdContentRating.js +33 -0
  90. package/lib/commonjs/MaxAdContentRating.js.map +1 -0
  91. package/lib/commonjs/MobileAds.js +67 -0
  92. package/lib/commonjs/MobileAds.js.map +1 -0
  93. package/lib/commonjs/RewardedAdEventType.js +31 -0
  94. package/lib/commonjs/RewardedAdEventType.js.map +1 -0
  95. package/lib/commonjs/TestIds.js +47 -0
  96. package/lib/commonjs/TestIds.js.map +1 -0
  97. package/lib/commonjs/ads/AppOpenAd.js +96 -0
  98. package/lib/commonjs/ads/AppOpenAd.js.map +1 -0
  99. package/lib/commonjs/ads/BannerAd.js +128 -0
  100. package/lib/commonjs/ads/BannerAd.js.map +1 -0
  101. package/lib/commonjs/ads/InterstitialAd.js +163 -0
  102. package/lib/commonjs/ads/InterstitialAd.js.map +1 -0
  103. package/lib/commonjs/ads/MobileAd.js +90 -0
  104. package/lib/commonjs/ads/MobileAd.js.map +1 -0
  105. package/lib/commonjs/ads/RewardedAd.js +169 -0
  106. package/lib/commonjs/ads/RewardedAd.js.map +1 -0
  107. package/lib/commonjs/common/Base64.js +121 -0
  108. package/lib/commonjs/common/Base64.js.map +1 -0
  109. package/lib/commonjs/common/MutatableParams.js +46 -0
  110. package/lib/commonjs/common/MutatableParams.js.map +1 -0
  111. package/lib/commonjs/common/ReferenceBase.js +59 -0
  112. package/lib/commonjs/common/ReferenceBase.js.map +1 -0
  113. package/lib/commonjs/common/deeps.js +101 -0
  114. package/lib/commonjs/common/deeps.js.map +1 -0
  115. package/lib/commonjs/common/id.js +82 -0
  116. package/lib/commonjs/common/id.js.map +1 -0
  117. package/lib/commonjs/common/index.js +212 -0
  118. package/lib/commonjs/common/index.js.map +1 -0
  119. package/lib/commonjs/common/path.js +144 -0
  120. package/lib/commonjs/common/path.js.map +1 -0
  121. package/lib/commonjs/common/promise.js +70 -0
  122. package/lib/commonjs/common/promise.js.map +1 -0
  123. package/lib/commonjs/common/serialize.js +52 -0
  124. package/lib/commonjs/common/serialize.js.map +1 -0
  125. package/lib/commonjs/common/validate.js +239 -0
  126. package/lib/commonjs/common/validate.js.map +1 -0
  127. package/lib/commonjs/declarations.d.js +2 -0
  128. package/lib/commonjs/declarations.d.js.map +1 -0
  129. package/lib/commonjs/index.js +143 -0
  130. package/lib/commonjs/index.js.map +1 -0
  131. package/lib/commonjs/internal/GoogleMobileAdsNativeEventEmitter.js +76 -0
  132. package/lib/commonjs/internal/GoogleMobileAdsNativeEventEmitter.js.map +1 -0
  133. package/lib/commonjs/internal/Module.js +60 -0
  134. package/lib/commonjs/internal/Module.js.map +1 -0
  135. package/lib/commonjs/internal/NativeError.js +70 -0
  136. package/lib/commonjs/internal/NativeError.js.map +1 -0
  137. package/lib/commonjs/internal/SharedEventEmitter.js +31 -0
  138. package/lib/commonjs/internal/SharedEventEmitter.js.map +1 -0
  139. package/lib/commonjs/internal/constants.js +30 -0
  140. package/lib/commonjs/internal/constants.js.map +1 -0
  141. package/lib/commonjs/internal/index.js +49 -0
  142. package/lib/commonjs/internal/index.js.map +1 -0
  143. package/lib/commonjs/internal/registry/nativeModule.js +231 -0
  144. package/lib/commonjs/internal/registry/nativeModule.js.map +1 -0
  145. package/lib/commonjs/types/AdEventListener.js +6 -0
  146. package/lib/commonjs/types/AdEventListener.js.map +1 -0
  147. package/lib/commonjs/types/AdShowOptions.js +2 -0
  148. package/lib/commonjs/types/AdShowOptions.js.map +1 -0
  149. package/lib/commonjs/types/AdapterStatus.js +18 -0
  150. package/lib/commonjs/types/AdapterStatus.js.map +1 -0
  151. package/lib/commonjs/types/AdsConsent.interface.js +6 -0
  152. package/lib/commonjs/types/AdsConsent.interface.js.map +1 -0
  153. package/lib/commonjs/types/BannerAdProps.js +6 -0
  154. package/lib/commonjs/types/BannerAdProps.js.map +1 -0
  155. package/lib/commonjs/types/GoogleMobileAdsNativeModule.js +6 -0
  156. package/lib/commonjs/types/GoogleMobileAdsNativeModule.js.map +1 -0
  157. package/lib/commonjs/types/MobileAd.interface.js +6 -0
  158. package/lib/commonjs/types/MobileAd.interface.js.map +1 -0
  159. package/lib/commonjs/types/MobileAdsModule.interface.js +6 -0
  160. package/lib/commonjs/types/MobileAdsModule.interface.js.map +1 -0
  161. package/lib/commonjs/types/Module.interface.js +2 -0
  162. package/lib/commonjs/types/Module.interface.js.map +1 -0
  163. package/lib/commonjs/types/RequestConfiguration.js +6 -0
  164. package/lib/commonjs/types/RequestConfiguration.js.map +1 -0
  165. package/lib/commonjs/types/RequestOptions.js +2 -0
  166. package/lib/commonjs/types/RequestOptions.js.map +1 -0
  167. package/lib/commonjs/types/RewardedAdReward.js +2 -0
  168. package/lib/commonjs/types/RewardedAdReward.js.map +1 -0
  169. package/lib/commonjs/validateAdRequestConfiguration.js +69 -0
  170. package/lib/commonjs/validateAdRequestConfiguration.js.map +1 -0
  171. package/lib/commonjs/validateAdRequestOptions.js +158 -0
  172. package/lib/commonjs/validateAdRequestOptions.js.map +1 -0
  173. package/lib/commonjs/validateAdShowOptions.js +47 -0
  174. package/lib/commonjs/validateAdShowOptions.js.map +1 -0
  175. package/lib/commonjs/version.js +10 -0
  176. package/lib/commonjs/version.js.map +1 -0
  177. package/lib/module/AdEventType.js +26 -0
  178. package/lib/module/AdEventType.js.map +1 -0
  179. package/lib/module/AdsConsent.js +148 -0
  180. package/lib/module/AdsConsent.js.map +1 -0
  181. package/lib/module/AdsConsentDebugGeography.js +30 -0
  182. package/lib/module/AdsConsentDebugGeography.js.map +1 -0
  183. package/lib/module/AdsConsentStatus.js +28 -0
  184. package/lib/module/AdsConsentStatus.js.map +1 -0
  185. package/lib/module/BannerAdSize.js +30 -0
  186. package/lib/module/BannerAdSize.js.map +1 -0
  187. package/lib/module/MaxAdContentRating.js +25 -0
  188. package/lib/module/MaxAdContentRating.js.map +1 -0
  189. package/lib/module/MobileAds.js +53 -0
  190. package/lib/module/MobileAds.js.map +1 -0
  191. package/lib/module/RewardedAdEventType.js +23 -0
  192. package/lib/module/RewardedAdEventType.js.map +1 -0
  193. package/lib/module/TestIds.js +38 -0
  194. package/lib/module/TestIds.js.map +1 -0
  195. package/lib/module/ads/AppOpenAd.js +81 -0
  196. package/lib/module/ads/AppOpenAd.js.map +1 -0
  197. package/lib/module/ads/BannerAd.js +108 -0
  198. package/lib/module/ads/BannerAd.js.map +1 -0
  199. package/lib/module/ads/InterstitialAd.js +149 -0
  200. package/lib/module/ads/InterstitialAd.js.map +1 -0
  201. package/lib/module/ads/MobileAd.js +94 -0
  202. package/lib/module/ads/MobileAd.js.map +1 -0
  203. package/lib/module/ads/RewardedAd.js +155 -0
  204. package/lib/module/ads/RewardedAd.js.map +1 -0
  205. package/lib/module/common/Base64.js +106 -0
  206. package/lib/module/common/Base64.js.map +1 -0
  207. package/lib/module/common/MutatableParams.js +52 -0
  208. package/lib/module/common/MutatableParams.js.map +1 -0
  209. package/lib/module/common/ReferenceBase.js +50 -0
  210. package/lib/module/common/ReferenceBase.js.map +1 -0
  211. package/lib/module/common/deeps.js +91 -0
  212. package/lib/module/common/deeps.js.map +1 -0
  213. package/lib/module/common/id.js +74 -0
  214. package/lib/module/common/id.js.map +1 -0
  215. package/lib/module/common/index.js +109 -0
  216. package/lib/module/common/index.js.map +1 -0
  217. package/lib/module/common/path.js +120 -0
  218. package/lib/module/common/path.js.map +1 -0
  219. package/lib/module/common/promise.js +60 -0
  220. package/lib/module/common/promise.js.map +1 -0
  221. package/lib/module/common/serialize.js +41 -0
  222. package/lib/module/common/serialize.js.map +1 -0
  223. package/lib/module/common/validate.js +197 -0
  224. package/lib/module/common/validate.js.map +1 -0
  225. package/lib/module/declarations.d.js +2 -0
  226. package/lib/module/declarations.d.js.map +1 -0
  227. package/lib/module/index.js +33 -0
  228. package/lib/module/index.js.map +1 -0
  229. package/lib/module/internal/GoogleMobileAdsNativeEventEmitter.js +83 -0
  230. package/lib/module/internal/GoogleMobileAdsNativeEventEmitter.js.map +1 -0
  231. package/lib/module/internal/Module.js +64 -0
  232. package/lib/module/internal/Module.js.map +1 -0
  233. package/lib/module/internal/NativeError.js +61 -0
  234. package/lib/module/internal/NativeError.js.map +1 -0
  235. package/lib/module/internal/SharedEventEmitter.js +20 -0
  236. package/lib/module/internal/SharedEventEmitter.js.map +1 -0
  237. package/lib/module/internal/constants.js +20 -0
  238. package/lib/module/internal/constants.js.map +1 -0
  239. package/lib/module/internal/index.js +21 -0
  240. package/lib/module/internal/index.js.map +1 -0
  241. package/lib/module/internal/registry/nativeModule.js +215 -0
  242. package/lib/module/internal/registry/nativeModule.js.map +1 -0
  243. package/lib/module/types/AdEventListener.js +2 -0
  244. package/lib/module/types/AdEventListener.js.map +1 -0
  245. package/lib/module/types/AdShowOptions.js +2 -0
  246. package/lib/module/types/AdShowOptions.js.map +1 -0
  247. package/lib/module/types/AdapterStatus.js +10 -0
  248. package/lib/module/types/AdapterStatus.js.map +1 -0
  249. package/lib/module/types/AdsConsent.interface.js +2 -0
  250. package/lib/module/types/AdsConsent.interface.js.map +1 -0
  251. package/lib/module/types/BannerAdProps.js +2 -0
  252. package/lib/module/types/BannerAdProps.js.map +1 -0
  253. package/lib/module/types/GoogleMobileAdsNativeModule.js +2 -0
  254. package/lib/module/types/GoogleMobileAdsNativeModule.js.map +1 -0
  255. package/lib/module/types/MobileAd.interface.js +2 -0
  256. package/lib/module/types/MobileAd.interface.js.map +1 -0
  257. package/lib/module/types/MobileAdsModule.interface.js +2 -0
  258. package/lib/module/types/MobileAdsModule.interface.js.map +1 -0
  259. package/lib/module/types/Module.interface.js +2 -0
  260. package/lib/module/types/Module.interface.js.map +1 -0
  261. package/lib/module/types/RequestConfiguration.js +2 -0
  262. package/lib/module/types/RequestConfiguration.js.map +1 -0
  263. package/lib/module/types/RequestOptions.js +2 -0
  264. package/lib/module/types/RequestOptions.js.map +1 -0
  265. package/lib/module/types/RewardedAdReward.js +2 -0
  266. package/lib/module/types/RewardedAdReward.js.map +1 -0
  267. package/lib/module/validateAdRequestConfiguration.js +60 -0
  268. package/lib/module/validateAdRequestConfiguration.js.map +1 -0
  269. package/lib/module/validateAdRequestOptions.js +150 -0
  270. package/lib/module/validateAdRequestOptions.js.map +1 -0
  271. package/lib/module/validateAdShowOptions.js +39 -0
  272. package/lib/module/validateAdShowOptions.js.map +1 -0
  273. package/lib/module/version.js +3 -0
  274. package/lib/module/version.js.map +1 -0
  275. package/lib/typescript/AdEventType.d.ts +47 -0
  276. package/lib/typescript/AdsConsent.d.ts +2 -0
  277. package/lib/typescript/AdsConsentDebugGeography.d.ts +19 -0
  278. package/lib/typescript/AdsConsentStatus.d.ts +17 -0
  279. package/lib/typescript/BannerAdSize.d.ts +34 -0
  280. package/lib/typescript/MaxAdContentRating.d.ts +18 -0
  281. package/lib/typescript/MobileAds.d.ts +11 -0
  282. package/lib/typescript/RewardedAdEventType.d.ts +46 -0
  283. package/lib/typescript/TestIds.d.ts +6 -0
  284. package/lib/typescript/ads/AppOpenAd.d.ts +11 -0
  285. package/lib/typescript/ads/BannerAd.d.ts +3 -0
  286. package/lib/typescript/ads/InterstitialAd.d.ts +78 -0
  287. package/lib/typescript/ads/MobileAd.d.ts +32 -0
  288. package/lib/typescript/ads/RewardedAd.d.ts +84 -0
  289. package/lib/typescript/common/Base64.d.ts +14 -0
  290. package/lib/typescript/common/MutatableParams.d.ts +9 -0
  291. package/lib/typescript/common/ReferenceBase.d.ts +11 -0
  292. package/lib/typescript/common/deeps.d.ts +18 -0
  293. package/lib/typescript/common/id.d.ts +11 -0
  294. package/lib/typescript/common/index.d.ts +28 -0
  295. package/lib/typescript/common/path.d.ts +43 -0
  296. package/lib/typescript/common/promise.d.ts +13 -0
  297. package/lib/typescript/common/serialize.d.ts +5 -0
  298. package/lib/typescript/common/validate.d.ts +90 -0
  299. package/lib/typescript/index.d.ts +14 -0
  300. package/lib/typescript/internal/GoogleMobileAdsNativeEventEmitter.d.ts +12 -0
  301. package/lib/typescript/internal/Module.d.ts +13 -0
  302. package/lib/typescript/internal/NativeError.d.ts +26 -0
  303. package/lib/typescript/internal/SharedEventEmitter.d.ts +2 -0
  304. package/lib/typescript/internal/constants.d.ts +3 -0
  305. package/lib/typescript/internal/index.d.ts +4 -0
  306. package/lib/typescript/internal/registry/nativeModule.d.ts +15 -0
  307. package/lib/typescript/types/AdEventListener.d.ts +11 -0
  308. package/lib/typescript/types/AdShowOptions.d.ts +12 -0
  309. package/lib/typescript/types/AdapterStatus.d.ts +18 -0
  310. package/lib/typescript/types/AdsConsent.interface.d.ts +286 -0
  311. package/lib/typescript/types/BannerAdProps.d.ts +66 -0
  312. package/lib/typescript/types/GoogleMobileAdsNativeModule.d.ts +14 -0
  313. package/lib/typescript/types/MobileAd.interface.d.ts +64 -0
  314. package/lib/typescript/types/MobileAdsModule.interface.d.ts +38 -0
  315. package/lib/typescript/types/Module.interface.d.ts +14 -0
  316. package/lib/typescript/types/RequestConfiguration.d.ts +36 -0
  317. package/lib/typescript/types/RequestOptions.d.ts +106 -0
  318. package/lib/typescript/types/RewardedAdReward.d.ts +13 -0
  319. package/lib/typescript/validateAdRequestConfiguration.d.ts +2 -0
  320. package/lib/typescript/validateAdRequestOptions.d.ts +2 -0
  321. package/lib/typescript/validateAdShowOptions.d.ts +2 -0
  322. package/lib/typescript/version.d.ts +1 -0
  323. package/package.json +143 -0
  324. package/react-native.config.js +19 -0
  325. package/src/AdEventType.ts +68 -0
  326. package/src/AdsConsent.ts +191 -0
  327. package/src/AdsConsentDebugGeography.ts +38 -0
  328. package/src/AdsConsentStatus.ts +36 -0
  329. package/src/BannerAdSize.ts +59 -0
  330. package/src/MaxAdContentRating.ts +38 -0
  331. package/src/MobileAds.ts +84 -0
  332. package/src/RewardedAdEventType.ts +64 -0
  333. package/src/TestIds.ts +39 -0
  334. package/src/ads/AppOpenAd.ts +85 -0
  335. package/src/ads/BannerAd.tsx +126 -0
  336. package/src/ads/InterstitialAd.ts +156 -0
  337. package/src/ads/MobileAd.ts +101 -0
  338. package/src/ads/RewardedAd.ts +161 -0
  339. package/src/common/Base64.ts +114 -0
  340. package/src/common/MutatableParams.ts +50 -0
  341. package/src/common/ReferenceBase.ts +45 -0
  342. package/src/common/deeps.ts +88 -0
  343. package/src/common/id.ts +74 -0
  344. package/src/common/index.ts +103 -0
  345. package/src/common/path.ts +114 -0
  346. package/src/common/promise.ts +66 -0
  347. package/src/common/serialize.ts +43 -0
  348. package/src/common/validate.ts +205 -0
  349. package/src/declarations.d.ts +3 -0
  350. package/src/index.ts +35 -0
  351. package/src/internal/GoogleMobileAdsNativeEventEmitter.ts +81 -0
  352. package/src/internal/Module.ts +58 -0
  353. package/src/internal/NativeError.ts +56 -0
  354. package/src/internal/SharedEventEmitter.ts +22 -0
  355. package/src/internal/constants.ts +43 -0
  356. package/src/internal/index.ts +21 -0
  357. package/src/internal/registry/nativeModule.ts +226 -0
  358. package/src/types/AdEventListener.ts +16 -0
  359. package/src/types/AdShowOptions.ts +12 -0
  360. package/src/types/AdapterStatus.ts +20 -0
  361. package/src/types/AdsConsent.interface.ts +306 -0
  362. package/src/types/BannerAdProps.ts +73 -0
  363. package/src/types/GoogleMobileAdsNativeModule.ts +15 -0
  364. package/src/types/MobileAd.interface.ts +69 -0
  365. package/src/types/MobileAdsModule.interface.ts +43 -0
  366. package/src/types/Module.interface.ts +16 -0
  367. package/src/types/RequestConfiguration.ts +40 -0
  368. package/src/types/RequestOptions.ts +113 -0
  369. package/src/types/RewardedAdReward.ts +14 -0
  370. package/src/validateAdRequestConfiguration.ts +71 -0
  371. package/src/validateAdRequestOptions.ts +168 -0
  372. package/src/validateAdShowOptions.ts +41 -0
  373. package/src/version.ts +2 -0
package/LICENSE ADDED
@@ -0,0 +1,32 @@
1
+ Apache-2.0 License
2
+ ------------------
3
+
4
+ Copyright (c) 2021-present Invertase Limited <oss@invertase.io>
5
+
6
+ Licensed under the Apache License, Version 2.0 (the "License");
7
+ you may not use this library except in compliance with the License.
8
+
9
+ You may obtain a copy of the Apache-2.0 License at
10
+
11
+ http://www.apache.org/licenses/LICENSE-2.0
12
+
13
+ Unless required by applicable law or agreed to in writing, software
14
+ distributed under the License is distributed on an "AS IS" BASIS,
15
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16
+ See the License for the specific language governing permissions and
17
+ limitations under the License.
18
+
19
+
20
+ Creative Commons Attribution 3.0 License
21
+ ----------------------------------------
22
+
23
+ Copyright (c) 2016-present Invertase Limited <oss@invertase.io>
24
+
25
+ Documentation and other instructional materials provided for this project
26
+ (including on a separate documentation repository or it's documentation website) are
27
+ licensed under the Creative Commons Attribution 3.0 License. Code samples/blocks
28
+ contained therein are licensed under the Apache License, Version 2.0 (the "License"), as above.
29
+
30
+ You may obtain a copy of the Creative Commons Attribution 3.0 License at
31
+
32
+ https://creativecommons.org/licenses/by/3.0/
package/README.md ADDED
@@ -0,0 +1,65 @@
1
+ <p align="center">
2
+ <a href="https://docs.page/invertase/react-native-google-mobile-ads">
3
+ <img width="160px" src="./docs/img/logo_admob_192px.svg"><br/>
4
+ </a>
5
+ <h2 align="center">React Native Google Mobile Ads</h2>
6
+ </p>
7
+
8
+ <p align="center">
9
+ <a href="https://www.npmjs.com/package/react-native-google-mobile-ads"><img src="https://img.shields.io/npm/dm/react-native-google-mobile-ads.svg?style=flat-square" alt="NPM downloads"></a>
10
+ <a href="https://www.npmjs.com/package/react-native-google-mobile-ads"><img src="https://img.shields.io/npm/v/react-native-google-mobile-ads.svg?style=flat-square" alt="NPM version"></a>
11
+ <a href="/LICENSE"><img src="https://img.shields.io/npm/l/react-native-google-mobile-ads.svg?style=flat-square" alt="License"></a>
12
+ </p>
13
+
14
+ <p align="center">
15
+ <a href="https://invertase.link/discord"><img src="https://img.shields.io/discord/295953187817521152.svg?style=flat-square&colorA=7289da&label=Chat%20on%20Discord" alt="Chat on Discord"></a>
16
+ <a href="https://twitter.com/invertaseio"><img src="https://img.shields.io/twitter/follow/invertaseio.svg?style=flat-square&colorA=1da1f2&colorB=&label=Follow%20on%20Twitter" alt="Follow on Twitter"></a>
17
+ <a href="https://www.facebook.com/groups/invertase.io"><img src="https://img.shields.io/badge/Follow%20on%20Facebook-4172B8?logo=facebook&style=flat-square&logoColor=fff" alt="Follow on Facebook"></a>
18
+ </p>
19
+
20
+ ---
21
+
22
+ **React Native Google Mobile Ads** allows you to monetize your app with AdMob; a React Native wrapper around the native Google-Mobile-Ads SDKs for both iOS and Android.
23
+
24
+ React Native Google Mobile Ads is built with three key principals in mind;
25
+
26
+ - 🧪 **Well tested**
27
+ - the module is extensively tested to >95% coverage (getting there after moving from react-native-firebase!)
28
+ - 👁 **Well typed**
29
+ - first class support for Typescript included
30
+ - 📄 **Well documented**
31
+ - full reference & installation documentation alongside detailed guides and FAQs
32
+
33
+ ## Documentation
34
+
35
+ - [Installation](https://docs.page/invertase/react-native-google-mobile-ads)
36
+ - [Displaying Ads](https://docs.page/invertase/react-native-google-mobile-ads/displaying-ads)
37
+
38
+ <!--
39
+ - [Quick Start](https://rnfirebase.io/)
40
+ - [Reference API](https://rnfirebase.io/reference) -->
41
+
42
+ ## Contributing
43
+
44
+ <!-- - [Overview](https://rnfirebase.io) -->
45
+
46
+ - [Issues](https://github.com/invertase/react-native-google-mobile-ads/issues)
47
+ - [PRs](https://github.com/invertase/react-native-google-mobile-ads/pulls)
48
+ <!-- - [Documentation](https://rnfirebase.io) -->
49
+ - [Community](https://github.com/invertase/react-native-google-mobile-ads/blob/master/CONTRIBUTING.md)
50
+ - [Code of Conduct](https://github.com/invertase/meta/blob/master/CODE_OF_CONDUCT.md)
51
+
52
+ ## License
53
+
54
+ - See [LICENSE](/LICENSE)
55
+
56
+ ---
57
+
58
+ <p align="center">
59
+ <a href="https://invertase.io/?utm_source=readme&utm_medium=footer&utm_campaign=react-native-google-mobile-ads">
60
+ <img width="75px" src="https://static.invertase.io/assets/invertase/invertase-rounded-avatar.png">
61
+ </a>
62
+ <p align="center">
63
+ Built and maintained by <a href="https://invertase.io/?utm_source=readme&utm_medium=footer&utm_campaign=react-native-google-mobile-ads">Invertase</a>.
64
+ </p>
65
+ </p>
@@ -0,0 +1,42 @@
1
+ require 'json'
2
+ package = JSON.parse(File.read(File.join(__dir__, 'package.json')))
3
+
4
+ google_ads_sdk_version = package['sdkVersions']['ios']['googleAds']
5
+
6
+ Pod::Spec.new do |s|
7
+ s.name = "RNGoogleMobileAds"
8
+
9
+ s.version = package["version"]
10
+ s.description = package["description"]
11
+ s.summary = <<-DESC
12
+ #{package["description"]}
13
+ DESC
14
+ s.homepage = "http://invertase.io/oss/react-native-google-mobile-ads"
15
+ s.license = package['license']
16
+ s.authors = "Invertase Limited"
17
+ s.source = { :git => "#{package["repository"]["url"]}.git", :tag => "v#{s.version}" }
18
+ s.social_media_url = 'http://twitter.com/invertaseio'
19
+ s.ios.deployment_target = "10.0"
20
+ s.source_files = 'ios/**/*.{h,m}'
21
+
22
+ # React Native dependencies
23
+ s.dependency 'React-Core'
24
+
25
+ # Other dependencies
26
+ s.dependency 'PersonalizedAdConsent', '~> 1.0.5'
27
+
28
+ if defined?($RNGoogleAdsSDKVersion)
29
+ Pod::UI.puts "#{s.name}: Using user specified Google Mobile-Ads SDK version '#{$RNGoogleAdsSDKVersion}'"
30
+ google_ads_sdk_version = $RNGoogleAdsSDKVersion
31
+ end
32
+
33
+ # AdMob dependencies
34
+ s.dependency 'Google-Mobile-Ads-SDK', google_ads_sdk_version
35
+
36
+ if defined?($RNGoogleAdsAsStaticFramework)
37
+ Pod::UI.puts "#{s.name}: Using overridden static_framework value of '#{$RNGoogleAdsAsStaticFramework}'"
38
+ s.static_framework = $RNGoogleAdsAsStaticFramework
39
+ else
40
+ s.static_framework = false
41
+ end
42
+ end
@@ -0,0 +1,25 @@
1
+ import { AdsConsent } from '../src';
2
+
3
+ describe('Google Mobile Ads AdsConsent', function () {
4
+ describe('requestInfoUpdate', function () {
5
+ it('throws if publisherIds is not an array', function () {
6
+ // @ts-ignore
7
+ expect(() => AdsConsent.requestInfoUpdate('pub-123')).toThrowError(
8
+ "AdsConsent.requestInfoUpdate(*) 'publisherIds' expected an array of string values.",
9
+ );
10
+ });
11
+
12
+ it('throws if publisherIds is empty array', function () {
13
+ expect(() => AdsConsent.requestInfoUpdate([])).toThrowError(
14
+ "AdsConsent.requestInfoUpdate(*) 'publisherIds' list of publisher IDs cannot be empty.",
15
+ );
16
+ });
17
+
18
+ it('throws if publisherIds contains non-string values', function () {
19
+ // @ts-ignore
20
+ expect(() => AdsConsent.requestInfoUpdate(['foo', 123])).toThrowError(
21
+ "AdsConsent.requestInfoUpdate(*) 'publisherIds[1]' expected a string value.",
22
+ );
23
+ });
24
+ });
25
+ });
@@ -0,0 +1,63 @@
1
+ import admob, { MaxAdContentRating } from '../src';
2
+
3
+ describe('Admob', function () {
4
+ describe('setRequestConfiguration()', function () {
5
+ it('throws if config is not an object', function () {
6
+ // @ts-ignore
7
+ expect(() => admob().setRequestConfiguration('123')).toThrowError(
8
+ "setRequestConfiguration(*) 'requestConfiguration' expected an object value",
9
+ );
10
+ });
11
+
12
+ describe('maxAdContentRating', function () {
13
+ it('throws if maxAdContentRating is invalid', function () {
14
+ expect(() =>
15
+ admob().setRequestConfiguration({
16
+ maxAdContentRating: 'Y' as MaxAdContentRating,
17
+ }),
18
+ ).toThrowError(
19
+ "setRequestConfiguration(*) 'requestConfiguration.maxAdContentRating' expected on of MaxAdContentRating.G, MaxAdContentRating.PG, MaxAdContentRating.T or MaxAdContentRating.MA",
20
+ );
21
+ });
22
+ });
23
+
24
+ describe('tagForChildDirectedTreatment', function () {
25
+ it('throws if tagForChildDirectedTreatment not a boolean', function () {
26
+ expect(() =>
27
+ admob().setRequestConfiguration({
28
+ // @ts-ignore
29
+ tagForChildDirectedTreatment: 'true',
30
+ }),
31
+ ).toThrowError(
32
+ "setRequestConfiguration(*) 'requestConfiguration.tagForChildDirectedTreatment' expected a boolean value",
33
+ );
34
+ });
35
+ });
36
+
37
+ describe('tagForUnderAgeOfConsent', function () {
38
+ it('throws if tagForUnderAgeOfConsent not a boolean', function () {
39
+ expect(() =>
40
+ admob().setRequestConfiguration({
41
+ // @ts-ignore
42
+ tagForUnderAgeOfConsent: 'false',
43
+ }),
44
+ ).toThrowError(
45
+ "setRequestConfiguration(*) 'requestConfiguration.tagForUnderAgeOfConsent' expected a boolean value",
46
+ );
47
+ });
48
+ });
49
+
50
+ describe('testDeviceIdentifiers', function () {
51
+ it('throws if testDeviceIdentifiers not an array', function () {
52
+ expect(() =>
53
+ admob().setRequestConfiguration({
54
+ // @ts-ignore
55
+ testDeviceIdentifiers: 'EMULATOR',
56
+ }),
57
+ ).toThrowError(
58
+ "setRequestConfiguration(*) 'requestConfiguration.testDeviceIdentifiers' expected an array value",
59
+ );
60
+ });
61
+ });
62
+ });
63
+ });
@@ -0,0 +1,53 @@
1
+ import { InterstitialAd } from '../src';
2
+
3
+ describe('Google Mobile Ads Interstitial', function () {
4
+ describe('createForAdRequest', function () {
5
+ it('throws if adUnitId is invalid', function () {
6
+ // @ts-ignore
7
+ expect(() => InterstitialAd.createForAdRequest(123)).toThrowError(
8
+ "'adUnitId' expected an string value",
9
+ );
10
+ });
11
+
12
+ it('throws if requestOptions are invalid', function () {
13
+ // @ts-ignore
14
+ expect(() => InterstitialAd.createForAdRequest('123', 123)).toThrowError(
15
+ "InterstitialAd.createForAdRequest(_, *) 'options' expected an object value.",
16
+ );
17
+ });
18
+
19
+ // has own tests
20
+ it('returns a new instance', function () {
21
+ const i = InterstitialAd.createForAdRequest('abc');
22
+ expect(i.constructor.name).toEqual('InterstitialAd');
23
+ expect(i.adUnitId).toEqual('abc');
24
+ expect(i.loaded).toEqual(false);
25
+ });
26
+
27
+ describe('show', function () {
28
+ it('throws if showing before loaded', function () {
29
+ const i = InterstitialAd.createForAdRequest('abc');
30
+
31
+ expect(() => i.show()).toThrowError(
32
+ 'The requested InterstitialAd has not loaded and could not be shown',
33
+ );
34
+ });
35
+ });
36
+
37
+ describe('onAdEvent', function () {
38
+ it('throws if handler is not a function', function () {
39
+ const i = InterstitialAd.createForAdRequest('abc');
40
+
41
+ // @ts-ignore
42
+ expect(() => i.onAdEvent('foo')).toThrowError("'handler' expected a function");
43
+ });
44
+
45
+ it('returns an unsubscriber function', function () {
46
+ const i = InterstitialAd.createForAdRequest('abc');
47
+ const unsub = i.onAdEvent(() => {});
48
+ expect(unsub).toBeDefined();
49
+ unsub();
50
+ });
51
+ });
52
+ });
53
+ });
@@ -0,0 +1,4 @@
1
+ describe('Admob RequestOptions', () => {
2
+ // eslint-disable-next-line jest/no-disabled-tests
3
+ test.skip('skip', () => {});
4
+ });
@@ -0,0 +1,4 @@
1
+ describe('Admob Rewarded', () => {
2
+ // eslint-disable-next-line jest/no-disabled-tests
3
+ test.skip('skip', () => {});
4
+ });
@@ -0,0 +1,4 @@
1
+ describe('Admob Show Options', () => {
2
+ // eslint-disable-next-line jest/no-disabled-tests
3
+ test.skip('skip', () => {});
4
+ });
@@ -0,0 +1,10 @@
1
+ # editorconfig
2
+ root = true
3
+
4
+ [*]
5
+ indent_style = space
6
+ indent_size = 2
7
+ end_of_line = lf
8
+ charset = utf-8
9
+ trim_trailing_whitespace = true
10
+ insert_final_newline = true
@@ -0,0 +1,69 @@
1
+ import groovy.json.JsonOutput
2
+ import groovy.json.JsonSlurper
3
+
4
+ String fileName = "app.json"
5
+ String jsonRoot = "react-native-google-mobile-ads"
6
+ String jsonRaw = "GOOGLE_MOBILE_ADS_JSON_RAW"
7
+
8
+ File jsonFile = null
9
+ File parentDir = rootProject.projectDir
10
+
11
+ for (int i = 0; i <= 3; i++) {
12
+ if (parentDir == null) break
13
+ parentDir = parentDir.parentFile
14
+ if (parentDir != null) {
15
+ jsonFile = new File(parentDir, fileName)
16
+ if (jsonFile.exists()) break
17
+ }
18
+ }
19
+
20
+ if (jsonFile != null && jsonFile.exists()) {
21
+ rootProject.logger.info ":${project.name} ${fileName} found at ${jsonFile.toString()}"
22
+ Object json = null
23
+
24
+ try {
25
+ json = new JsonSlurper().parseText(jsonFile.text)
26
+ } catch (Exception ignored) {
27
+ rootProject.logger.warn ":${project.name} failed to parse ${fileName} found at ${jsonFile.toString()}."
28
+ rootProject.logger.warn ignored.toString()
29
+ }
30
+
31
+ if (json && json[jsonRoot]) {
32
+ String jsonStr = JsonOutput.toJson(JsonOutput.toJson(json[jsonRoot]))
33
+
34
+ rootProject.ext.googleMobileAdsJson = [
35
+ raw: json[jsonRoot],
36
+ isFlagEnabled: { key, defaultValue ->
37
+ if (json[jsonRoot] == null || json[jsonRoot][key] == null) return defaultValue
38
+ return json[jsonRoot][key] == true ? true : false
39
+ },
40
+ getStringValue: { key, defaultValue ->
41
+ if (json[jsonRoot] == null) return defaultValue
42
+ return json[jsonRoot][key] ? json[jsonRoot][key] : defaultValue
43
+ }
44
+ ]
45
+
46
+ rootProject.logger.info ":${project.name} found ${jsonRoot} json root in ${fileName}, creating app build config"
47
+ android {
48
+ defaultConfig {
49
+ buildConfigField "String", jsonRaw, jsonStr
50
+ }
51
+ }
52
+ } else {
53
+ rootProject.ext.googleAdsJson = false
54
+ rootProject.logger.info ":${project.name} ${fileName} found with no ${jsonRoot} config, skipping"
55
+ android {
56
+ defaultConfig {
57
+ buildConfigField "String", jsonRaw, '"{}"'
58
+ }
59
+ }
60
+ }
61
+ } else {
62
+ rootProject.ext.googleMobileAdsJson = false
63
+ rootProject.logger.info ":${project.name} no ${fileName} found, skipping"
64
+ android {
65
+ defaultConfig {
66
+ buildConfigField "String", jsonRaw, '"{}"'
67
+ }
68
+ }
69
+ }
@@ -0,0 +1,98 @@
1
+ import io.invertase.gradle.common.PackageJson
2
+
3
+ buildscript {
4
+ // The Android Gradle plugin is only required when opening the android folder stand-alone.
5
+ // This avoids unnecessary downloads and potential conflicts when the library is included as a
6
+ // module dependency in an application project.
7
+ if (project == rootProject) {
8
+ repositories {
9
+ google()
10
+ mavenCentral()
11
+ }
12
+
13
+ dependencies {
14
+ classpath("com.android.tools.build:gradle:7.0.4")
15
+ }
16
+ }
17
+ }
18
+
19
+ plugins {
20
+ id "io.invertase.gradle.build" version "1.5"
21
+ }
22
+
23
+ def packageJson = PackageJson.getForProject(project)
24
+ def googleMobileAdsVersion = packageJson['sdkVersions']['android']['googleMobileAds']
25
+ def jsonMinSdk = packageJson['sdkVersions']['android']['minSdk']
26
+ def jsonTargetSdk = packageJson['sdkVersions']['android']['targetSdk']
27
+ def jsonCompileSdk = packageJson['sdkVersions']['android']['compileSdk']
28
+ def jsonBuildTools = packageJson['sdkVersions']['android']['buildTools']
29
+
30
+ project.ext {
31
+ set('react-native', [
32
+ versions: [
33
+ android : [
34
+ minSdk : jsonMinSdk,
35
+ targetSdk : jsonTargetSdk,
36
+ compileSdk: jsonCompileSdk,
37
+ // optional as gradle.buildTools comes with one by default
38
+ // overriding here though to match the version RN uses
39
+ buildTools: jsonBuildTools
40
+ ],
41
+
42
+ googleMobileAds: [
43
+ sdk: googleMobileAdsVersion,
44
+ ],
45
+
46
+ ads : [
47
+ consent: "1.0.6"
48
+ ],
49
+ ],
50
+ ])
51
+ }
52
+
53
+ apply from: file("./app-json.gradle")
54
+
55
+ def appJSONGoogleMobileAdsAppIDString = ""
56
+ def appJSONGoogleMobileAdsDelayAppMeasurementInitBool = false
57
+
58
+ if (rootProject.ext.googleMobileAdsJson) {
59
+ appJSONGoogleMobileAdsAppIDString = rootProject.ext.googleMobileAdsJson.getStringValue("android_app_id", "")
60
+ appJSONGoogleMobileAdsDelayAppMeasurementInitBool = rootProject.ext.googleMobileAdsJson.isFlagEnabled("delay_app_measurement_init", false)
61
+ }
62
+
63
+ if (!appJSONGoogleMobileAdsAppIDString) {
64
+ // todo throw a build error?
65
+ }
66
+
67
+ android {
68
+ defaultConfig {
69
+ multiDexEnabled true
70
+ manifestPlaceholders = [
71
+ appJSONGoogleMobileAdsAppID : appJSONGoogleMobileAdsAppIDString,
72
+ appJSONGoogleMobileAdsDelayAppMeasurementInit: appJSONGoogleMobileAdsDelayAppMeasurementInitBool
73
+ ]
74
+ }
75
+ lintOptions {
76
+ disable 'GradleCompatible'
77
+ abortOnError false
78
+ }
79
+ compileOptions {
80
+ sourceCompatibility JavaVersion.VERSION_1_8
81
+ targetCompatibility JavaVersion.VERSION_1_8
82
+ }
83
+ }
84
+
85
+ repositories {
86
+ google()
87
+ mavenCentral()
88
+ }
89
+
90
+ dependencies {
91
+ implementation("com.google.android.gms:play-services-ads:20.5.0") { force = true; }
92
+ implementation "com.google.android.ads.consent:consent-library:${ReactNative.ext.getVersion("ads", "consent")}"
93
+ }
94
+
95
+ ReactNative.shared.applyPackageVersion()
96
+ ReactNative.shared.applyDefaultExcludes()
97
+ ReactNative.module.applyAndroidVersions()
98
+ ReactNative.module.applyReactNativeDependency("api")
@@ -0,0 +1,5 @@
1
+ <?xml version="1.0" encoding="UTF-8"?>
2
+ <lint>
3
+ <!-- Disable the given check in this project -->
4
+ <issue id="GradleCompatible" severity="ignore" />
5
+ </lint>
@@ -0,0 +1 @@
1
+ rootProject.name = 'react-native-google-mobile-ads'
@@ -0,0 +1,17 @@
1
+ <?xml version="1.0" encoding="utf-8"?>
2
+ <manifest xmlns:android="http://schemas.android.com/apk/res/android"
3
+ package="io.invertase.googlemobileads">
4
+
5
+ <uses-permission android:name="android.permission.INTERNET" />
6
+ <uses-permission android:name="android.permission.WAKE_LOCK" />
7
+ <uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
8
+
9
+ <application>
10
+ <meta-data
11
+ android:name="com.google.android.gms.ads.APPLICATION_ID"
12
+ android:value="${appJSONGoogleMobileAdsAppID}"/>
13
+ <meta-data
14
+ android:name="com.google.android.gms.ads.DELAY_APP_MEASUREMENT_INIT"
15
+ android:value="${appJSONGoogleMobileAdsDelayAppMeasurementInit}"/>
16
+ </application>
17
+ </manifest>
@@ -0,0 +1,169 @@
1
+ package io.invertase.googlemobileads;
2
+
3
+ /*
4
+ * Copyright (c) 2016-present Invertase Limited & Contributors
5
+ *
6
+ * Licensed under the Apache License, Version 2.0 (the "License");
7
+ * you may not use this library except in compliance with the License.
8
+ * You may obtain a copy of the License at
9
+ *
10
+ * http://www.apache.org/licenses/LICENSE-2.0
11
+ *
12
+ * Unless required by applicable law or agreed to in writing, software
13
+ * distributed under the License is distributed on an "AS IS" BASIS,
14
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15
+ * See the License for the specific language governing permissions and
16
+ * limitations under the License.
17
+ *
18
+ */
19
+
20
+ import com.facebook.react.bridge.Promise;
21
+ import com.facebook.react.bridge.ReactApplicationContext;
22
+ import com.facebook.react.bridge.ReactMethod;
23
+ import com.facebook.react.bridge.ReadableMap;
24
+ import io.invertase.googlemobileads.common.RCTConvert;
25
+ import io.invertase.googlemobileads.common.ReactNativeEvent;
26
+ import io.invertase.googlemobileads.common.ReactNativeEventEmitter;
27
+ import io.invertase.googlemobileads.common.ReactNativeJSON;
28
+ import io.invertase.googlemobileads.common.ReactNativeMeta;
29
+ import io.invertase.googlemobileads.common.ReactNativeModule;
30
+ import io.invertase.googlemobileads.common.ReactNativePreferences;
31
+ import java.util.HashMap;
32
+ import java.util.Map;
33
+
34
+ public class ReactNativeAppModule extends ReactNativeModule {
35
+ private static final String TAG = "RNAppModule";
36
+
37
+ ReactNativeAppModule(ReactApplicationContext reactContext) {
38
+ super(reactContext, TAG);
39
+ }
40
+
41
+ @Override
42
+ public void initialize() {
43
+ super.initialize();
44
+ ReactNativeEventEmitter.getSharedInstance().attachReactContext(getContext());
45
+ }
46
+
47
+ @ReactMethod
48
+ public void initializeApp(ReadableMap options, ReadableMap appConfig, Promise promise) {
49
+ // ReactNativeApp reactNativeApp =
50
+ // RCTConvertFirebase.readableMapToFirebaseApp(options, appConfig, getContext());
51
+
52
+ // WritableMap reactNativeAppMap =
53
+ // RCTConvertFirebase.reactNativeAppToWritableMap(reactNativeApp);
54
+ // promise.resolve(reactNativeAppMap);
55
+ promise.resolve(options);
56
+ }
57
+
58
+ @ReactMethod
59
+ public void setAutomaticDataCollectionEnabled(String appName, Boolean enabled) {
60
+ // ReactNativeApp reactNativeApp = ReactNativeApp.getInstance(appName);
61
+ // reactNativeApp.setDataCollectionDefaultEnabled(enabled);
62
+ }
63
+
64
+ @ReactMethod
65
+ public void deleteApp(String appName, Promise promise) {
66
+ // ReactNativeApp reactNativeApp = ReactNativeApp.getInstance(appName);
67
+
68
+ // if (reactNativeApp != null) {
69
+ // reactNativeApp.delete();
70
+ // }
71
+
72
+ promise.resolve(null);
73
+ }
74
+
75
+ @ReactMethod
76
+ public void eventsNotifyReady(Boolean ready) {
77
+ ReactNativeEventEmitter emitter = ReactNativeEventEmitter.getSharedInstance();
78
+ emitter.notifyJsReady(ready);
79
+ }
80
+
81
+ @ReactMethod
82
+ public void eventsGetListeners(Promise promise) {
83
+ ReactNativeEventEmitter emitter = ReactNativeEventEmitter.getSharedInstance();
84
+ promise.resolve(emitter.getListenersMap());
85
+ }
86
+
87
+ @ReactMethod
88
+ public void eventsPing(String eventName, ReadableMap eventBody, Promise promise) {
89
+ ReactNativeEventEmitter emitter = ReactNativeEventEmitter.getSharedInstance();
90
+ emitter.sendEvent(
91
+ new ReactNativeEvent(eventName, RCTConvert.readableMapToWritableMap(eventBody)));
92
+ promise.resolve(RCTConvert.readableMapToWritableMap(eventBody));
93
+ }
94
+
95
+ @ReactMethod
96
+ public void eventsAddListener(String eventName) {
97
+ ReactNativeEventEmitter emitter = ReactNativeEventEmitter.getSharedInstance();
98
+ emitter.addListener(eventName);
99
+ }
100
+
101
+ @ReactMethod
102
+ public void eventsRemoveListener(String eventName, Boolean all) {
103
+ ReactNativeEventEmitter emitter = ReactNativeEventEmitter.getSharedInstance();
104
+ emitter.removeListener(eventName, all);
105
+ }
106
+
107
+ @ReactMethod
108
+ public void addListener(String eventName) {
109
+ // Keep: Required for RN built in Event Emitter Calls.
110
+ }
111
+
112
+ @ReactMethod
113
+ public void removeListeners(Integer count) {
114
+ // Keep: Required for RN built in Event Emitter Calls.
115
+ }
116
+
117
+ /** ------------------ META ------------------ */
118
+ @ReactMethod
119
+ public void metaGetAll(Promise promise) {
120
+ promise.resolve(ReactNativeMeta.getSharedInstance().getAll());
121
+ }
122
+
123
+ /** ------------------ JSON ------------------ */
124
+ @ReactMethod
125
+ public void jsonGetAll(Promise promise) {
126
+ promise.resolve(ReactNativeJSON.getSharedInstance().getAll());
127
+ }
128
+
129
+ /** ------------------ PREFERENCES ------------------ */
130
+ @ReactMethod
131
+ public void preferencesSetBool(String key, boolean value, Promise promise) {
132
+ ReactNativePreferences.getSharedInstance().setBooleanValue(key, value);
133
+ promise.resolve(null);
134
+ }
135
+
136
+ @ReactMethod
137
+ public void preferencesSetString(String key, String value, Promise promise) {
138
+ ReactNativePreferences.getSharedInstance().setStringValue(key, value);
139
+ promise.resolve(null);
140
+ }
141
+
142
+ @ReactMethod
143
+ public void preferencesGetAll(Promise promise) {
144
+ promise.resolve(ReactNativePreferences.getSharedInstance().getAll());
145
+ }
146
+
147
+ @ReactMethod
148
+ public void preferencesClearAll(Promise promise) {
149
+ ReactNativePreferences.getSharedInstance().clearAll();
150
+ promise.resolve(null);
151
+ }
152
+
153
+ @Override
154
+ public Map<String, Object> getConstants() {
155
+ Map<String, Object> constants = new HashMap<>();
156
+ // List<Map<String, Object>> appsList = new ArrayList<>();
157
+ // List<ReactNativeApp> reactNativeApps = ReactNativeApp.getApps(getReactApplicationContext());
158
+
159
+ // for (ReactNativeApp app : reactNativeApps) {
160
+ // appsList.add(RCTConvertFirebase.reactNativeAppToMap(app));
161
+ // }
162
+
163
+ // constants.put("NATIVE_FIREBASE_APPS", appsList);
164
+
165
+ // constants.put("FIREBASE_RAW_JSON", ReactNativeJSON.getSharedInstance().getRawJSON());
166
+
167
+ return constants;
168
+ }
169
+ }