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
@@ -0,0 +1,43 @@
1
+ /*
2
+ * Copyright (c) 2016-present Invertase Limited & Contributors
3
+ *
4
+ * Licensed under the Apache License, Version 2.0 (the "License");
5
+ * you may not use this library except in compliance with the License.
6
+ * You may obtain a copy of the License at
7
+ *
8
+ * http://www.apache.org/licenses/LICENSE-2.0
9
+ *
10
+ * Unless required by applicable law or agreed to in writing, software
11
+ * distributed under the License is distributed on an "AS IS" BASIS,
12
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
+ * See the License for the specific language governing permissions and
14
+ * limitations under the License.
15
+ *
16
+ */
17
+
18
+ export const APP_NATIVE_MODULE = 'RNFBAppModule';
19
+
20
+ export const DEFAULT_APP_NAME = '[DEFAULT]';
21
+
22
+ export const KNOWN_NAMESPACES = [
23
+ 'appCheck',
24
+ 'appDistribution',
25
+ 'auth',
26
+ 'analytics',
27
+ 'remoteConfig',
28
+ 'crashlytics',
29
+ 'database',
30
+ 'inAppMessaging',
31
+ 'installations',
32
+ 'firestore',
33
+ 'functions',
34
+ 'indexing',
35
+ 'storage',
36
+ 'dynamicLinks',
37
+ 'messaging',
38
+ 'naturalLanguage',
39
+ 'ml',
40
+ 'notifications',
41
+ 'perf',
42
+ 'utils',
43
+ ];
@@ -0,0 +1,21 @@
1
+ /*
2
+ * Copyright (c) 2016-present Invertase Limited & Contributors
3
+ *
4
+ * Licensed under the Apache License, Version 2.0 (the "License");
5
+ * you may not use this library except in compliance with the License.
6
+ * You may obtain a copy of the License at
7
+ *
8
+ * http://www.apache.org/licenses/LICENSE-2.0
9
+ *
10
+ * Unless required by applicable law or agreed to in writing, software
11
+ * distributed under the License is distributed on an "AS IS" BASIS,
12
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
+ * See the License for the specific language governing permissions and
14
+ * limitations under the License.
15
+ *
16
+ */
17
+
18
+ export { AppModule as Module } from './Module';
19
+ export { NativeError } from './NativeError';
20
+ export * from './registry/nativeModule';
21
+ export { SharedEventEmitter } from './SharedEventEmitter';
@@ -0,0 +1,226 @@
1
+ /*
2
+ * Copyright (c) 2016-present Invertase Limited & Contributors
3
+ *
4
+ * Licensed under the Apache License, Version 2.0 (the "License");
5
+ * you may not use this library except in compliance with the License.
6
+ * You may obtain a copy of the License at
7
+ *
8
+ * http://www.apache.org/licenses/LICENSE-2.0
9
+ *
10
+ * Unless required by applicable law or agreed to in writing, software
11
+ * distributed under the License is distributed on an "AS IS" BASIS,
12
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
+ * See the License for the specific language governing permissions and
14
+ * limitations under the License.
15
+ *
16
+ */
17
+
18
+ import { NativeModules, Platform } from 'react-native';
19
+ import { APP_NATIVE_MODULE } from '../constants';
20
+ import { NativeError } from '../NativeError';
21
+ import { GoogleMobileAdsNativeEventEmitter } from '../GoogleMobileAdsNativeEventEmitter';
22
+ import { SharedEventEmitter } from '../SharedEventEmitter';
23
+ import { isFunction } from '../../common';
24
+ import { ModuleInterface } from '../../types/Module.interface';
25
+
26
+ const NATIVE_MODULE_REGISTRY: Record<string, unknown> = {};
27
+ const NATIVE_MODULE_EVENT_SUBSCRIPTIONS: Record<string, unknown> = {};
28
+
29
+ function nativeModuleKey(module: ModuleInterface) {
30
+ return `${module._customUrlOrRegion || ''}:${module.app.name}:${module._config.namespace}`;
31
+ }
32
+
33
+ /**
34
+ * Wraps a native module method to provide
35
+ * auto prepended args and custom Error classes.
36
+ *
37
+ * @param namespace
38
+ * @param method
39
+ * @param argToPrepend
40
+ * @returns {Function}
41
+ */
42
+ function nativeModuleMethodWrapped(
43
+ namespace: string,
44
+ method: (...args: unknown[]) => Promise<unknown> | void,
45
+ argToPrepend: [],
46
+ ) {
47
+ return (...args: []) => {
48
+ const possiblePromise = method(...[...argToPrepend, ...args]);
49
+
50
+ if (possiblePromise && possiblePromise.then) {
51
+ const jsStack = new Error().stack || '';
52
+ return possiblePromise.catch(nativeError =>
53
+ Promise.reject(new NativeError(nativeError, jsStack, namespace)),
54
+ );
55
+ }
56
+
57
+ return possiblePromise;
58
+ };
59
+ }
60
+
61
+ /**
62
+ * Prepends all arguments in prependArgs to all native method calls
63
+ *
64
+ * @param namespace
65
+ * @param NativeModule
66
+ * @param argToPrepend
67
+ */
68
+ function nativeModuleWrapped(
69
+ namespace: string,
70
+ NativeModule: Record<string, (...args: unknown[]) => Promise<unknown> | void>,
71
+ argToPrepend: [],
72
+ ) {
73
+ const native: Record<string, unknown> = {};
74
+ if (!NativeModule) {
75
+ return NativeModule;
76
+ }
77
+
78
+ const properties = Object.keys(NativeModule);
79
+
80
+ for (let i = 0, len = properties.length; i < len; i++) {
81
+ const property = properties[i];
82
+ if (isFunction(NativeModule[property])) {
83
+ native[property] = nativeModuleMethodWrapped(namespace, NativeModule[property], argToPrepend);
84
+ } else {
85
+ native[property] = NativeModule[property];
86
+ }
87
+ }
88
+
89
+ return native;
90
+ }
91
+
92
+ /**
93
+ * Initialises and wraps all the native module methods.
94
+ *
95
+ * @param module
96
+ * @returns {*}
97
+ */
98
+ function initialiseNativeModule(module: ModuleInterface) {
99
+ const config = module._config;
100
+ const key = nativeModuleKey(module);
101
+ const { namespace, nativeEvents, nativeModuleName } = config;
102
+ const multiModuleRoot: Record<string, unknown> = {};
103
+ const multiModule = Array.isArray(nativeModuleName);
104
+ const nativeModuleNames = multiModule ? nativeModuleName : [nativeModuleName];
105
+
106
+ for (let i = 0; i < nativeModuleNames.length; i++) {
107
+ const nativeModule = NativeModules[nativeModuleNames[i]];
108
+
109
+ // only error if there's a single native module
110
+ // as multi modules can mean some are optional
111
+ if (!multiModule && !nativeModule) {
112
+ throw new Error(getMissingModuleHelpText(namespace));
113
+ }
114
+
115
+ if (multiModule) {
116
+ multiModuleRoot[nativeModuleNames[i]] = !!nativeModule;
117
+ }
118
+
119
+ Object.assign(multiModuleRoot, nativeModuleWrapped(namespace, nativeModule, []));
120
+ }
121
+
122
+ if (nativeEvents && nativeEvents.length) {
123
+ for (let i = 0, len = nativeEvents.length; i < len; i++) {
124
+ subscribeToNativeModuleEvent(nativeEvents[i]);
125
+ }
126
+ }
127
+
128
+ Object.freeze(multiModuleRoot);
129
+
130
+ NATIVE_MODULE_REGISTRY[key] = multiModuleRoot;
131
+
132
+ return NATIVE_MODULE_REGISTRY[key];
133
+ }
134
+
135
+ /**
136
+ * Subscribe to a native event for js side distribution by appName
137
+ * React Native events are hard set at compile - cant do dynamic event names
138
+ * so we use a single event send it to js and js then internally can prefix it
139
+ * and distribute dynamically.
140
+ *
141
+ * @param eventName
142
+ * @private
143
+ */
144
+ function subscribeToNativeModuleEvent(eventName: string) {
145
+ if (!NATIVE_MODULE_EVENT_SUBSCRIPTIONS[eventName]) {
146
+ GoogleMobileAdsNativeEventEmitter.addListener(eventName, event => {
147
+ if (event.appName) {
148
+ // native event has an appName property - auto prefix and internally emit
149
+ SharedEventEmitter.emit(`${event.appName}-${eventName}`, event);
150
+ } else {
151
+ // standard event - no need to prefix
152
+ SharedEventEmitter.emit(eventName, event);
153
+ }
154
+ });
155
+
156
+ NATIVE_MODULE_EVENT_SUBSCRIPTIONS[eventName] = true;
157
+ }
158
+ }
159
+
160
+ /**
161
+ * Help text for integrating the native counter parts for each module.
162
+ *
163
+ * @param namespace
164
+ * @returns {string}
165
+ */
166
+ function getMissingModuleHelpText(namespace: string) {
167
+ const snippet = `${namespace}()`;
168
+ const nativeModule = namespace.charAt(0).toUpperCase() + namespace.slice(1);
169
+
170
+ if (Platform.OS === 'ios') {
171
+ return (
172
+ `You attempted to use a module that's not installed natively on your iOS project by calling ${snippet}.` +
173
+ '\r\n\r\nEnsure you have either linked the module or added it to your projects Podfile.' +
174
+ '\r\n\r\nSee http://invertase.link/ios for full setup instructions.'
175
+ );
176
+ }
177
+
178
+ const rnPackage = `'io.invertase.${namespace}.ReactNative${nativeModule}Package'`;
179
+ const newInstance = `'new ReactNative${nativeModule}Package()'`;
180
+
181
+ return (
182
+ `You attempted to use a module that's not installed on your Android project by calling ${snippet}.` +
183
+ `\r\n\r\nEnsure you have:\r\n\r\n1) imported the ${rnPackage} module in your 'MainApplication.java' file.\r\n\r\n2) Added the ` +
184
+ `${newInstance} line inside of the RN 'getPackages()' method list.` +
185
+ '\r\n\r\nSee http://invertase.link/android for full setup instructions.'
186
+ );
187
+ }
188
+
189
+ /**
190
+ * Gets a wrapped native module instance for the provided module.
191
+ * Will attempt to create a new instance if non previously created.
192
+ *
193
+ * @param module
194
+ * @returns {*}
195
+ */
196
+ export function getNativeModule(module: ModuleInterface) {
197
+ const key = nativeModuleKey(module);
198
+
199
+ if (NATIVE_MODULE_REGISTRY[key]) {
200
+ return NATIVE_MODULE_REGISTRY[key];
201
+ }
202
+
203
+ return initialiseNativeModule(module);
204
+ }
205
+
206
+ /**
207
+ * Custom wrapped app module as it does not have it's own FirebaseModule based class.
208
+ *
209
+ * @returns {*}
210
+ */
211
+ export function getAppModule() {
212
+ if (NATIVE_MODULE_REGISTRY[APP_NATIVE_MODULE]) {
213
+ return NATIVE_MODULE_REGISTRY[APP_NATIVE_MODULE];
214
+ }
215
+
216
+ const namespace = 'app';
217
+ const nativeModule = NativeModules[APP_NATIVE_MODULE];
218
+
219
+ if (!nativeModule) {
220
+ throw new Error(getMissingModuleHelpText(namespace));
221
+ }
222
+
223
+ NATIVE_MODULE_REGISTRY[APP_NATIVE_MODULE] = nativeModuleWrapped(namespace, nativeModule, []);
224
+
225
+ return NATIVE_MODULE_REGISTRY[APP_NATIVE_MODULE];
226
+ }
@@ -0,0 +1,16 @@
1
+ import { AdEventType } from '../AdEventType';
2
+ import { RewardedAdReward } from './RewardedAdReward';
3
+ import { RewardedAdEventType } from '../RewardedAdEventType';
4
+
5
+ /**
6
+ * A callback interface for all ad events.
7
+ *
8
+ * @param type The event type, e.g. `AdEventType.LOADED`.
9
+ * @param error An optional JavaScript Error containing the error code and message.
10
+ * @param data Optional data for the event, e.g. reward type and amount
11
+ */
12
+ export type AdEventListener = (
13
+ type: AdEventType | RewardedAdEventType,
14
+ error?: Error,
15
+ data?: RewardedAdReward,
16
+ ) => void;
@@ -0,0 +1,12 @@
1
+ /**
2
+ * A `AdShowOptions` interface used when showing an ad.
3
+ */
4
+ export interface AdShowOptions {
5
+ /**
6
+ * - On Android, enables [immersive mode](https://developer.android.com/training/system-ui/immersive).
7
+ * - On iOS, this has no effect on how the ad is shown.
8
+ *
9
+ * @android
10
+ */
11
+ immersiveModeEnabled?: boolean;
12
+ }
@@ -0,0 +1,20 @@
1
+ export enum InitializationState {
2
+ /**
3
+ * The mediation adapter is less likely to fill ad requests.
4
+ */
5
+ AdapterInitializationStateNotReady = 0,
6
+
7
+ /**
8
+ * The mediation adapter is ready to service ad requests.
9
+ */
10
+ AdapterInitializationStateReady = 1,
11
+ }
12
+
13
+ /**
14
+ * An immutable snapshot of a mediation adapter's initialization status.
15
+ */
16
+ export type AdapterStatus = {
17
+ name: string;
18
+ description: string;
19
+ status: InitializationState;
20
+ };
@@ -0,0 +1,306 @@
1
+ import { AdsConsentDebugGeography } from '../AdsConsentDebugGeography';
2
+ import { AdsConsentStatus } from '../AdsConsentStatus';
3
+
4
+ /**
5
+ * Under the Google [EU User Consent Policy](https://www.google.com/about/company/consentstaging.html), you must make certain disclosures to your users in the European Economic Area (EEA)
6
+ * and obtain their consent to use cookies or other local storage, where legally required, and to use personal data
7
+ * (such as AdID) to serve ads. This policy reflects the requirements of the EU ePrivacy Directive and the
8
+ * General Data Protection Regulation (GDPR).
9
+ *
10
+ * It is recommended that you determine the status of a user's consent at every app launch. The user consent status is held
11
+ * on the device until a condition changes which requires the user to consent again, such as a change in publishers.
12
+ *
13
+ * For more information, see [here](https://developers.google.com/admob/android/eu-consent#delay_app_measurement_optional).
14
+ */
15
+
16
+ /**
17
+ * A AdProvider interface returned from `AdsConsent.getProviders`.
18
+ */
19
+ export interface AdProvider {
20
+ /**
21
+ * A provider company ID.
22
+ */
23
+ companyId: string;
24
+
25
+ /**
26
+ * A provider company name.
27
+ */
28
+ companyName: string;
29
+
30
+ /**
31
+ * A fully formed URL for the privacy policy of the provider.
32
+ */
33
+ privacyPolicyUrl: string;
34
+ }
35
+
36
+ export interface AdsConsentInterface {
37
+ /**
38
+ * Requests user consent for a given list of publisher IDs.
39
+ *
40
+ * The list of publisher IDs can be obtained from the settings panel on the Google Mobile Ads console. If the list of
41
+ * publisher IDs has changed since the last time a user provided consent, their consent status will be reset to
42
+ * 'UNKNOWN' and they must provide consent again.
43
+ *
44
+ * If the request fails with the error "Could not parse Event FE preflight response", this means the state of your
45
+ * Google Mobile Ads account is not complete. Ensure you have validated your account and have setup valid payment
46
+ * information. This error is also thrown when a Publisher ID is invalid.
47
+ *
48
+ * The response from this method provides request location and consent status properties.
49
+ *
50
+ * If request location is within the EEA or unknown, and the consent status is also unknown, you
51
+ * must request consent via the `showForm()` method or your own means.
52
+ *
53
+ * If the consent status is not unknown, the user has already previously provided consent for the current publisher
54
+ * scope.
55
+ *
56
+ * #### Example
57
+ *
58
+ * ```js
59
+ * import { AdsConsent } from 'react-native-google-mobile-ads';
60
+ *
61
+ * const consent = await AdsConsent.requestInfoUpdate(['pub-6189033257628554']);
62
+ * console.log('User location within EEA or Unknown:', consent.isRequestLocationInEeaOrUnknown);
63
+ * console.log('User consent status:', consent.status);
64
+ * ```
65
+ *
66
+ * @param publisherIds A list of publisher IDs found on your Google Mobile Ads dashboard.
67
+ */
68
+ requestInfoUpdate(publisherIds: string[]): Promise<AdsConsentInfo>;
69
+
70
+ /**
71
+ * Shows a Google-rendered user consent form.
72
+ *
73
+ * The Google-rendered consent form is a full-screen configurable form that displays over your app content. The form
74
+ * allows the following configuration options:
75
+ *
76
+ *
77
+ * 1. Consent to view personalized ads (via `withPersonalizedAds`).
78
+ * 2. Consent to view non-personalized ads (via `withNonPersonalizedAds`).
79
+ * 3. Use a paid version of the app instead of viewing ads (via `withAdFree`).
80
+ *
81
+ * Every consent form requires a privacy policy URL which outlines the usage of your application.
82
+ *
83
+ * You should review the consent text carefully: what appears by default is a message that might be appropriate if
84
+ * you use Google to monetize your app.
85
+ *
86
+ * If providing an ad-free version of your app, ensure you handle this once the form has been handled by the user
87
+ * via the `userPrefersAdFree` property. The users preference on consent is automatically forwarded onto the Google
88
+ * Mobile SDKs and saved.
89
+ *
90
+ * If the user is outside of the EEA, the request form will error.
91
+ *
92
+ * #### Example
93
+ *
94
+ * ```js
95
+ * import { AdsConsent, AdsConsentStatus } from 'react-native-google-mobile-ads';
96
+ *
97
+ * async function requestConsent() {
98
+ * const consent = await AdsConsent.requestInfoUpdate(['pub-6189033257628554']);
99
+ *
100
+ * // Check if user requires consent
101
+ * if (consent.isRequestLocationInEeaOrUnknown && consent.status === AdsConsentStatus.UNKNOWN) {
102
+ * // Show a Google-rendered form
103
+ * const result = await AdsConsent.showForm({
104
+ * privacyPolicy: 'https://invertase.io/privacy-policy',
105
+ * withPersonalizedAds: true,
106
+ * withNonPersonalizedAds: true,
107
+ * withAdFree: true,
108
+ * });
109
+ *
110
+ * console.log('User accepted personalized: ', result.status === AdsConsentStatus.PERSONALIZED);
111
+ * console.log('User accepted non-personalized: ', result.status === AdsConsentStatus.NON_PERSONALIZED);
112
+ * console.log('User prefers Ad Free version of app: ', result.userPrefersAdFree);
113
+ * }
114
+ * }
115
+ *
116
+ * ```
117
+ *
118
+ * @param options An AdsConsentFormOptions interface to control the Google-rendered form.
119
+ */
120
+ showForm(options: AdsConsentFormOptions): Promise<AdsConsentFormResult>;
121
+
122
+ /**
123
+ * Returns a list of ad providers currently in use for the given Google Mobile Ads App ID.
124
+ *
125
+ * If requesting consent from the user via your own method, this list of ad providers must be shown to the user
126
+ * for them to accept consent.
127
+ *
128
+ * #### Example
129
+ *
130
+ * ```js
131
+ * import { AdsConsent } from 'react-native-google-mobile-ads';
132
+ *
133
+ * const providers = await AdsConsent.getAdProviders();
134
+ * ```
135
+ */
136
+ getAdProviders(): Promise<AdProvider[]>;
137
+
138
+ /**
139
+ * Sets the debug geography to locally test consent.
140
+ *
141
+ * If debugging on an emulator (where location cannot be determined) or outside of the EEA,
142
+ * it is possible set your own location to test how your app handles different scenarios.
143
+ *
144
+ * If using a real device, ensure you have set it as a test device via `addTestDevice()` otherwise this method will have
145
+ * no effect.
146
+ *
147
+ * #### Example
148
+ *
149
+ * ```js
150
+ * import { AdsConsent, AdsConsentDebugGeography } from 'react-native-google-mobile-ads';
151
+ *
152
+ * // Set disabled
153
+ * await AdsConsentDebugGeography.setDebugGeography(AdsConsentDebugGeography.DISABLED);
154
+ *
155
+ * // Set within EEA
156
+ * await AdsConsentDebugGeography.setDebugGeography(AdsConsentDebugGeography.EEA);
157
+ *
158
+ * // Set outside EEA
159
+ * await AdsConsentDebugGeography.setDebugGeography(AdsConsentDebugGeography.NOT_EEA);
160
+ * ```
161
+ *
162
+ * @param geography The debug geography location.
163
+ */
164
+ setDebugGeography(geography: AdsConsentDebugGeography): Promise<void>;
165
+
166
+ /**
167
+ * Manually update the consent status of the user.
168
+ *
169
+ * This method is used when providing your own means of user consent. If using the Google-rendered form via `showForm()`,
170
+ * the consent status is automatically set and calling this method is not required.
171
+ *
172
+ * This method can also be used to reset the consent status, by setting it to `AdsConsentStatus.UNKNOWN`, which may be useful in certain circumstances.
173
+ *
174
+ * #### Example
175
+ *
176
+ * ```js
177
+ * import { AdsConsent, AdsConsentStatus } from 'react-native-google-mobile-ads';
178
+ *
179
+ * // User accepted personalized ads
180
+ * await AdsConsent.setStatus(AdsConsentStatus.PERSONALIZED);
181
+ * ```
182
+ *
183
+ * @param status The user consent status.
184
+ */
185
+ setStatus(status: AdsConsentStatus): Promise<void>;
186
+
187
+ /**
188
+ * Returns the current consent status of the user.
189
+ *
190
+ * > The user consent status may change at any time, therefore don't reuse old values locally and always request the current value at any time consent is required.
191
+ *
192
+ * #### Example
193
+ *
194
+ * ```js
195
+ * import { AdsConsent } from 'react-native-google-mobile-ads';
196
+ *
197
+ * const status = await AdsConsent.getStatus();
198
+ * ```
199
+ */
200
+ getStatus(): Promise<AdsConsentStatus>;
201
+
202
+ /**
203
+ * If a publisher is aware that the user is under the age of consent, all ad requests must set TFUA (Tag For Users
204
+ * Under the Age of consent in Europe). This setting takes effect for all future ad requests.
205
+ *
206
+ * Once the TFUA setting is enabled, the Google-rendered consent form will fail to load. All ad requests that include
207
+ * TFUA will be made ineligible for personalized advertising and remarketing. TFUA disables requests to third-party
208
+ * ad technology providers, such as ad measurement pixels and third-party ad servers.
209
+ *
210
+ * To remove TFUA from ad requests, set the value to `false`.
211
+ *
212
+ * #### Example
213
+ *
214
+ * ```js
215
+ * import { AdsConsent } from 'react-native-google-mobile-ads';
216
+ *
217
+ * // User is under age of consent
218
+ * await AdsConsent.setTagForUnderAgeOfConsent(true);
219
+ * ```
220
+ *
221
+ * @param tag The boolean value to tag for under age consent.
222
+ */
223
+ setTagForUnderAgeOfConsent(tag: boolean): Promise<void>;
224
+
225
+ /**
226
+ * If using a real device to test, ensure the device ID is provided to the Google Mobile Ads SDK so any mock debug locations
227
+ * can take effect.
228
+ *
229
+ * Emulators are automatically on the allowlist and should require no action.
230
+ *
231
+ * If you are seeing real ad activity from a test device, examine logcat / console
232
+ * during execution in association with google mobile ads test device documentation to
233
+ * configure your device correctly.
234
+ *
235
+ * @param deviceIds An array of testing device ID.
236
+ */
237
+ addTestDevices(deviceIds: string[]): Promise<void>;
238
+ }
239
+
240
+ /**
241
+ * The options used to show on the Google-rendered consent form. At least one of `withAdFree`, `withPersonalizedAds` and `WithNonPersonalizedAds` needs to be set to `true`.
242
+ */
243
+ export interface AdsConsentFormOptions {
244
+ /**
245
+ * A fully formed HTTP or HTTPS privacy policy URL for your application.
246
+ *
247
+ * Users will have the option to visit this web page before consenting to ads.
248
+ */
249
+ privacyPolicy: string;
250
+
251
+ /**
252
+ * Set to `true` to provide the option for the user to accept being shown personalized ads, defaults to `false`.
253
+ */
254
+ withPersonalizedAds?: boolean;
255
+
256
+ /**
257
+ * Set to `true` to provide the option for the user to accept being shown non-personalized ads, defaults to `false`.
258
+ */
259
+ withNonPersonalizedAds?: boolean;
260
+
261
+ /**
262
+ * Set to `true` to provide the option for the user to choose an ad-free version of your app, defaults to `false`.
263
+ *
264
+ * If the user chooses this option, you must handle it as required (e.g. navigating to a paid version of the app,
265
+ * or a subscribe view).
266
+ */
267
+ withAdFree?: boolean;
268
+ }
269
+
270
+ /**
271
+ * The result of a Google-rendered consent form.
272
+ */
273
+ export interface AdsConsentFormResult {
274
+ /**
275
+ * The consent status of the user after closing the consent form.
276
+ *
277
+ * - UNKNOWN: The form was unable to determine the users consent status.
278
+ * - NON_PERSONALIZED: The user has accepted non-personalized ads.
279
+ * - PERSONALIZED: The user has accepted personalized ads.
280
+ */
281
+ status: AdsConsentStatus;
282
+
283
+ /**
284
+ * If `true`, the user requested an ad-free version of your application.
285
+ */
286
+ userPrefersAdFree: boolean;
287
+ }
288
+
289
+ /**
290
+ * The result of requesting info about a users consent status.
291
+ */
292
+ export interface AdsConsentInfo {
293
+ /**
294
+ * The consent status of the user.
295
+ *
296
+ * - UNKNOWN: The consent status is unknown and the user must provide consent to show ads if they are within the EEA or location is also unknown.
297
+ * - NON_PERSONALIZED: The user has accepted non-personalized ads.
298
+ * - PERSONALIZED: The user has accepted personalized ads.
299
+ */
300
+ status: AdsConsentStatus;
301
+
302
+ /**
303
+ * If `true` the user is within the EEA or their location could not be determined.
304
+ */
305
+ isRequestLocationInEeaOrUnknown: boolean;
306
+ }