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
package/package.json
ADDED
|
@@ -0,0 +1,143 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "react-native-google-mobile-ads",
|
|
3
|
+
"version": "4.1.0",
|
|
4
|
+
"author": "Invertase <oss@invertase.io> (http://invertase.io)",
|
|
5
|
+
"description": "React Native Google Mobile Ads is an easy way to monetize mobile apps with targeted, in-app advertising.",
|
|
6
|
+
"main": "lib/commonjs/index.js",
|
|
7
|
+
"module": "lib/module/index.js",
|
|
8
|
+
"react-native": "src/index.ts",
|
|
9
|
+
"types": "lib/typescript/index.d.ts",
|
|
10
|
+
"repository": {
|
|
11
|
+
"type": "git",
|
|
12
|
+
"url": "https://github.com/invertase/react-native-google-mobile-ads"
|
|
13
|
+
},
|
|
14
|
+
"license": "Apache-2.0",
|
|
15
|
+
"keywords": [
|
|
16
|
+
"react",
|
|
17
|
+
"react-native",
|
|
18
|
+
"admob",
|
|
19
|
+
"mobile ads",
|
|
20
|
+
"google ads",
|
|
21
|
+
"gdpr",
|
|
22
|
+
"banner ad",
|
|
23
|
+
"rewarded ad",
|
|
24
|
+
"interstitial",
|
|
25
|
+
"ad consent"
|
|
26
|
+
],
|
|
27
|
+
"files": [
|
|
28
|
+
"/__tests__/",
|
|
29
|
+
"/android/",
|
|
30
|
+
"/docs/",
|
|
31
|
+
"/ios/",
|
|
32
|
+
"/lib/",
|
|
33
|
+
"/src/",
|
|
34
|
+
"/docs.json",
|
|
35
|
+
"/RNGoogleMobileAds.podspec",
|
|
36
|
+
"/babel.config.js",
|
|
37
|
+
"/jest.config.js",
|
|
38
|
+
"/jest.setup.ts",
|
|
39
|
+
"/ios_config.sh",
|
|
40
|
+
"/react-native.config.js"
|
|
41
|
+
],
|
|
42
|
+
"sdkVersions": {
|
|
43
|
+
"ios": {
|
|
44
|
+
"googleAds": "8.13.0"
|
|
45
|
+
},
|
|
46
|
+
"android": {
|
|
47
|
+
"minSdk": 16,
|
|
48
|
+
"targetSdk": 30,
|
|
49
|
+
"compileSdk": 31,
|
|
50
|
+
"buildTools": "31.0.0",
|
|
51
|
+
"googleAds": "19.8.0"
|
|
52
|
+
}
|
|
53
|
+
},
|
|
54
|
+
"react-native-builder-bob": {
|
|
55
|
+
"source": "src",
|
|
56
|
+
"output": "lib",
|
|
57
|
+
"targets": [
|
|
58
|
+
"commonjs",
|
|
59
|
+
"module",
|
|
60
|
+
"typescript"
|
|
61
|
+
]
|
|
62
|
+
},
|
|
63
|
+
"scripts": {
|
|
64
|
+
"prepare": "yarn build",
|
|
65
|
+
"build": "genversion --es6 --semi src/version.ts && bob build",
|
|
66
|
+
"build:clean": "rimraf android/build && rimraf ios/build && rimraf lib",
|
|
67
|
+
"lint:code": "yarn lint:js && yarn lint:android && yarn lint:ios:check",
|
|
68
|
+
"lint:js": "eslint src/ --ext .js,.jsx,.ts,.tsx --max-warnings=0",
|
|
69
|
+
"lint:android": "google-java-format --set-exit-if-changed --replace --glob=\"android/**/*.java\"",
|
|
70
|
+
"lint:ios:check": "clang-format --glob=\"ios/**/*.{h,cpp,m,mm}\" --style=Google -n -Werror",
|
|
71
|
+
"lint:ios:fix": "clang-format -i --glob=\"ios/**/*.{h,cpp,m,mm}\" --style=Google",
|
|
72
|
+
"lint:markdown:check": "prettier --check \"docs/**/*.md[x]\"",
|
|
73
|
+
"lint:markdown:fix": "prettier --write \"docs/**/*.md\"",
|
|
74
|
+
"lint:report": "eslint --output-file=eslint-report.json --format=json . --ext .js,.jsx,.ts,.tsx",
|
|
75
|
+
"lint:spellcheck": "spellchecker --quiet --files=\"docs/**/*.md\" --dictionaries=\"./.spellcheck.dict.txt\" --reports=\"spelling.json\" --plugins spell indefinite-article repeated-words syntax-mentions syntax-urls frontmatter",
|
|
76
|
+
"tsc:compile": "tsc --project . --noEmit",
|
|
77
|
+
"lint": "yarn lint:code && yarn tsc:compile",
|
|
78
|
+
"tests:jest": "jest",
|
|
79
|
+
"tests:jest-watch": "jest --watch",
|
|
80
|
+
"tests:jest-coverage": "jest --coverage",
|
|
81
|
+
"tests:packager": "cd example && yarn react-native start",
|
|
82
|
+
"tests:packager:reset-cache": "cd example && yarn react-native start --reset-cache",
|
|
83
|
+
"tests:android:build": "cd example && yarn detox build --configuration android.emu.debug",
|
|
84
|
+
"tests:android:build-release": "cd example && yarn detox build --configuration android.emu.release",
|
|
85
|
+
"tests:android:test": "cd example && yarn detox test --configuration android.emu.debug --loglevel trace",
|
|
86
|
+
"tests:android:test:debug": "cd example && yarn detox test --configuration android.emu.debug --inspect",
|
|
87
|
+
"tests:android:test-reuse": "cd example && yarn detox test --configuration android.emu.debug --reuse",
|
|
88
|
+
"tests:android:test-cover": "cd example && ./node_modules/.bin/nyc yarn detox test --loglevel trace --configuration android.emu.debug",
|
|
89
|
+
"tests:android:test-cover-reuse": "cd example && ./node_modules/.bin/nyc yarn detox test --configuration android.emu.debug --reuse",
|
|
90
|
+
"tests:ios:build": "cd example && yarn detox build --configuration ios.sim.debug",
|
|
91
|
+
"tests:ios:build-release": "cd example && yarn detox build --configuration ios.sim.release",
|
|
92
|
+
"tests:ios:test": "cd example && yarn detox test --configuration ios.sim.debug --loglevel warn",
|
|
93
|
+
"tests:ios:test:debug": "cd example && yarn detox test --configuration ios.sim.debug --loglevel warn --inspect",
|
|
94
|
+
"tests:ios:test-reuse": "cd example && yarn detox test --configuration ios.sim.debug --reuse --loglevel warn",
|
|
95
|
+
"tests:ios:test-cover": "cd example && ./node_modules/.bin/nyc yarn detox test --configuration ios.sim.debug",
|
|
96
|
+
"tests:ios:test-cover-reuse": "cd example && node_modules/.bin/nyc yarn detox test --configuration ios.sim.debug --reuse --loglevel warn",
|
|
97
|
+
"tests:ios:pod:install": "cd example && cd ios && rm -rf example.xcworkspace && rm -f Podfile.lock && pod install --repo-update && cd .."
|
|
98
|
+
},
|
|
99
|
+
"devDependencies": {
|
|
100
|
+
"@babel/core": "^7.16.0",
|
|
101
|
+
"@babel/preset-env": "^7.16.4",
|
|
102
|
+
"@semantic-release/changelog": "^6.0.1",
|
|
103
|
+
"@semantic-release/commit-analyzer": "^9.0.2",
|
|
104
|
+
"@semantic-release/git": "^10.0.1",
|
|
105
|
+
"@semantic-release/github": "^8.0.2",
|
|
106
|
+
"@semantic-release/npm": "^8.0.3",
|
|
107
|
+
"@semantic-release/release-notes-generator": "^10.0.3",
|
|
108
|
+
"@types/jest": "^27.0.3",
|
|
109
|
+
"@types/node": "^16.11.12",
|
|
110
|
+
"@types/react": "^17.0.37",
|
|
111
|
+
"@types/react-native": "^0.66.8",
|
|
112
|
+
"@typescript-eslint/eslint-plugin": "^5.6.0",
|
|
113
|
+
"@typescript-eslint/parser": "^5.6.0",
|
|
114
|
+
"babel-jest": "^27.4.2",
|
|
115
|
+
"clang-format": "^1.6.0",
|
|
116
|
+
"codecov": "^3.8.3",
|
|
117
|
+
"conventional-changelog-cli": "^2.0.34",
|
|
118
|
+
"eslint": "^8.4.1",
|
|
119
|
+
"eslint-config-prettier": "^8.3.0",
|
|
120
|
+
"eslint-plugin-jest": "^25.3.0",
|
|
121
|
+
"eslint-plugin-mocha": "^10.0.0",
|
|
122
|
+
"eslint-plugin-prettier": "^4.0.0",
|
|
123
|
+
"eslint-plugin-react": "^7.27.1",
|
|
124
|
+
"genversion": "^3.0.2",
|
|
125
|
+
"google-java-format": "^1.0.1",
|
|
126
|
+
"inquirer": "^8.2.0",
|
|
127
|
+
"jest": "^27.4.3",
|
|
128
|
+
"lerna": "4.0.0",
|
|
129
|
+
"prettier": "^2.5.1",
|
|
130
|
+
"react": "^17.0.2",
|
|
131
|
+
"react-native": "0.66.3",
|
|
132
|
+
"react-native-builder-bob": "^0.18.2",
|
|
133
|
+
"rimraf": "^3.0.2",
|
|
134
|
+
"semantic-release": "^18.0.1",
|
|
135
|
+
"shelljs": "^0.8.3",
|
|
136
|
+
"ts-jest": "^27.1.1",
|
|
137
|
+
"ts-node": "^10.4.0",
|
|
138
|
+
"typescript": "^4.5.2"
|
|
139
|
+
},
|
|
140
|
+
"publishConfig": {
|
|
141
|
+
"access": "public"
|
|
142
|
+
}
|
|
143
|
+
}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
module.exports = {
|
|
2
|
+
dependency: {
|
|
3
|
+
platforms: {
|
|
4
|
+
android: {
|
|
5
|
+
packageImportPath: 'import io.invertase.googlemobileads.ReactNativeGoogleMobileAdsPackage;',
|
|
6
|
+
},
|
|
7
|
+
ios: {
|
|
8
|
+
scriptPhases: [
|
|
9
|
+
{
|
|
10
|
+
name: '[RNGoogleMobileAds] Configuration',
|
|
11
|
+
path: './ios_config.sh',
|
|
12
|
+
execution_position: 'after_compile',
|
|
13
|
+
input_files: ['$(BUILT_PRODUCTS_DIR)/$(INFOPLIST_PATH)'],
|
|
14
|
+
},
|
|
15
|
+
],
|
|
16
|
+
},
|
|
17
|
+
},
|
|
18
|
+
},
|
|
19
|
+
};
|
|
@@ -0,0 +1,68 @@
|
|
|
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 enum AdEventType {
|
|
19
|
+
/**
|
|
20
|
+
* When an ad has loaded. At this point, the ad is ready to be shown to the user.
|
|
21
|
+
*
|
|
22
|
+
* #### Example
|
|
23
|
+
*
|
|
24
|
+
* ```js
|
|
25
|
+
* import { AdEventType } from 'react-native-google-mobile-ads';
|
|
26
|
+
*
|
|
27
|
+
* advert.onAdEvent((type,error,data) => {
|
|
28
|
+
* if (type === AdEventType.LOADED) {
|
|
29
|
+
* advert.show();
|
|
30
|
+
* }
|
|
31
|
+
* });
|
|
32
|
+
* ```
|
|
33
|
+
*/
|
|
34
|
+
LOADED = 'loaded',
|
|
35
|
+
|
|
36
|
+
/**
|
|
37
|
+
* The ad has thrown an error. See the error parameter the listener callback for more information.
|
|
38
|
+
*
|
|
39
|
+
* #### Example
|
|
40
|
+
*
|
|
41
|
+
* ```js
|
|
42
|
+
* import { AdEventType } from 'react-native-google-mobile-ads';
|
|
43
|
+
*
|
|
44
|
+
* advert.onAdEvent((type, error, data) => {
|
|
45
|
+
* if (type === AdEventType.ERROR) {
|
|
46
|
+
* console.log('Ad error:', error);
|
|
47
|
+
* }
|
|
48
|
+
* });
|
|
49
|
+
* ```
|
|
50
|
+
*/
|
|
51
|
+
ERROR = 'error',
|
|
52
|
+
|
|
53
|
+
/**
|
|
54
|
+
* The ad opened and is currently visible to the user. This event is fired after the `show()`
|
|
55
|
+
* method has been called.
|
|
56
|
+
*/
|
|
57
|
+
OPENED = 'opened',
|
|
58
|
+
|
|
59
|
+
/**
|
|
60
|
+
* The user clicked the advert.
|
|
61
|
+
*/
|
|
62
|
+
CLICKED = 'clicked',
|
|
63
|
+
|
|
64
|
+
/**
|
|
65
|
+
* The user closed the ad and has returned back to your application.
|
|
66
|
+
*/
|
|
67
|
+
CLOSED = 'closed',
|
|
68
|
+
}
|
|
@@ -0,0 +1,191 @@
|
|
|
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 {
|
|
19
|
+
hasOwnProperty,
|
|
20
|
+
isArray,
|
|
21
|
+
isBoolean,
|
|
22
|
+
isObject,
|
|
23
|
+
isString,
|
|
24
|
+
isUndefined,
|
|
25
|
+
isValidUrl,
|
|
26
|
+
} from './common';
|
|
27
|
+
import { NativeModules } from 'react-native';
|
|
28
|
+
import { AdsConsentDebugGeography } from './AdsConsentDebugGeography';
|
|
29
|
+
import { AdsConsentStatus } from './AdsConsentStatus';
|
|
30
|
+
import { AdsConsentInterface } from './types/AdsConsent.interface';
|
|
31
|
+
|
|
32
|
+
const native = NativeModules.RNGoogleAdsConsentModule;
|
|
33
|
+
|
|
34
|
+
export const AdsConsent: AdsConsentInterface = {
|
|
35
|
+
/**
|
|
36
|
+
*
|
|
37
|
+
* @param publisherIds
|
|
38
|
+
* @returns {*}
|
|
39
|
+
*/
|
|
40
|
+
requestInfoUpdate(publisherIds) {
|
|
41
|
+
if (!isArray(publisherIds)) {
|
|
42
|
+
throw new Error(
|
|
43
|
+
"AdsConsent.requestInfoUpdate(*) 'publisherIds' expected an array of string values.",
|
|
44
|
+
);
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
if (publisherIds.length === 0) {
|
|
48
|
+
throw new Error(
|
|
49
|
+
"AdsConsent.requestInfoUpdate(*) 'publisherIds' list of publisher IDs cannot be empty.",
|
|
50
|
+
);
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
for (let i = 0; i < publisherIds.length; i++) {
|
|
54
|
+
if (!isString(publisherIds[i])) {
|
|
55
|
+
throw new Error(
|
|
56
|
+
`AdsConsent.requestInfoUpdate(*) 'publisherIds[${i}]' expected a string value.`,
|
|
57
|
+
);
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
return native.requestInfoUpdate(publisherIds);
|
|
62
|
+
},
|
|
63
|
+
|
|
64
|
+
/**
|
|
65
|
+
*
|
|
66
|
+
* @param options
|
|
67
|
+
* @returns {*}
|
|
68
|
+
*/
|
|
69
|
+
showForm(options) {
|
|
70
|
+
if (!isUndefined(options) && !isObject(options)) {
|
|
71
|
+
throw new Error("AdsConsent.showForm(*) 'options' expected an object value.");
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
if (!isValidUrl(options.privacyPolicy)) {
|
|
75
|
+
throw new Error(
|
|
76
|
+
"AdsConsent.showForm(*) 'options.privacyPolicy' expected a valid HTTP or HTTPS URL.",
|
|
77
|
+
);
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
if (hasOwnProperty(options, 'withPersonalizedAds') && !isBoolean(options.withPersonalizedAds)) {
|
|
81
|
+
throw new Error(
|
|
82
|
+
"AdsConsent.showForm(*) 'options.withPersonalizedAds' expected a boolean value.",
|
|
83
|
+
);
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
if (
|
|
87
|
+
hasOwnProperty(options, 'withNonPersonalizedAds') &&
|
|
88
|
+
!isBoolean(options.withNonPersonalizedAds)
|
|
89
|
+
) {
|
|
90
|
+
throw new Error(
|
|
91
|
+
"AdsConsent.showForm(*) 'options.withNonPersonalizedAds' expected a boolean value.",
|
|
92
|
+
);
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
if (hasOwnProperty(options, 'withAdFree') && !isBoolean(options.withAdFree)) {
|
|
96
|
+
throw new Error("AdsConsent.showForm(*) 'options.withAdFree' expected a boolean value.");
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
if (!options.withPersonalizedAds && !options.withNonPersonalizedAds && !options.withAdFree) {
|
|
100
|
+
throw new Error(
|
|
101
|
+
"AdsConsent.showForm(*) 'options' form requires at least one option to be enabled.",
|
|
102
|
+
);
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
return native.showForm(options);
|
|
106
|
+
},
|
|
107
|
+
|
|
108
|
+
/**
|
|
109
|
+
*
|
|
110
|
+
*/
|
|
111
|
+
getAdProviders() {
|
|
112
|
+
return native.getAdProviders();
|
|
113
|
+
},
|
|
114
|
+
|
|
115
|
+
/**
|
|
116
|
+
*
|
|
117
|
+
* @param geography
|
|
118
|
+
*/
|
|
119
|
+
setDebugGeography(geography) {
|
|
120
|
+
if (
|
|
121
|
+
geography !== AdsConsentDebugGeography.DISABLED &&
|
|
122
|
+
geography !== AdsConsentDebugGeography.EEA &&
|
|
123
|
+
geography !== AdsConsentDebugGeography.NOT_EEA
|
|
124
|
+
) {
|
|
125
|
+
throw new Error(
|
|
126
|
+
"AdsConsent.setDebugGeography(*) 'geography' expected one of AdsConsentDebugGeography.DISABLED, AdsConsentDebugGeography.EEA or AdsConsentDebugGeography.NOT_EEA.",
|
|
127
|
+
);
|
|
128
|
+
}
|
|
129
|
+
|
|
130
|
+
return native.setDebugGeography(geography);
|
|
131
|
+
},
|
|
132
|
+
|
|
133
|
+
/**
|
|
134
|
+
*
|
|
135
|
+
*/
|
|
136
|
+
getStatus() {
|
|
137
|
+
return native.getStatus();
|
|
138
|
+
},
|
|
139
|
+
|
|
140
|
+
/**
|
|
141
|
+
*
|
|
142
|
+
* @param status
|
|
143
|
+
*/
|
|
144
|
+
setStatus(status) {
|
|
145
|
+
if (
|
|
146
|
+
status !== AdsConsentStatus.UNKNOWN &&
|
|
147
|
+
status !== AdsConsentStatus.NON_PERSONALIZED &&
|
|
148
|
+
status !== AdsConsentStatus.PERSONALIZED
|
|
149
|
+
) {
|
|
150
|
+
throw new Error(
|
|
151
|
+
"AdsConsent.setStatus(*) 'status' expected one of AdsConsentStatus.UNKNOWN, AdsConsentStatus.NON_PERSONALIZED or AdsConsentStatus.PERSONALIZED.",
|
|
152
|
+
);
|
|
153
|
+
}
|
|
154
|
+
|
|
155
|
+
return native.setStatus(status);
|
|
156
|
+
},
|
|
157
|
+
|
|
158
|
+
/**
|
|
159
|
+
*
|
|
160
|
+
* @param tag
|
|
161
|
+
*/
|
|
162
|
+
setTagForUnderAgeOfConsent(tag) {
|
|
163
|
+
if (!isBoolean(tag)) {
|
|
164
|
+
throw new Error("AdsConsent.setTagForUnderAgeOfConsent(*) 'tag' expected a boolean value.");
|
|
165
|
+
}
|
|
166
|
+
|
|
167
|
+
return native.setTagForUnderAgeOfConsent(tag);
|
|
168
|
+
},
|
|
169
|
+
|
|
170
|
+
/**
|
|
171
|
+
*
|
|
172
|
+
* @param deviceIds
|
|
173
|
+
*/
|
|
174
|
+
addTestDevices(deviceIds) {
|
|
175
|
+
if (!isArray(deviceIds)) {
|
|
176
|
+
throw new Error(
|
|
177
|
+
"AdsConsent.addTestDevices(*) 'deviceIds' expected an array of string values.",
|
|
178
|
+
);
|
|
179
|
+
}
|
|
180
|
+
|
|
181
|
+
for (let i = 0; i < deviceIds.length; i++) {
|
|
182
|
+
if (!isString(deviceIds[i])) {
|
|
183
|
+
throw new Error(
|
|
184
|
+
"AdsConsent.addTestDevices(*) 'deviceIds' expected an array of string values.",
|
|
185
|
+
);
|
|
186
|
+
}
|
|
187
|
+
}
|
|
188
|
+
|
|
189
|
+
return native.addTestDevices(deviceIds);
|
|
190
|
+
},
|
|
191
|
+
};
|
|
@@ -0,0 +1,38 @@
|
|
|
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
|
+
/**
|
|
19
|
+
* AdsConsentDebugGeography enum.
|
|
20
|
+
*
|
|
21
|
+
* Used to set a mock location when testing the `AdsConsent` helper.
|
|
22
|
+
*/
|
|
23
|
+
export enum AdsConsentDebugGeography {
|
|
24
|
+
/**
|
|
25
|
+
* Disable any debug geography.
|
|
26
|
+
*/
|
|
27
|
+
DISABLED = 0,
|
|
28
|
+
|
|
29
|
+
/**
|
|
30
|
+
* Sets the location to within the EEA.
|
|
31
|
+
*/
|
|
32
|
+
EEA = 1,
|
|
33
|
+
|
|
34
|
+
/**
|
|
35
|
+
* Sets the location to outside of the EEA.
|
|
36
|
+
*/
|
|
37
|
+
NOT_EEA = 2,
|
|
38
|
+
}
|
|
@@ -0,0 +1,36 @@
|
|
|
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
|
+
/**
|
|
19
|
+
* AdsConsentStatus enum.
|
|
20
|
+
*/
|
|
21
|
+
export enum AdsConsentStatus {
|
|
22
|
+
/**
|
|
23
|
+
* 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.
|
|
24
|
+
*/
|
|
25
|
+
UNKNOWN = 0,
|
|
26
|
+
|
|
27
|
+
/**
|
|
28
|
+
* The user has accepted non-personalized ads.
|
|
29
|
+
*/
|
|
30
|
+
NON_PERSONALIZED = 1,
|
|
31
|
+
|
|
32
|
+
/**
|
|
33
|
+
* The user has accepted personalized ads.
|
|
34
|
+
*/
|
|
35
|
+
PERSONALIZED = 2,
|
|
36
|
+
}
|
|
@@ -0,0 +1,59 @@
|
|
|
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
|
+
|
|
19
|
+
export enum BannerAdSize {
|
|
20
|
+
/**
|
|
21
|
+
* Mobile Marketing Association (MMA) banner ad size (320x50 density-independent pixels).
|
|
22
|
+
*/
|
|
23
|
+
BANNER = 'BANNER',
|
|
24
|
+
|
|
25
|
+
/**
|
|
26
|
+
* Interactive Advertising Bureau (IAB) full banner ad size (468x60 density-independent pixels).
|
|
27
|
+
*/
|
|
28
|
+
FULL_BANNER = 'FULL_BANNER',
|
|
29
|
+
|
|
30
|
+
/**
|
|
31
|
+
* Large banner ad size (320x100 density-independent pixels).
|
|
32
|
+
*/
|
|
33
|
+
LARGE_BANNER = 'LARGE_BANNER',
|
|
34
|
+
|
|
35
|
+
/**
|
|
36
|
+
* Interactive Advertising Bureau (IAB) leaderboard ad size (728x90 density-independent pixels).
|
|
37
|
+
*/
|
|
38
|
+
LEADERBOARD = 'LEADERBOARD',
|
|
39
|
+
|
|
40
|
+
/**
|
|
41
|
+
* Interactive Advertising Bureau (IAB) medium rectangle ad size (300x250 density-independent pixels).
|
|
42
|
+
*/
|
|
43
|
+
MEDIUM_RECTANGLE = 'MEDIUM_RECTANGLE',
|
|
44
|
+
|
|
45
|
+
/**
|
|
46
|
+
* A (next generation) dynamically sized banner that is full-width and auto-height.
|
|
47
|
+
*/
|
|
48
|
+
ADAPTIVE_BANNER = 'ADAPTIVE_BANNER',
|
|
49
|
+
|
|
50
|
+
/**
|
|
51
|
+
* A dynamically sized banner that matches its parent's width and expands/contracts its height to match the ad's content after loading completes.
|
|
52
|
+
*/
|
|
53
|
+
FLUID = 'FLUID',
|
|
54
|
+
|
|
55
|
+
/**
|
|
56
|
+
* IAB wide skyscraper ad size (160x600 density-independent pixels). This size is currently not supported by the Google Mobile Ads network; this is intended for mediation ad networks only.
|
|
57
|
+
*/
|
|
58
|
+
WIDE_SKYSCRAPER = 'WIDE_SKYSCRAPER',
|
|
59
|
+
}
|
|
@@ -0,0 +1,38 @@
|
|
|
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 enum MaxAdContentRating {
|
|
19
|
+
/**
|
|
20
|
+
* "General audiences." Content suitable for all audiences, including families and children.
|
|
21
|
+
*/
|
|
22
|
+
G = 'G',
|
|
23
|
+
|
|
24
|
+
/**
|
|
25
|
+
* "Parental guidance." Content suitable for most audiences with parental guidance, including topics like non-realistic, cartoonish violence.
|
|
26
|
+
*/
|
|
27
|
+
PG = 'PG',
|
|
28
|
+
|
|
29
|
+
/**
|
|
30
|
+
* T: "Teen." Content suitable for teen and older audiences, including topics such as general health, social networks, scary imagery, and fight sports.
|
|
31
|
+
*/
|
|
32
|
+
T = 'T',
|
|
33
|
+
|
|
34
|
+
/**
|
|
35
|
+
* "Mature audiences." Content suitable only for mature audiences; includes topics such as alcohol, gambling, sexual content, and weapons.
|
|
36
|
+
*/
|
|
37
|
+
MA = 'MA',
|
|
38
|
+
}
|
package/src/MobileAds.ts
ADDED
|
@@ -0,0 +1,84 @@
|
|
|
1
|
+
import { Module } from './internal';
|
|
2
|
+
import { validateAdRequestConfiguration } from './validateAdRequestConfiguration';
|
|
3
|
+
import { version } from './version';
|
|
4
|
+
import { MobileAdsModuleInterface } from './types/MobileAdsModule.interface';
|
|
5
|
+
import { RequestConfiguration } from './types/RequestConfiguration';
|
|
6
|
+
import { App, Config } from './types/Module.interface';
|
|
7
|
+
|
|
8
|
+
const namespace = 'google_mobile_ads';
|
|
9
|
+
|
|
10
|
+
const nativeModuleName = [
|
|
11
|
+
'RNGoogleMobileAdsModule',
|
|
12
|
+
'RNGoogleMobileAdsAppOpenModule',
|
|
13
|
+
'RNGoogleMobileAdsInterstitialModule',
|
|
14
|
+
'RNGoogleMobileAdsRewardedModule',
|
|
15
|
+
];
|
|
16
|
+
|
|
17
|
+
type Event = {
|
|
18
|
+
adUnitId: string;
|
|
19
|
+
requestId: number;
|
|
20
|
+
};
|
|
21
|
+
|
|
22
|
+
class MobileAdsModule extends Module implements MobileAdsModuleInterface {
|
|
23
|
+
constructor(app: App, config: Config) {
|
|
24
|
+
super(app, config);
|
|
25
|
+
|
|
26
|
+
this.emitter.addListener('google_mobile_ads_app_open_event', (event: Event) => {
|
|
27
|
+
this.emitter.emit(
|
|
28
|
+
`google_mobile_ads_app_open_event:${event.adUnitId}:${event.requestId}`,
|
|
29
|
+
event,
|
|
30
|
+
);
|
|
31
|
+
});
|
|
32
|
+
|
|
33
|
+
this.emitter.addListener('google_mobile_ads_interstitial_event', (event: Event) => {
|
|
34
|
+
this.emitter.emit(
|
|
35
|
+
`google_mobile_ads_interstitial_event:${event.adUnitId}:${event.requestId}`,
|
|
36
|
+
event,
|
|
37
|
+
);
|
|
38
|
+
});
|
|
39
|
+
|
|
40
|
+
this.emitter.addListener('google_mobile_ads_rewarded_event', (event: Event) => {
|
|
41
|
+
this.emitter.emit(
|
|
42
|
+
`google_mobile_ads_rewarded_event:${event.adUnitId}:${event.requestId}`,
|
|
43
|
+
event,
|
|
44
|
+
);
|
|
45
|
+
});
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
initialize() {
|
|
49
|
+
return this.native.initialize();
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
setRequestConfiguration(requestConfiguration: RequestConfiguration) {
|
|
53
|
+
let config;
|
|
54
|
+
try {
|
|
55
|
+
config = validateAdRequestConfiguration(requestConfiguration);
|
|
56
|
+
} catch (e) {
|
|
57
|
+
if (e instanceof Error) {
|
|
58
|
+
throw new Error(`googleMobileAds.setRequestConfiguration(*) ${e.message}`);
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
return this.native.setRequestConfiguration(config);
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
const MobileAdsInstance = new MobileAdsModule(
|
|
67
|
+
{ name: 'AppName' },
|
|
68
|
+
{
|
|
69
|
+
version,
|
|
70
|
+
namespace,
|
|
71
|
+
nativeModuleName,
|
|
72
|
+
nativeEvents: [
|
|
73
|
+
'google_mobile_ads_app_open_event',
|
|
74
|
+
'google_mobile_ads_interstitial_event',
|
|
75
|
+
'google_mobile_ads_rewarded_event',
|
|
76
|
+
],
|
|
77
|
+
},
|
|
78
|
+
);
|
|
79
|
+
|
|
80
|
+
export const MobileAds = () => {
|
|
81
|
+
return MobileAdsInstance;
|
|
82
|
+
};
|
|
83
|
+
|
|
84
|
+
export default MobileAds;
|