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.
- package/LICENSE +32 -0
- package/README.md +65 -0
- package/RNGoogleMobileAds.podspec +42 -0
- package/__tests__/consent.test.ts +25 -0
- package/__tests__/googleMobileAds.test.ts +63 -0
- package/__tests__/interstitial.test.ts +53 -0
- package/__tests__/requestOptions.test.tsx +4 -0
- package/__tests__/rewarded.test.tsx +4 -0
- package/__tests__/showOptions.test.tsx +4 -0
- package/android/.editorconfig +10 -0
- package/android/app-json.gradle +69 -0
- package/android/build.gradle +98 -0
- package/android/lint.xml +5 -0
- package/android/settings.gradle +1 -0
- package/android/src/main/AndroidManifest.xml +17 -0
- package/android/src/main/java/io/invertase/googlemobileads/ReactNativeAppModule.java +169 -0
- package/android/src/main/java/io/invertase/googlemobileads/ReactNativeGoogleMobileAdsAppOpenModule.java +161 -0
- package/android/src/main/java/io/invertase/googlemobileads/ReactNativeGoogleMobileAdsBannerAdViewManager.java +209 -0
- package/android/src/main/java/io/invertase/googlemobileads/ReactNativeGoogleMobileAdsCommon.java +256 -0
- package/android/src/main/java/io/invertase/googlemobileads/ReactNativeGoogleMobileAdsConsentModule.java +226 -0
- package/android/src/main/java/io/invertase/googlemobileads/ReactNativeGoogleMobileAdsEvent.java +72 -0
- package/android/src/main/java/io/invertase/googlemobileads/ReactNativeGoogleMobileAdsInterstitialModule.java +159 -0
- package/android/src/main/java/io/invertase/googlemobileads/ReactNativeGoogleMobileAdsModule.java +143 -0
- package/android/src/main/java/io/invertase/googlemobileads/ReactNativeGoogleMobileAdsPackage.java +48 -0
- package/android/src/main/java/io/invertase/googlemobileads/ReactNativeGoogleMobileAdsRewardedModule.java +177 -0
- package/android/src/main/java/io/invertase/googlemobileads/common/RCTConvert.java +111 -0
- package/android/src/main/java/io/invertase/googlemobileads/common/ReactNativeApp.java +34 -0
- package/android/src/main/java/io/invertase/googlemobileads/common/ReactNativeEvent.java +41 -0
- package/android/src/main/java/io/invertase/googlemobileads/common/ReactNativeEventEmitter.java +150 -0
- package/android/src/main/java/io/invertase/googlemobileads/common/ReactNativeInitProvider.java +77 -0
- package/android/src/main/java/io/invertase/googlemobileads/common/ReactNativeJSON.java +107 -0
- package/android/src/main/java/io/invertase/googlemobileads/common/ReactNativeMeta.java +92 -0
- package/android/src/main/java/io/invertase/googlemobileads/common/ReactNativeModule.java +96 -0
- package/android/src/main/java/io/invertase/googlemobileads/common/ReactNativePreferences.java +86 -0
- package/android/src/main/java/io/invertase/googlemobileads/common/SharedUtils.java +427 -0
- package/android/src/main/java/io/invertase/googlemobileads/common/TaskExecutorService.java +124 -0
- package/android/src/main/java/io/invertase/googlemobileads/interfaces/ContextProvider.java +30 -0
- package/android/src/main/java/io/invertase/googlemobileads/interfaces/NativeError.java +28 -0
- package/android/src/main/java/io/invertase/googlemobileads/interfaces/NativeEvent.java +26 -0
- package/babel.config.js +18 -0
- package/docs/displaying-ads.mdx +319 -0
- package/docs/european-user-consent.mdx +258 -0
- package/docs/img/logo_admob_192px.svg +19 -0
- package/docs/index.mdx +168 -0
- package/docs.json +9 -0
- package/ios/RNGoogleMobileAds/RNGoogleMobileAdsAppOpenModule.h +29 -0
- package/ios/RNGoogleMobileAds/RNGoogleMobileAdsAppOpenModule.m +98 -0
- package/ios/RNGoogleMobileAds/RNGoogleMobileAdsBannerViewManager.h +23 -0
- package/ios/RNGoogleMobileAds/RNGoogleMobileAdsBannerViewManager.m +153 -0
- package/ios/RNGoogleMobileAds/RNGoogleMobileAdsCommon.h +60 -0
- package/ios/RNGoogleMobileAds/RNGoogleMobileAdsCommon.m +201 -0
- package/ios/RNGoogleMobileAds/RNGoogleMobileAdsConsentModule.h +26 -0
- package/ios/RNGoogleMobileAds/RNGoogleMobileAdsConsentModule.m +179 -0
- package/ios/RNGoogleMobileAds/RNGoogleMobileAdsFullScreenContentDelegate.h +32 -0
- package/ios/RNGoogleMobileAds/RNGoogleMobileAdsFullScreenContentDelegate.m +57 -0
- package/ios/RNGoogleMobileAds/RNGoogleMobileAdsInterstitialModule.h +25 -0
- package/ios/RNGoogleMobileAds/RNGoogleMobileAdsInterstitialModule.m +124 -0
- package/ios/RNGoogleMobileAds/RNGoogleMobileAdsModule.h +24 -0
- package/ios/RNGoogleMobileAds/RNGoogleMobileAdsModule.m +104 -0
- package/ios/RNGoogleMobileAds/RNGoogleMobileAdsRewardedModule.h +25 -0
- package/ios/RNGoogleMobileAds/RNGoogleMobileAdsRewardedModule.m +173 -0
- package/ios/RNGoogleMobileAds/common/RNAppModule.h +24 -0
- package/ios/RNGoogleMobileAds/common/RNAppModule.m +158 -0
- package/ios/RNGoogleMobileAds/common/RNJSON.h +34 -0
- package/ios/RNGoogleMobileAds/common/RNJSON.m +93 -0
- package/ios/RNGoogleMobileAds/common/RNMeta.h +30 -0
- package/ios/RNGoogleMobileAds/common/RNMeta.m +61 -0
- package/ios/RNGoogleMobileAds/common/RNPreferences.h +44 -0
- package/ios/RNGoogleMobileAds/common/RNPreferences.m +94 -0
- package/ios/RNGoogleMobileAds/common/RNRCTEventEmitter.h +73 -0
- package/ios/RNGoogleMobileAds/common/RNRCTEventEmitter.m +150 -0
- package/ios/RNGoogleMobileAds/common/RNSharedUtils.h +48 -0
- package/ios/RNGoogleMobileAds/common/RNSharedUtils.m +56 -0
- package/ios/RNGoogleMobileAds.xcodeproj/project.pbxproj +377 -0
- package/ios/RNGoogleMobileAds.xcodeproj/xcshareddata/IDETemplateMacros.plist +24 -0
- package/ios_config.sh +140 -0
- package/jest.config.js +6 -0
- package/jest.setup.ts +29 -0
- package/lib/commonjs/AdEventType.js +34 -0
- package/lib/commonjs/AdEventType.js.map +1 -0
- package/lib/commonjs/AdsConsent.js +160 -0
- package/lib/commonjs/AdsConsent.js.map +1 -0
- package/lib/commonjs/AdsConsentDebugGeography.js +38 -0
- package/lib/commonjs/AdsConsentDebugGeography.js.map +1 -0
- package/lib/commonjs/AdsConsentStatus.js +36 -0
- package/lib/commonjs/AdsConsentStatus.js.map +1 -0
- package/lib/commonjs/BannerAdSize.js +38 -0
- package/lib/commonjs/BannerAdSize.js.map +1 -0
- package/lib/commonjs/MaxAdContentRating.js +33 -0
- package/lib/commonjs/MaxAdContentRating.js.map +1 -0
- package/lib/commonjs/MobileAds.js +67 -0
- package/lib/commonjs/MobileAds.js.map +1 -0
- package/lib/commonjs/RewardedAdEventType.js +31 -0
- package/lib/commonjs/RewardedAdEventType.js.map +1 -0
- package/lib/commonjs/TestIds.js +47 -0
- package/lib/commonjs/TestIds.js.map +1 -0
- package/lib/commonjs/ads/AppOpenAd.js +96 -0
- package/lib/commonjs/ads/AppOpenAd.js.map +1 -0
- package/lib/commonjs/ads/BannerAd.js +128 -0
- package/lib/commonjs/ads/BannerAd.js.map +1 -0
- package/lib/commonjs/ads/InterstitialAd.js +163 -0
- package/lib/commonjs/ads/InterstitialAd.js.map +1 -0
- package/lib/commonjs/ads/MobileAd.js +90 -0
- package/lib/commonjs/ads/MobileAd.js.map +1 -0
- package/lib/commonjs/ads/RewardedAd.js +169 -0
- package/lib/commonjs/ads/RewardedAd.js.map +1 -0
- package/lib/commonjs/common/Base64.js +121 -0
- package/lib/commonjs/common/Base64.js.map +1 -0
- package/lib/commonjs/common/MutatableParams.js +46 -0
- package/lib/commonjs/common/MutatableParams.js.map +1 -0
- package/lib/commonjs/common/ReferenceBase.js +59 -0
- package/lib/commonjs/common/ReferenceBase.js.map +1 -0
- package/lib/commonjs/common/deeps.js +101 -0
- package/lib/commonjs/common/deeps.js.map +1 -0
- package/lib/commonjs/common/id.js +82 -0
- package/lib/commonjs/common/id.js.map +1 -0
- package/lib/commonjs/common/index.js +212 -0
- package/lib/commonjs/common/index.js.map +1 -0
- package/lib/commonjs/common/path.js +144 -0
- package/lib/commonjs/common/path.js.map +1 -0
- package/lib/commonjs/common/promise.js +70 -0
- package/lib/commonjs/common/promise.js.map +1 -0
- package/lib/commonjs/common/serialize.js +52 -0
- package/lib/commonjs/common/serialize.js.map +1 -0
- package/lib/commonjs/common/validate.js +239 -0
- package/lib/commonjs/common/validate.js.map +1 -0
- package/lib/commonjs/declarations.d.js +2 -0
- package/lib/commonjs/declarations.d.js.map +1 -0
- package/lib/commonjs/index.js +143 -0
- package/lib/commonjs/index.js.map +1 -0
- package/lib/commonjs/internal/GoogleMobileAdsNativeEventEmitter.js +76 -0
- package/lib/commonjs/internal/GoogleMobileAdsNativeEventEmitter.js.map +1 -0
- package/lib/commonjs/internal/Module.js +60 -0
- package/lib/commonjs/internal/Module.js.map +1 -0
- package/lib/commonjs/internal/NativeError.js +70 -0
- package/lib/commonjs/internal/NativeError.js.map +1 -0
- package/lib/commonjs/internal/SharedEventEmitter.js +31 -0
- package/lib/commonjs/internal/SharedEventEmitter.js.map +1 -0
- package/lib/commonjs/internal/constants.js +30 -0
- package/lib/commonjs/internal/constants.js.map +1 -0
- package/lib/commonjs/internal/index.js +49 -0
- package/lib/commonjs/internal/index.js.map +1 -0
- package/lib/commonjs/internal/registry/nativeModule.js +231 -0
- package/lib/commonjs/internal/registry/nativeModule.js.map +1 -0
- package/lib/commonjs/types/AdEventListener.js +6 -0
- package/lib/commonjs/types/AdEventListener.js.map +1 -0
- package/lib/commonjs/types/AdShowOptions.js +2 -0
- package/lib/commonjs/types/AdShowOptions.js.map +1 -0
- package/lib/commonjs/types/AdapterStatus.js +18 -0
- package/lib/commonjs/types/AdapterStatus.js.map +1 -0
- package/lib/commonjs/types/AdsConsent.interface.js +6 -0
- package/lib/commonjs/types/AdsConsent.interface.js.map +1 -0
- package/lib/commonjs/types/BannerAdProps.js +6 -0
- package/lib/commonjs/types/BannerAdProps.js.map +1 -0
- package/lib/commonjs/types/GoogleMobileAdsNativeModule.js +6 -0
- package/lib/commonjs/types/GoogleMobileAdsNativeModule.js.map +1 -0
- package/lib/commonjs/types/MobileAd.interface.js +6 -0
- package/lib/commonjs/types/MobileAd.interface.js.map +1 -0
- package/lib/commonjs/types/MobileAdsModule.interface.js +6 -0
- package/lib/commonjs/types/MobileAdsModule.interface.js.map +1 -0
- package/lib/commonjs/types/Module.interface.js +2 -0
- package/lib/commonjs/types/Module.interface.js.map +1 -0
- package/lib/commonjs/types/RequestConfiguration.js +6 -0
- package/lib/commonjs/types/RequestConfiguration.js.map +1 -0
- package/lib/commonjs/types/RequestOptions.js +2 -0
- package/lib/commonjs/types/RequestOptions.js.map +1 -0
- package/lib/commonjs/types/RewardedAdReward.js +2 -0
- package/lib/commonjs/types/RewardedAdReward.js.map +1 -0
- package/lib/commonjs/validateAdRequestConfiguration.js +69 -0
- package/lib/commonjs/validateAdRequestConfiguration.js.map +1 -0
- package/lib/commonjs/validateAdRequestOptions.js +158 -0
- package/lib/commonjs/validateAdRequestOptions.js.map +1 -0
- package/lib/commonjs/validateAdShowOptions.js +47 -0
- package/lib/commonjs/validateAdShowOptions.js.map +1 -0
- package/lib/commonjs/version.js +10 -0
- package/lib/commonjs/version.js.map +1 -0
- package/lib/module/AdEventType.js +26 -0
- package/lib/module/AdEventType.js.map +1 -0
- package/lib/module/AdsConsent.js +148 -0
- package/lib/module/AdsConsent.js.map +1 -0
- package/lib/module/AdsConsentDebugGeography.js +30 -0
- package/lib/module/AdsConsentDebugGeography.js.map +1 -0
- package/lib/module/AdsConsentStatus.js +28 -0
- package/lib/module/AdsConsentStatus.js.map +1 -0
- package/lib/module/BannerAdSize.js +30 -0
- package/lib/module/BannerAdSize.js.map +1 -0
- package/lib/module/MaxAdContentRating.js +25 -0
- package/lib/module/MaxAdContentRating.js.map +1 -0
- package/lib/module/MobileAds.js +53 -0
- package/lib/module/MobileAds.js.map +1 -0
- package/lib/module/RewardedAdEventType.js +23 -0
- package/lib/module/RewardedAdEventType.js.map +1 -0
- package/lib/module/TestIds.js +38 -0
- package/lib/module/TestIds.js.map +1 -0
- package/lib/module/ads/AppOpenAd.js +81 -0
- package/lib/module/ads/AppOpenAd.js.map +1 -0
- package/lib/module/ads/BannerAd.js +108 -0
- package/lib/module/ads/BannerAd.js.map +1 -0
- package/lib/module/ads/InterstitialAd.js +149 -0
- package/lib/module/ads/InterstitialAd.js.map +1 -0
- package/lib/module/ads/MobileAd.js +94 -0
- package/lib/module/ads/MobileAd.js.map +1 -0
- package/lib/module/ads/RewardedAd.js +155 -0
- package/lib/module/ads/RewardedAd.js.map +1 -0
- package/lib/module/common/Base64.js +106 -0
- package/lib/module/common/Base64.js.map +1 -0
- package/lib/module/common/MutatableParams.js +52 -0
- package/lib/module/common/MutatableParams.js.map +1 -0
- package/lib/module/common/ReferenceBase.js +50 -0
- package/lib/module/common/ReferenceBase.js.map +1 -0
- package/lib/module/common/deeps.js +91 -0
- package/lib/module/common/deeps.js.map +1 -0
- package/lib/module/common/id.js +74 -0
- package/lib/module/common/id.js.map +1 -0
- package/lib/module/common/index.js +109 -0
- package/lib/module/common/index.js.map +1 -0
- package/lib/module/common/path.js +120 -0
- package/lib/module/common/path.js.map +1 -0
- package/lib/module/common/promise.js +60 -0
- package/lib/module/common/promise.js.map +1 -0
- package/lib/module/common/serialize.js +41 -0
- package/lib/module/common/serialize.js.map +1 -0
- package/lib/module/common/validate.js +197 -0
- package/lib/module/common/validate.js.map +1 -0
- package/lib/module/declarations.d.js +2 -0
- package/lib/module/declarations.d.js.map +1 -0
- package/lib/module/index.js +33 -0
- package/lib/module/index.js.map +1 -0
- package/lib/module/internal/GoogleMobileAdsNativeEventEmitter.js +83 -0
- package/lib/module/internal/GoogleMobileAdsNativeEventEmitter.js.map +1 -0
- package/lib/module/internal/Module.js +64 -0
- package/lib/module/internal/Module.js.map +1 -0
- package/lib/module/internal/NativeError.js +61 -0
- package/lib/module/internal/NativeError.js.map +1 -0
- package/lib/module/internal/SharedEventEmitter.js +20 -0
- package/lib/module/internal/SharedEventEmitter.js.map +1 -0
- package/lib/module/internal/constants.js +20 -0
- package/lib/module/internal/constants.js.map +1 -0
- package/lib/module/internal/index.js +21 -0
- package/lib/module/internal/index.js.map +1 -0
- package/lib/module/internal/registry/nativeModule.js +215 -0
- package/lib/module/internal/registry/nativeModule.js.map +1 -0
- package/lib/module/types/AdEventListener.js +2 -0
- package/lib/module/types/AdEventListener.js.map +1 -0
- package/lib/module/types/AdShowOptions.js +2 -0
- package/lib/module/types/AdShowOptions.js.map +1 -0
- package/lib/module/types/AdapterStatus.js +10 -0
- package/lib/module/types/AdapterStatus.js.map +1 -0
- package/lib/module/types/AdsConsent.interface.js +2 -0
- package/lib/module/types/AdsConsent.interface.js.map +1 -0
- package/lib/module/types/BannerAdProps.js +2 -0
- package/lib/module/types/BannerAdProps.js.map +1 -0
- package/lib/module/types/GoogleMobileAdsNativeModule.js +2 -0
- package/lib/module/types/GoogleMobileAdsNativeModule.js.map +1 -0
- package/lib/module/types/MobileAd.interface.js +2 -0
- package/lib/module/types/MobileAd.interface.js.map +1 -0
- package/lib/module/types/MobileAdsModule.interface.js +2 -0
- package/lib/module/types/MobileAdsModule.interface.js.map +1 -0
- package/lib/module/types/Module.interface.js +2 -0
- package/lib/module/types/Module.interface.js.map +1 -0
- package/lib/module/types/RequestConfiguration.js +2 -0
- package/lib/module/types/RequestConfiguration.js.map +1 -0
- package/lib/module/types/RequestOptions.js +2 -0
- package/lib/module/types/RequestOptions.js.map +1 -0
- package/lib/module/types/RewardedAdReward.js +2 -0
- package/lib/module/types/RewardedAdReward.js.map +1 -0
- package/lib/module/validateAdRequestConfiguration.js +60 -0
- package/lib/module/validateAdRequestConfiguration.js.map +1 -0
- package/lib/module/validateAdRequestOptions.js +150 -0
- package/lib/module/validateAdRequestOptions.js.map +1 -0
- package/lib/module/validateAdShowOptions.js +39 -0
- package/lib/module/validateAdShowOptions.js.map +1 -0
- package/lib/module/version.js +3 -0
- package/lib/module/version.js.map +1 -0
- package/lib/typescript/AdEventType.d.ts +47 -0
- package/lib/typescript/AdsConsent.d.ts +2 -0
- package/lib/typescript/AdsConsentDebugGeography.d.ts +19 -0
- package/lib/typescript/AdsConsentStatus.d.ts +17 -0
- package/lib/typescript/BannerAdSize.d.ts +34 -0
- package/lib/typescript/MaxAdContentRating.d.ts +18 -0
- package/lib/typescript/MobileAds.d.ts +11 -0
- package/lib/typescript/RewardedAdEventType.d.ts +46 -0
- package/lib/typescript/TestIds.d.ts +6 -0
- package/lib/typescript/ads/AppOpenAd.d.ts +11 -0
- package/lib/typescript/ads/BannerAd.d.ts +3 -0
- package/lib/typescript/ads/InterstitialAd.d.ts +78 -0
- package/lib/typescript/ads/MobileAd.d.ts +32 -0
- package/lib/typescript/ads/RewardedAd.d.ts +84 -0
- package/lib/typescript/common/Base64.d.ts +14 -0
- package/lib/typescript/common/MutatableParams.d.ts +9 -0
- package/lib/typescript/common/ReferenceBase.d.ts +11 -0
- package/lib/typescript/common/deeps.d.ts +18 -0
- package/lib/typescript/common/id.d.ts +11 -0
- package/lib/typescript/common/index.d.ts +28 -0
- package/lib/typescript/common/path.d.ts +43 -0
- package/lib/typescript/common/promise.d.ts +13 -0
- package/lib/typescript/common/serialize.d.ts +5 -0
- package/lib/typescript/common/validate.d.ts +90 -0
- package/lib/typescript/index.d.ts +14 -0
- package/lib/typescript/internal/GoogleMobileAdsNativeEventEmitter.d.ts +12 -0
- package/lib/typescript/internal/Module.d.ts +13 -0
- package/lib/typescript/internal/NativeError.d.ts +26 -0
- package/lib/typescript/internal/SharedEventEmitter.d.ts +2 -0
- package/lib/typescript/internal/constants.d.ts +3 -0
- package/lib/typescript/internal/index.d.ts +4 -0
- package/lib/typescript/internal/registry/nativeModule.d.ts +15 -0
- package/lib/typescript/types/AdEventListener.d.ts +11 -0
- package/lib/typescript/types/AdShowOptions.d.ts +12 -0
- package/lib/typescript/types/AdapterStatus.d.ts +18 -0
- package/lib/typescript/types/AdsConsent.interface.d.ts +286 -0
- package/lib/typescript/types/BannerAdProps.d.ts +66 -0
- package/lib/typescript/types/GoogleMobileAdsNativeModule.d.ts +14 -0
- package/lib/typescript/types/MobileAd.interface.d.ts +64 -0
- package/lib/typescript/types/MobileAdsModule.interface.d.ts +38 -0
- package/lib/typescript/types/Module.interface.d.ts +14 -0
- package/lib/typescript/types/RequestConfiguration.d.ts +36 -0
- package/lib/typescript/types/RequestOptions.d.ts +106 -0
- package/lib/typescript/types/RewardedAdReward.d.ts +13 -0
- package/lib/typescript/validateAdRequestConfiguration.d.ts +2 -0
- package/lib/typescript/validateAdRequestOptions.d.ts +2 -0
- package/lib/typescript/validateAdShowOptions.d.ts +2 -0
- package/lib/typescript/version.d.ts +1 -0
- package/package.json +143 -0
- package/react-native.config.js +19 -0
- package/src/AdEventType.ts +68 -0
- package/src/AdsConsent.ts +191 -0
- package/src/AdsConsentDebugGeography.ts +38 -0
- package/src/AdsConsentStatus.ts +36 -0
- package/src/BannerAdSize.ts +59 -0
- package/src/MaxAdContentRating.ts +38 -0
- package/src/MobileAds.ts +84 -0
- package/src/RewardedAdEventType.ts +64 -0
- package/src/TestIds.ts +39 -0
- package/src/ads/AppOpenAd.ts +85 -0
- package/src/ads/BannerAd.tsx +126 -0
- package/src/ads/InterstitialAd.ts +156 -0
- package/src/ads/MobileAd.ts +101 -0
- package/src/ads/RewardedAd.ts +161 -0
- package/src/common/Base64.ts +114 -0
- package/src/common/MutatableParams.ts +50 -0
- package/src/common/ReferenceBase.ts +45 -0
- package/src/common/deeps.ts +88 -0
- package/src/common/id.ts +74 -0
- package/src/common/index.ts +103 -0
- package/src/common/path.ts +114 -0
- package/src/common/promise.ts +66 -0
- package/src/common/serialize.ts +43 -0
- package/src/common/validate.ts +205 -0
- package/src/declarations.d.ts +3 -0
- package/src/index.ts +35 -0
- package/src/internal/GoogleMobileAdsNativeEventEmitter.ts +81 -0
- package/src/internal/Module.ts +58 -0
- package/src/internal/NativeError.ts +56 -0
- package/src/internal/SharedEventEmitter.ts +22 -0
- package/src/internal/constants.ts +43 -0
- package/src/internal/index.ts +21 -0
- package/src/internal/registry/nativeModule.ts +226 -0
- package/src/types/AdEventListener.ts +16 -0
- package/src/types/AdShowOptions.ts +12 -0
- package/src/types/AdapterStatus.ts +20 -0
- package/src/types/AdsConsent.interface.ts +306 -0
- package/src/types/BannerAdProps.ts +73 -0
- package/src/types/GoogleMobileAdsNativeModule.ts +15 -0
- package/src/types/MobileAd.interface.ts +69 -0
- package/src/types/MobileAdsModule.interface.ts +43 -0
- package/src/types/Module.interface.ts +16 -0
- package/src/types/RequestConfiguration.ts +40 -0
- package/src/types/RequestOptions.ts +113 -0
- package/src/types/RewardedAdReward.ts +14 -0
- package/src/validateAdRequestConfiguration.ts +71 -0
- package/src/validateAdRequestOptions.ts +168 -0
- package/src/validateAdShowOptions.ts +41 -0
- package/src/version.ts +2 -0
|
@@ -0,0 +1,258 @@
|
|
|
1
|
+
# European User Consent
|
|
2
|
+
|
|
3
|
+
Under the Google [EU User Consent Policy](https://www.google.com/about/company/consentstaging.html), you must make
|
|
4
|
+
certain disclosures to your users in the European Economic Area (EEA) and obtain their consent to use cookies or
|
|
5
|
+
other local storage, where legally required, and to use personal data (such as `AdID`) to serve ads. This policy
|
|
6
|
+
reflects the requirements of the `EU ePrivacy Directive` and the `General Data Protection Regulation` (GDPR).
|
|
7
|
+
|
|
8
|
+
The React Native Google Mobile Ads module provides out of the box support for helping to manage your users consent
|
|
9
|
+
within your application. The `AdsConsent` helper which comes with the module wraps the Google Consent SDK for both
|
|
10
|
+
Android & iOS, and provides a single JavaScript interface for both platforms.
|
|
11
|
+
|
|
12
|
+
The `AdsConsent` helper & AdMob module provides out of the box support for:
|
|
13
|
+
|
|
14
|
+
- Requesting consent for multiple publisher IDs.
|
|
15
|
+
- Showing a Google-rendered consent form, listing all providers on your enabled mediation networks.
|
|
16
|
+
- Manually handling user consent if you prefer not to use the Google-rendered consent form.
|
|
17
|
+
- Forwarding your user consent status onto AdMob ad requests.
|
|
18
|
+
|
|
19
|
+
## Understanding AdMob Ads
|
|
20
|
+
|
|
21
|
+
Ads served by Google can be categorized as personalized or non-personalized, both requiring consent from users in the EEA. By default,
|
|
22
|
+
ad requests to Google serve personalized ads, with ad selection based on the user's previously collected data. Users outside of the EEA do not require consent.
|
|
23
|
+
|
|
24
|
+
> The `AdsConsent` helper only provides you with the tools for requesting consent, it is up to the developer to ensure the consent status is reflected throughout the app.
|
|
25
|
+
|
|
26
|
+
## Handling consent
|
|
27
|
+
|
|
28
|
+
The following steps show the various methods and ways of handling consent within your app.
|
|
29
|
+
|
|
30
|
+
### Delaying app measurement
|
|
31
|
+
|
|
32
|
+
By default, the Google Mobile Ads SDK initializes app measurement and begins sending user-level event data to Google immediately when the app starts.
|
|
33
|
+
If your app will be used by users within the EEA, it is important you prevent app measurement until your first ad has been requested (after consent).
|
|
34
|
+
|
|
35
|
+
Within your projects `app.json` file, set the `delay_app_measurement_init` to `true` to delay app measurement:
|
|
36
|
+
|
|
37
|
+
```json
|
|
38
|
+
{
|
|
39
|
+
"react-native-google-mobile-ads": {
|
|
40
|
+
"android_app_id": "ca-app-pub-xxxxxxxx~xxxxxxxx",
|
|
41
|
+
"ios_app_id": "ca-app-pub-xxxxxxxx~xxxxxxxx",
|
|
42
|
+
"delay_app_measurement_init": true
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
```
|
|
46
|
+
|
|
47
|
+
Once set, rebuild your application:
|
|
48
|
+
|
|
49
|
+
```bash
|
|
50
|
+
# For iOS
|
|
51
|
+
npx react-native run-ios
|
|
52
|
+
|
|
53
|
+
# For Android
|
|
54
|
+
npx react-native run-android
|
|
55
|
+
```
|
|
56
|
+
|
|
57
|
+
### Requesting consent information
|
|
58
|
+
|
|
59
|
+
It is recommended you request consent information each time your application starts. The Consent SDK stores the users consent status
|
|
60
|
+
based on the state of your AdMob network. If the state changes (e.g. a new mediation provider is added) the SDK automatically
|
|
61
|
+
invalidates the consent status (setting is to "UNKNOWN").
|
|
62
|
+
|
|
63
|
+
The `AdsConsent` helper provides a promised based method to return the users consent status called `requestInfoUpdate`. This method
|
|
64
|
+
accepts an array of publisher IDs, which are used by the Consent SDK to determine the users consent status.
|
|
65
|
+
|
|
66
|
+
Your own publisher ID can be found on the [Google AdMob dashboard](https://apps.admob.com/v2/settings) under "Settings > Account Information":
|
|
67
|
+
|
|
68
|
+

|
|
69
|
+
|
|
70
|
+
To request consent, call the method as early as possible within your app before presenting any ads:
|
|
71
|
+
|
|
72
|
+
```js
|
|
73
|
+
import { AdsConsent } from 'react-native-google-mobile-ads';
|
|
74
|
+
|
|
75
|
+
const consentInfo = await AdsConsent.requestInfoUpdate(['pub-6189033257628123']);
|
|
76
|
+
```
|
|
77
|
+
|
|
78
|
+
The result of the method returns an `AdsConsentInfo` interface, which provides information about the users status and location:
|
|
79
|
+
|
|
80
|
+
- **status**: The status can be one of 3 outcomes:
|
|
81
|
+
- `UNKNOWN`: The user has not yet given consent, or has been invalidated since the last time they gave consent.
|
|
82
|
+
- `NON_PERSONALIZED`: The user gave consent to see non-personalized ads only.
|
|
83
|
+
- `PERSONALIZED`: The user gave consent to see personalized ads.
|
|
84
|
+
- **isRequestLocationInEeaOrUnknown**: A boolean value. If `true` the users location is within the EEA or is unknown.
|
|
85
|
+
|
|
86
|
+
The combination of status and location allows you to handle the next steps for requesting consent, if required:
|
|
87
|
+
|
|
88
|
+
1. If the users location is within the EEA or unknown, and their status is unknown, you must request consent before showing any ads.
|
|
89
|
+
2. If the users location is within the EEA or unknown, and their status is **not** unknown, you can show only the ad personalization they have requested.
|
|
90
|
+
3. If the users location is outside of the EEA, you do not have to give consent.
|
|
91
|
+
|
|
92
|
+
### Gathering user consent
|
|
93
|
+
|
|
94
|
+
Now we understand the consent status of the user, we can gather their consent (if required). This can be done in two ways:
|
|
95
|
+
|
|
96
|
+
1. Using a Google-rendered consent form.
|
|
97
|
+
2. Using a custom method.
|
|
98
|
+
|
|
99
|
+
If you are aware that users are under the age of consent in Europe, it is possible to set this using the `setTagForUnderAgeOfConsent`
|
|
100
|
+
method (TFUA). Once the setting is enabled, the Google-rendered consent form will fail to load. All ad requests that include
|
|
101
|
+
TFUA will be made ineligible for personalized advertising and remarketing. TFUA disables requests to third-party ad technology
|
|
102
|
+
providers, such as ad measurement pixels and third-party ad servers.
|
|
103
|
+
|
|
104
|
+
To remove this setting, pass `false` to the method.
|
|
105
|
+
|
|
106
|
+
#### 1. Google-rendered consent form
|
|
107
|
+
|
|
108
|
+
The Google-rendered consent form is a full-screen configurable form that displays over your app content.
|
|
109
|
+
You can configure the form to present the user with combinations of the following options:
|
|
110
|
+
|
|
111
|
+
- Consent to view personalized ads
|
|
112
|
+
- Consent to view non-personalized ads
|
|
113
|
+
- Use a paid version of the app instead of viewing ads
|
|
114
|
+
|
|
115
|
+
You should review the consent text carefully: what appears by default is a message that might be appropriate if you use
|
|
116
|
+
Google to monetize your app; but Google cannot provide legal advice on the consent text that is appropriate for you.
|
|
117
|
+
To update consent text of the Google-rendered consent form, modify the `consentform.html` file included in the Consent SDK as required.
|
|
118
|
+
|
|
119
|
+
> An [example of a Google-rendered](https://developers.google.com/admob/images/android_eu_consent_form.png) consent form.
|
|
120
|
+
|
|
121
|
+
To show the consent form, the `AdsConsent` helper provides a `showForm` method, which takes options to configure the form.
|
|
122
|
+
You must provide a privacy policy URL.
|
|
123
|
+
|
|
124
|
+
```js
|
|
125
|
+
import { AdsConsent, AdsConsentStatus } from 'react-native-google-mobile-ads';
|
|
126
|
+
|
|
127
|
+
const consentInfo = await AdsConsent.requestInfoUpdate(['pub-6189033257628123']);
|
|
128
|
+
|
|
129
|
+
if (
|
|
130
|
+
consentInfo.isRequestLocationInEeaOrUnknown &&
|
|
131
|
+
consentInfo.status === AdsConsentStatus.UNKNOWN
|
|
132
|
+
) {
|
|
133
|
+
const formResult = await AdsConsent.showForm({
|
|
134
|
+
privacyPolicy: 'https://invertase.io/privacy-policy',
|
|
135
|
+
withPersonalizedAds: true,
|
|
136
|
+
withNonPersonalizedAds: true,
|
|
137
|
+
withAdFree: true,
|
|
138
|
+
});
|
|
139
|
+
}
|
|
140
|
+
```
|
|
141
|
+
|
|
142
|
+
Once the user has selected their preference, the `formResult` contains their status and whether or not they prefer an
|
|
143
|
+
ad-free option of your application (if enabled):
|
|
144
|
+
|
|
145
|
+
```js
|
|
146
|
+
const formResult = await AdsConsent.showForm({
|
|
147
|
+
privacyPolicy: 'https://invertase.io/privacy-policy',
|
|
148
|
+
withPersonalizedAds: true,
|
|
149
|
+
withNonPersonalizedAds: true,
|
|
150
|
+
withAdFree: true,
|
|
151
|
+
});
|
|
152
|
+
|
|
153
|
+
if (formResult.userPrefersAdFree) {
|
|
154
|
+
// Handle the users request, e.g. redirect to a paid for version of the app
|
|
155
|
+
}
|
|
156
|
+
|
|
157
|
+
// The user requested non-personalized or personalized ads
|
|
158
|
+
const status = formResult.status;
|
|
159
|
+
```
|
|
160
|
+
|
|
161
|
+
The `formResult.status` provides feedback on whether the user consented to personalized ads, or non-personalized ads.
|
|
162
|
+
It is important that you forward this status onto all ad requests (see below).
|
|
163
|
+
|
|
164
|
+
> Do not persist the status. You could however store this locally in application state (e.g. React Context) and update the status on every app launch as it may change.
|
|
165
|
+
|
|
166
|
+
#### 2. Custom consent method
|
|
167
|
+
|
|
168
|
+
If you wish to implement your own consent flow, the `AdsConsent` helper provides the tools needed to accomplish this.
|
|
169
|
+
Depending on your requirements, a list of the enabled network mediation providers for the AdMob App ID can be returned and shown
|
|
170
|
+
to the user via the `getAdProviders` method:
|
|
171
|
+
|
|
172
|
+
```js
|
|
173
|
+
import { AdsConsent } from 'react-native-google-mobile-ads';
|
|
174
|
+
|
|
175
|
+
const providers = await AdsConsent.getAdProviders();
|
|
176
|
+
```
|
|
177
|
+
|
|
178
|
+
Each provider is an interface of `AdProvider`, containing information such as their company ID, company name and privacy policy URL.
|
|
179
|
+
Using this information you can request consent from your users.
|
|
180
|
+
|
|
181
|
+
Once consent has been returned, the Consent SDK needs to be aware of the custom user consent status. This can be forwarded on using the
|
|
182
|
+
`setStatus` method, for example:
|
|
183
|
+
|
|
184
|
+
```js
|
|
185
|
+
import { AdsConsent, AdsConsentStatus } from 'react-native-google-mobile-ads';
|
|
186
|
+
|
|
187
|
+
// After getting user consent...
|
|
188
|
+
await AdsConsent.setStatus(AdsConsentStatus.PERSONALIZED);
|
|
189
|
+
```
|
|
190
|
+
|
|
191
|
+
To invalidate the users consent status (e.g. if the providers list changes since their last consent), set the status back to
|
|
192
|
+
`UNKNOWN`. When your application next boots, you can get the users previous consent status using the `getStatus` method.
|
|
193
|
+
|
|
194
|
+
### Testing
|
|
195
|
+
|
|
196
|
+
When developing the consent flow, the behavior of the `AdsConsent` responses may not be reliable due to the environment
|
|
197
|
+
(e.g. using an emulator vs real device). It is possible to set a debug location to test the various responses from the
|
|
198
|
+
Consent SDK.
|
|
199
|
+
|
|
200
|
+
If using a real device, ensure you whitelist it using the device ID, which can be obtained from native logs or using a library
|
|
201
|
+
such as [react-native-device-info](https://github.com/react-native-community/react-native-device-info). Once found,
|
|
202
|
+
call the `addTestDevice(deviceId)` method.
|
|
203
|
+
|
|
204
|
+
> Emulators are automatically whitelisted.
|
|
205
|
+
|
|
206
|
+
To set a debug location, use the `setDebugGeography` method. It accepts 3 values:
|
|
207
|
+
|
|
208
|
+
- **DISABLED**: Removes any previous debug locations.
|
|
209
|
+
- **EEA**: Set the test device to be within the EEA.
|
|
210
|
+
- **NOT_EEA**: Set the test device to be outside of the EEA.
|
|
211
|
+
|
|
212
|
+
For example:
|
|
213
|
+
|
|
214
|
+
```js
|
|
215
|
+
import { AdsConsent, AdsConsentDebugGeography } from 'react-native-google-mobile-ads';
|
|
216
|
+
|
|
217
|
+
await AdsConsent.setDebugGeography(AdsConsentDebugGeography.EEA);
|
|
218
|
+
```
|
|
219
|
+
|
|
220
|
+
> Always ensure debug information is removed for production apps!
|
|
221
|
+
|
|
222
|
+
### Forwarding the consent status to ads
|
|
223
|
+
|
|
224
|
+
Assuming the user is within the EEA and has provided consent, their status needs to be forwarded to every ad request we
|
|
225
|
+
make in our application.
|
|
226
|
+
|
|
227
|
+
> If the user is within the EEA and has not given consent, do not display AdMob ads (even non-personalized).
|
|
228
|
+
|
|
229
|
+
Taking a Rewarded Video as an example, we can apply the users consent when our ad is loaded via the `RequestOptions`. For example:
|
|
230
|
+
|
|
231
|
+
```js
|
|
232
|
+
import { AdsConsent, RewardedAd } from 'react-native-google-mobile-ads';
|
|
233
|
+
|
|
234
|
+
const status = await AdsConsent.getStatus();
|
|
235
|
+
|
|
236
|
+
const rewardedAd = RewardedAd.createForAdRequest('AD_UNIT_ID', {
|
|
237
|
+
requestNonPersonalizedAdsOnly: status === AdsConsentStatus.NON_PERSONALIZED,
|
|
238
|
+
});
|
|
239
|
+
```
|
|
240
|
+
|
|
241
|
+
The requested ad URL via the SDK will send a request with an additional parameter `&npa=1`, which will return a
|
|
242
|
+
non-personalized ad.
|
|
243
|
+
|
|
244
|
+
### Troubleshooting
|
|
245
|
+
|
|
246
|
+
#### "Could not parse Event FE preflight response."
|
|
247
|
+
|
|
248
|
+
This is a common error which occurs on both Android & iOS when making a request to display a Google-rendered consent form. Unfortunately the reasoning for this error is generic, making it hard to debug. There are a number of steps to check which are usually the cause for this error:
|
|
249
|
+
|
|
250
|
+
- The AdMob App ID is incorrect: Ensure you have entered the correct ID into the `app.json` file under the `android_app_id` or `ios_app_id` key in the `react-native-google-mobile-ads` config.
|
|
251
|
+
- A publisher ID is incorrect: Ensure your entered publisher IDs are correct.
|
|
252
|
+
- The publisher ID needs to be available on the same account as your AdMob App ID.
|
|
253
|
+
- The user is outside of the EEA: If a user does not need to provide consent, the form request will error. Ensure you have checked the users status via `requestInfoUpdate`. If using an emulator, ensure you set a debug location via `setDebugGeography`.
|
|
254
|
+
- Your AdMob account is not valid:
|
|
255
|
+
- Your account is disabled: This can occur if Google notices you have duplicate accounts. They will email you about this, and block you from entering the dashboard.
|
|
256
|
+
- You have provided invalid payment information: If your account has no payment information set up, this seems to cause this error to trigger.
|
|
257
|
+
|
|
258
|
+
If you are still struggling to present the consent form, reach out to AdMob support to investigate your account status via https://support.google.com/admob
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
<?xml version="1.0" encoding="utf-8"?>
|
|
2
|
+
<!-- Generator: Adobe Illustrator 22.1.0, SVG Export Plug-In . SVG Version: 6.00 Build 0) -->
|
|
3
|
+
<svg version="1.1" id="Content" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" x="0px" y="0px"
|
|
4
|
+
width="192px" height="192px" viewBox="0 0 192 192" enable-background="new 0 0 192 192" xml:space="preserve">
|
|
5
|
+
<rect id="bounding_box_2_" fill="none" width="192" height="192"/>
|
|
6
|
+
<g id="logo_x5F_admob_x5F_192px">
|
|
7
|
+
<g id="icon_x5F_admob_x5F_192px_2_">
|
|
8
|
+
<path fill="#FBBC04" d="M92.01,8.26C93.28,8,98.31,8.01,99.51,8c34.25-0.27,81.75,28.87,84.49,84.28v69.18
|
|
9
|
+
c0,12.45-10.28,22.54-22.77,22.54c-9,0-21.23-11.53-21.23-22.5V92.32c-1.27-18.26-16.07-38.81-40.99-40.36
|
|
10
|
+
c-1.54-0.1-5.04-0.16-7.01,0.1"/>
|
|
11
|
+
<path fill="#4285F4" d="M183.98,162c0,12.15-9.85,22-22,22S140,174.15,140,162c0-12.15,9.83-22,21.98-22S183.98,149.85,183.98,162
|
|
12
|
+
z"/>
|
|
13
|
+
<path fill="#EA4335" d="M93.2,183.24c12.6,0,22.81-10.02,22.81-22.37c0-12.36-10.46-21.33-23.05-21.33
|
|
14
|
+
c-0.08,0-0.16,0.01-0.24,0.01c-21.66-1.5-41.92-20.57-40.44-46.71c0,0,0.01-0.13,0.03-0.42c1.25-20.51,18.75-39.12,40.9-40.4l0,0
|
|
15
|
+
c0,0,0,0,0,0c12.6,0,22.81-9.04,22.81-21.39S105.8,8.25,93.2,8.25c-0.51,0-1.02-0.03-1.53,0C53.46,9.58,8.46,41.37,8.01,95.4v0.33
|
|
16
|
+
c0,54.83,48.09,87.5,83.93,87.5H93.2z"/>
|
|
17
|
+
</g>
|
|
18
|
+
</g>
|
|
19
|
+
</svg>
|
package/docs/index.mdx
ADDED
|
@@ -0,0 +1,168 @@
|
|
|
1
|
+
# Installation
|
|
2
|
+
|
|
3
|
+
```bash
|
|
4
|
+
# Install the admob module
|
|
5
|
+
yarn add react-native-google-mobile-ads
|
|
6
|
+
```
|
|
7
|
+
|
|
8
|
+
> On Android, before releasing your app, you must select _Yes, my app contains ads_ in the Google Play Store, Policy, App content, Manage under Ads.
|
|
9
|
+
|
|
10
|
+
# What does it do
|
|
11
|
+
|
|
12
|
+
The AdMob module allows you to display adverts to your users. All adverts are served over the Google AdMob network, meaning
|
|
13
|
+
a [Google AdMob account](https://apps.admob.com) is required.
|
|
14
|
+
|
|
15
|
+
<YouTube id="9qCxo0D-Sak" />
|
|
16
|
+
|
|
17
|
+
The module supports three types of Ads:
|
|
18
|
+
|
|
19
|
+
1. Full screen [App Open Ads](/displaying-ads#app-open-ads).
|
|
20
|
+
2. Full screen [Interstitial Ads](/displaying-ads#interstitial-ads).
|
|
21
|
+
3. Full screen [Rewarded Ads](/displaying-ads#rewarded-ads).
|
|
22
|
+
4. Component based [Banner Ads](/displaying-ads#banner-ads).
|
|
23
|
+
|
|
24
|
+
# Getting Started
|
|
25
|
+
|
|
26
|
+
A number of steps must be taken and considered before you start serving adverts to your users:
|
|
27
|
+
|
|
28
|
+
- [Installation](#installation)
|
|
29
|
+
- [Getting Started](#getting-started)
|
|
30
|
+
- [Setting up Google AdMob](#setting-up-google-admob)
|
|
31
|
+
- [Configure outbound requests](#configure-outbound-requests)
|
|
32
|
+
- [European User Consent](#european-user-consent)
|
|
33
|
+
- [Test ads](#test-ads)
|
|
34
|
+
- [Next Steps](#next-steps)
|
|
35
|
+
|
|
36
|
+
## Setting up Google AdMob
|
|
37
|
+
|
|
38
|
+
Before you are able to display ads to your users, you must have a [Google AdMob account](https://apps.admob.com). Under the
|
|
39
|
+
"Apps" menu item, create or choose an existing Android/iOS app. Each app platform exposes a unique account ID which needs to
|
|
40
|
+
be added to the project.
|
|
41
|
+
|
|
42
|
+
> Attempting to build your app without a valid App ID may cause a crash during build.
|
|
43
|
+
|
|
44
|
+
Under the "App settings" menu item, you can find the "App ID":
|
|
45
|
+
|
|
46
|
+

|
|
47
|
+
|
|
48
|
+
Within the root of your React Native project, open the `app.json` file and add the
|
|
49
|
+
`android_app_id` & `ios_app_id` keys with the IDs from the Google AdMob console:
|
|
50
|
+
|
|
51
|
+
```json
|
|
52
|
+
// <project-root>/app.json
|
|
53
|
+
{
|
|
54
|
+
"react-native-google-mobile-ads": {
|
|
55
|
+
"android_app_id": "ca-app-pub-xxxxxxxx~xxxxxxxx",
|
|
56
|
+
"ios_app_id": "ca-app-pub-xxxxxxxx~xxxxxxxx"
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
```
|
|
60
|
+
|
|
61
|
+
For the changes to take effect, rebuild your project:
|
|
62
|
+
|
|
63
|
+
```bash
|
|
64
|
+
# For iOS
|
|
65
|
+
cd ios/ && pod install
|
|
66
|
+
npx react-native run-ios
|
|
67
|
+
|
|
68
|
+
# For Android
|
|
69
|
+
npx react-native run-android
|
|
70
|
+
```
|
|
71
|
+
|
|
72
|
+
## Configure outbound requests
|
|
73
|
+
|
|
74
|
+
If the default ad settings are not correct for your app, you can provide settings that will apply to all ad requests.
|
|
75
|
+
|
|
76
|
+
For example, if the application targets children then you must configure the outbound requests to only
|
|
77
|
+
receive content suitable for children before loading any adverts.
|
|
78
|
+
|
|
79
|
+
If you need to set a custom request configuration, you must call the `setRequestConfiguration` method before initializing the Google Mobile Ads SDK:
|
|
80
|
+
|
|
81
|
+
```js
|
|
82
|
+
import mobileAds, { MaxAdContentRating } from 'react-native-google-mobile-ads';
|
|
83
|
+
|
|
84
|
+
mobileAds()
|
|
85
|
+
.setRequestConfiguration({
|
|
86
|
+
// Update all future requests suitable for parental guidance
|
|
87
|
+
maxAdContentRating: MaxAdContentRating.PG,
|
|
88
|
+
|
|
89
|
+
// Indicates that you want your content treated as child-directed for purposes of COPPA.
|
|
90
|
+
tagForChildDirectedTreatment: true,
|
|
91
|
+
|
|
92
|
+
// Indicates that you want the ad request to be handled in a
|
|
93
|
+
// manner suitable for users under the age of consent.
|
|
94
|
+
tagForUnderAgeOfConsent: true,
|
|
95
|
+
|
|
96
|
+
// An array of test device IDs to whitelist.
|
|
97
|
+
testDeviceIdentifiers: ["EMULATOR"];
|
|
98
|
+
})
|
|
99
|
+
.then(() => {
|
|
100
|
+
// Request config successfully set!
|
|
101
|
+
});
|
|
102
|
+
```
|
|
103
|
+
|
|
104
|
+
To learn more about the request configuration settings, view the [`RequestConfiguration`](/reference/admob/requestconfiguration) documentation.
|
|
105
|
+
|
|
106
|
+
## Initialize the Google Mobile Ads SDK
|
|
107
|
+
|
|
108
|
+
Before loading ads, have your app initialize the Google Mobile Ads SDK by calling `initialize` which initializes the SDK and returns a promise once initialization is complete (or after a 30-second timeout).
|
|
109
|
+
This needs to be done only once, ideally at app launch.
|
|
110
|
+
|
|
111
|
+
> ⚠️ **Warning:** Ads may be preloaded by the Mobile Ads SDK or mediation partner SDKs upon calling `initialize`.
|
|
112
|
+
If you need to obtain consent from users in the European Economic Area (EEA), set any request-specific flags (such as tagForChildDirectedTreatment), or otherwise take action before loading ads, ensure you do so before initializing the Mobile Ads SDK.
|
|
113
|
+
|
|
114
|
+
```js
|
|
115
|
+
import mobileAds from 'react-native-google-mobile-ads';
|
|
116
|
+
|
|
117
|
+
mobileAds()
|
|
118
|
+
.initialize()
|
|
119
|
+
.then((adapterStatuses) => {
|
|
120
|
+
// Initialization complete!
|
|
121
|
+
});
|
|
122
|
+
```
|
|
123
|
+
|
|
124
|
+
If you are using mediation, you may wish to wait until the promise is settled before loading ads, as this will ensure that all mediation adapters are initialized.
|
|
125
|
+
|
|
126
|
+
## European User Consent
|
|
127
|
+
|
|
128
|
+
Out of the box, AdMob does not handle any related regulations which you may need to enforce on your application.
|
|
129
|
+
It is up to the developer to implement and handle this on a user-by-user basis. You must consent to EEA users
|
|
130
|
+
being served both personalized and non-personalized adverts before showing them. For more information, see
|
|
131
|
+
[Requesting Consent from European Users](https://developers.google.com/admob/android/eu-consent).
|
|
132
|
+
|
|
133
|
+
The AdMob module provides a `AdConsent` helper to help developers quickly implement consent flows within their application.
|
|
134
|
+
See the [European User Consent page](/european-user-consent) for full examples of how to integrate the helper into your application.
|
|
135
|
+
|
|
136
|
+
## Test ads
|
|
137
|
+
|
|
138
|
+
Whilst developing your app with AdMob, you'll want to make sure you use test ads rather than production ads from your
|
|
139
|
+
Google AdMob account - otherwise your account may be disabled!
|
|
140
|
+
|
|
141
|
+
Although usage of different advert types is explained later, when creating your adverts the "Ad Unit ID" being used whilst
|
|
142
|
+
testing can be set to a testing ID. The code snippet below shows how to initialize each advert type with a test ID:
|
|
143
|
+
|
|
144
|
+
```jsx
|
|
145
|
+
import { AppOpenAd, InterstitialAd, RewardedAd, BannerAd, TestIds } from 'react-native-google-mobile-ads';
|
|
146
|
+
|
|
147
|
+
# App Open
|
|
148
|
+
AppOpenAd.createForAdRequest(TestIds.APP_OPEN);
|
|
149
|
+
|
|
150
|
+
# Interstitial
|
|
151
|
+
InterstitialAd.createForAdRequest(TestIds.INTERSTITIAL);
|
|
152
|
+
|
|
153
|
+
# Rewarded
|
|
154
|
+
RewardedAd.createForAdRequest(TestIds.REWARDED);
|
|
155
|
+
|
|
156
|
+
# Banners
|
|
157
|
+
<BannerAd unitId={TestIds.BANNER} />
|
|
158
|
+
```
|
|
159
|
+
|
|
160
|
+
# Next Steps
|
|
161
|
+
|
|
162
|
+
Now the basics of setting up and configuring AdMob have been explained, we can go ahead and start to display different
|
|
163
|
+
adverts to our users. The AdMob module provides integration with three different types:
|
|
164
|
+
|
|
165
|
+
- [App Open Ads](/displaying-ads#app-open-ads)
|
|
166
|
+
- [Interstitial Ads](/displaying-ads#interstitial-ads)
|
|
167
|
+
- [Rewarded Ads](/displaying-ads#rewarded-ads)
|
|
168
|
+
- [Banner Ads](/displaying-ads#banner-ads)
|
package/docs.json
ADDED
|
@@ -0,0 +1,29 @@
|
|
|
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 <Foundation/Foundation.h>
|
|
19
|
+
#import <React/RCTBridgeModule.h>
|
|
20
|
+
#import "RNGoogleMobileAdsFullScreenContentDelegate.h"
|
|
21
|
+
|
|
22
|
+
@import GoogleMobileAds;
|
|
23
|
+
|
|
24
|
+
@interface RNGoogleMobileAdsAppOpenModule : NSObject <RCTBridgeModule>
|
|
25
|
+
|
|
26
|
+
@property(strong, nonatomic) GADAppOpenAd* appOpenAd;
|
|
27
|
+
@property(strong, nonatomic) RNGoogleMobileAdsFullScreenContentDelegate* appOpenDelegate;
|
|
28
|
+
|
|
29
|
+
@end
|
|
@@ -0,0 +1,98 @@
|
|
|
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 <React/RCTUtils.h>
|
|
19
|
+
|
|
20
|
+
#import "RNGoogleMobileAdsAppOpenModule.h"
|
|
21
|
+
#import "RNGoogleMobileAdsCommon.h"
|
|
22
|
+
#import "common/RNSharedUtils.h"
|
|
23
|
+
|
|
24
|
+
@implementation RNGoogleMobileAdsAppOpenModule
|
|
25
|
+
#pragma mark -
|
|
26
|
+
#pragma mark Module Setup
|
|
27
|
+
|
|
28
|
+
RCT_EXPORT_MODULE();
|
|
29
|
+
|
|
30
|
+
- (dispatch_queue_t)methodQueue {
|
|
31
|
+
return dispatch_get_main_queue();
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
+ (BOOL)requiresMainQueueSetup {
|
|
35
|
+
return YES;
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
// #pragma mark -
|
|
39
|
+
// #pragma mark Google Mobile Ads Methods
|
|
40
|
+
|
|
41
|
+
RCT_EXPORT_METHOD(appOpenLoad
|
|
42
|
+
: (nonnull NSNumber *)requestId
|
|
43
|
+
: (NSString *)adUnitId
|
|
44
|
+
: (NSDictionary *)adRequestOptions) {
|
|
45
|
+
self.appOpenAd = nil;
|
|
46
|
+
GADRequest *request = [GADRequest request];
|
|
47
|
+
[GADAppOpenAd loadWithAdUnitID:adUnitId
|
|
48
|
+
request:request
|
|
49
|
+
orientation:UIInterfaceOrientationPortrait
|
|
50
|
+
completionHandler:^(GADAppOpenAd *_Nullable appOpenAd, NSError *_Nullable error) {
|
|
51
|
+
if (error) {
|
|
52
|
+
NSDictionary *codeAndMessage =
|
|
53
|
+
[RNGoogleMobileAdsCommon getCodeAndMessageFromAdError:error];
|
|
54
|
+
[RNGoogleMobileAdsCommon sendAdEvent:GOOGLE_MOBILE_ADS_EVENT_APP_OPEN
|
|
55
|
+
requestId:requestId
|
|
56
|
+
type:GOOGLE_MOBILE_ADS_EVENT_ERROR
|
|
57
|
+
adUnitId:adUnitId
|
|
58
|
+
error:codeAndMessage
|
|
59
|
+
data:nil];
|
|
60
|
+
return;
|
|
61
|
+
}
|
|
62
|
+
self.appOpenAd = appOpenAd;
|
|
63
|
+
RNGoogleMobileAdsFullScreenContentDelegate *fullScreenContentDelegate =
|
|
64
|
+
[[RNGoogleMobileAdsFullScreenContentDelegate alloc] init];
|
|
65
|
+
fullScreenContentDelegate.sendAdEvent = GOOGLE_MOBILE_ADS_EVENT_APP_OPEN;
|
|
66
|
+
fullScreenContentDelegate.requestId = requestId;
|
|
67
|
+
fullScreenContentDelegate.adUnitId = adUnitId;
|
|
68
|
+
self.appOpenAd.fullScreenContentDelegate = fullScreenContentDelegate;
|
|
69
|
+
self.appOpenDelegate = fullScreenContentDelegate;
|
|
70
|
+
[RNGoogleMobileAdsCommon sendAdEvent:GOOGLE_MOBILE_ADS_EVENT_APP_OPEN
|
|
71
|
+
requestId:requestId
|
|
72
|
+
type:GOOGLE_MOBILE_ADS_EVENT_LOADED
|
|
73
|
+
adUnitId:adUnitId
|
|
74
|
+
error:nil
|
|
75
|
+
data:nil];
|
|
76
|
+
}];
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
RCT_EXPORT_METHOD(appOpenShow
|
|
80
|
+
: (nonnull NSNumber *)requestId
|
|
81
|
+
: (NSDictionary *)showOptions
|
|
82
|
+
: (RCTPromiseResolveBlock)resolve
|
|
83
|
+
: (RCTPromiseRejectBlock)reject) {
|
|
84
|
+
if (self.appOpenAd) {
|
|
85
|
+
[self.appOpenAd
|
|
86
|
+
presentFromRootViewController:RCTSharedApplication().delegate.window.rootViewController];
|
|
87
|
+
resolve([NSNull null]);
|
|
88
|
+
} else {
|
|
89
|
+
[RNSharedUtils
|
|
90
|
+
rejectPromiseWithUserInfo:reject
|
|
91
|
+
userInfo:[@{
|
|
92
|
+
@"code" : @"not-ready",
|
|
93
|
+
@"message" : @"App Open ad attempted to show but was not ready.",
|
|
94
|
+
} mutableCopy]];
|
|
95
|
+
}
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
@end
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
//
|
|
2
|
+
/**
|
|
3
|
+
* Copyright (c) 2016-present Invertase Limited & Contributors
|
|
4
|
+
*
|
|
5
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
6
|
+
* you may not use this library except in compliance with the License.
|
|
7
|
+
* You may obtain a copy of the License at
|
|
8
|
+
*
|
|
9
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
10
|
+
*
|
|
11
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
12
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
13
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
14
|
+
* See the License for the specific language governing permissions and
|
|
15
|
+
* limitations under the License.
|
|
16
|
+
*
|
|
17
|
+
*/
|
|
18
|
+
|
|
19
|
+
#import <React/RCTViewManager.h>
|
|
20
|
+
|
|
21
|
+
@interface RNGoogleMobileAdsBannerViewManager : RCTViewManager
|
|
22
|
+
|
|
23
|
+
@end
|