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/LICENSE
ADDED
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
Apache-2.0 License
|
|
2
|
+
------------------
|
|
3
|
+
|
|
4
|
+
Copyright (c) 2021-present Invertase Limited <oss@invertase.io>
|
|
5
|
+
|
|
6
|
+
Licensed under the Apache License, Version 2.0 (the "License");
|
|
7
|
+
you may not use this library except in compliance with the License.
|
|
8
|
+
|
|
9
|
+
You may obtain a copy of the Apache-2.0 License at
|
|
10
|
+
|
|
11
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
|
12
|
+
|
|
13
|
+
Unless required by applicable law or agreed to in writing, software
|
|
14
|
+
distributed under the License is distributed on an "AS IS" BASIS,
|
|
15
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
16
|
+
See the License for the specific language governing permissions and
|
|
17
|
+
limitations under the License.
|
|
18
|
+
|
|
19
|
+
|
|
20
|
+
Creative Commons Attribution 3.0 License
|
|
21
|
+
----------------------------------------
|
|
22
|
+
|
|
23
|
+
Copyright (c) 2016-present Invertase Limited <oss@invertase.io>
|
|
24
|
+
|
|
25
|
+
Documentation and other instructional materials provided for this project
|
|
26
|
+
(including on a separate documentation repository or it's documentation website) are
|
|
27
|
+
licensed under the Creative Commons Attribution 3.0 License. Code samples/blocks
|
|
28
|
+
contained therein are licensed under the Apache License, Version 2.0 (the "License"), as above.
|
|
29
|
+
|
|
30
|
+
You may obtain a copy of the Creative Commons Attribution 3.0 License at
|
|
31
|
+
|
|
32
|
+
https://creativecommons.org/licenses/by/3.0/
|
package/README.md
ADDED
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
<p align="center">
|
|
2
|
+
<a href="https://docs.page/invertase/react-native-google-mobile-ads">
|
|
3
|
+
<img width="160px" src="./docs/img/logo_admob_192px.svg"><br/>
|
|
4
|
+
</a>
|
|
5
|
+
<h2 align="center">React Native Google Mobile Ads</h2>
|
|
6
|
+
</p>
|
|
7
|
+
|
|
8
|
+
<p align="center">
|
|
9
|
+
<a href="https://www.npmjs.com/package/react-native-google-mobile-ads"><img src="https://img.shields.io/npm/dm/react-native-google-mobile-ads.svg?style=flat-square" alt="NPM downloads"></a>
|
|
10
|
+
<a href="https://www.npmjs.com/package/react-native-google-mobile-ads"><img src="https://img.shields.io/npm/v/react-native-google-mobile-ads.svg?style=flat-square" alt="NPM version"></a>
|
|
11
|
+
<a href="/LICENSE"><img src="https://img.shields.io/npm/l/react-native-google-mobile-ads.svg?style=flat-square" alt="License"></a>
|
|
12
|
+
</p>
|
|
13
|
+
|
|
14
|
+
<p align="center">
|
|
15
|
+
<a href="https://invertase.link/discord"><img src="https://img.shields.io/discord/295953187817521152.svg?style=flat-square&colorA=7289da&label=Chat%20on%20Discord" alt="Chat on Discord"></a>
|
|
16
|
+
<a href="https://twitter.com/invertaseio"><img src="https://img.shields.io/twitter/follow/invertaseio.svg?style=flat-square&colorA=1da1f2&colorB=&label=Follow%20on%20Twitter" alt="Follow on Twitter"></a>
|
|
17
|
+
<a href="https://www.facebook.com/groups/invertase.io"><img src="https://img.shields.io/badge/Follow%20on%20Facebook-4172B8?logo=facebook&style=flat-square&logoColor=fff" alt="Follow on Facebook"></a>
|
|
18
|
+
</p>
|
|
19
|
+
|
|
20
|
+
---
|
|
21
|
+
|
|
22
|
+
**React Native Google Mobile Ads** allows you to monetize your app with AdMob; a React Native wrapper around the native Google-Mobile-Ads SDKs for both iOS and Android.
|
|
23
|
+
|
|
24
|
+
React Native Google Mobile Ads is built with three key principals in mind;
|
|
25
|
+
|
|
26
|
+
- 🧪 **Well tested**
|
|
27
|
+
- the module is extensively tested to >95% coverage (getting there after moving from react-native-firebase!)
|
|
28
|
+
- 👁 **Well typed**
|
|
29
|
+
- first class support for Typescript included
|
|
30
|
+
- 📄 **Well documented**
|
|
31
|
+
- full reference & installation documentation alongside detailed guides and FAQs
|
|
32
|
+
|
|
33
|
+
## Documentation
|
|
34
|
+
|
|
35
|
+
- [Installation](https://docs.page/invertase/react-native-google-mobile-ads)
|
|
36
|
+
- [Displaying Ads](https://docs.page/invertase/react-native-google-mobile-ads/displaying-ads)
|
|
37
|
+
|
|
38
|
+
<!--
|
|
39
|
+
- [Quick Start](https://rnfirebase.io/)
|
|
40
|
+
- [Reference API](https://rnfirebase.io/reference) -->
|
|
41
|
+
|
|
42
|
+
## Contributing
|
|
43
|
+
|
|
44
|
+
<!-- - [Overview](https://rnfirebase.io) -->
|
|
45
|
+
|
|
46
|
+
- [Issues](https://github.com/invertase/react-native-google-mobile-ads/issues)
|
|
47
|
+
- [PRs](https://github.com/invertase/react-native-google-mobile-ads/pulls)
|
|
48
|
+
<!-- - [Documentation](https://rnfirebase.io) -->
|
|
49
|
+
- [Community](https://github.com/invertase/react-native-google-mobile-ads/blob/master/CONTRIBUTING.md)
|
|
50
|
+
- [Code of Conduct](https://github.com/invertase/meta/blob/master/CODE_OF_CONDUCT.md)
|
|
51
|
+
|
|
52
|
+
## License
|
|
53
|
+
|
|
54
|
+
- See [LICENSE](/LICENSE)
|
|
55
|
+
|
|
56
|
+
---
|
|
57
|
+
|
|
58
|
+
<p align="center">
|
|
59
|
+
<a href="https://invertase.io/?utm_source=readme&utm_medium=footer&utm_campaign=react-native-google-mobile-ads">
|
|
60
|
+
<img width="75px" src="https://static.invertase.io/assets/invertase/invertase-rounded-avatar.png">
|
|
61
|
+
</a>
|
|
62
|
+
<p align="center">
|
|
63
|
+
Built and maintained by <a href="https://invertase.io/?utm_source=readme&utm_medium=footer&utm_campaign=react-native-google-mobile-ads">Invertase</a>.
|
|
64
|
+
</p>
|
|
65
|
+
</p>
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
require 'json'
|
|
2
|
+
package = JSON.parse(File.read(File.join(__dir__, 'package.json')))
|
|
3
|
+
|
|
4
|
+
google_ads_sdk_version = package['sdkVersions']['ios']['googleAds']
|
|
5
|
+
|
|
6
|
+
Pod::Spec.new do |s|
|
|
7
|
+
s.name = "RNGoogleMobileAds"
|
|
8
|
+
|
|
9
|
+
s.version = package["version"]
|
|
10
|
+
s.description = package["description"]
|
|
11
|
+
s.summary = <<-DESC
|
|
12
|
+
#{package["description"]}
|
|
13
|
+
DESC
|
|
14
|
+
s.homepage = "http://invertase.io/oss/react-native-google-mobile-ads"
|
|
15
|
+
s.license = package['license']
|
|
16
|
+
s.authors = "Invertase Limited"
|
|
17
|
+
s.source = { :git => "#{package["repository"]["url"]}.git", :tag => "v#{s.version}" }
|
|
18
|
+
s.social_media_url = 'http://twitter.com/invertaseio'
|
|
19
|
+
s.ios.deployment_target = "10.0"
|
|
20
|
+
s.source_files = 'ios/**/*.{h,m}'
|
|
21
|
+
|
|
22
|
+
# React Native dependencies
|
|
23
|
+
s.dependency 'React-Core'
|
|
24
|
+
|
|
25
|
+
# Other dependencies
|
|
26
|
+
s.dependency 'PersonalizedAdConsent', '~> 1.0.5'
|
|
27
|
+
|
|
28
|
+
if defined?($RNGoogleAdsSDKVersion)
|
|
29
|
+
Pod::UI.puts "#{s.name}: Using user specified Google Mobile-Ads SDK version '#{$RNGoogleAdsSDKVersion}'"
|
|
30
|
+
google_ads_sdk_version = $RNGoogleAdsSDKVersion
|
|
31
|
+
end
|
|
32
|
+
|
|
33
|
+
# AdMob dependencies
|
|
34
|
+
s.dependency 'Google-Mobile-Ads-SDK', google_ads_sdk_version
|
|
35
|
+
|
|
36
|
+
if defined?($RNGoogleAdsAsStaticFramework)
|
|
37
|
+
Pod::UI.puts "#{s.name}: Using overridden static_framework value of '#{$RNGoogleAdsAsStaticFramework}'"
|
|
38
|
+
s.static_framework = $RNGoogleAdsAsStaticFramework
|
|
39
|
+
else
|
|
40
|
+
s.static_framework = false
|
|
41
|
+
end
|
|
42
|
+
end
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import { AdsConsent } from '../src';
|
|
2
|
+
|
|
3
|
+
describe('Google Mobile Ads AdsConsent', function () {
|
|
4
|
+
describe('requestInfoUpdate', function () {
|
|
5
|
+
it('throws if publisherIds is not an array', function () {
|
|
6
|
+
// @ts-ignore
|
|
7
|
+
expect(() => AdsConsent.requestInfoUpdate('pub-123')).toThrowError(
|
|
8
|
+
"AdsConsent.requestInfoUpdate(*) 'publisherIds' expected an array of string values.",
|
|
9
|
+
);
|
|
10
|
+
});
|
|
11
|
+
|
|
12
|
+
it('throws if publisherIds is empty array', function () {
|
|
13
|
+
expect(() => AdsConsent.requestInfoUpdate([])).toThrowError(
|
|
14
|
+
"AdsConsent.requestInfoUpdate(*) 'publisherIds' list of publisher IDs cannot be empty.",
|
|
15
|
+
);
|
|
16
|
+
});
|
|
17
|
+
|
|
18
|
+
it('throws if publisherIds contains non-string values', function () {
|
|
19
|
+
// @ts-ignore
|
|
20
|
+
expect(() => AdsConsent.requestInfoUpdate(['foo', 123])).toThrowError(
|
|
21
|
+
"AdsConsent.requestInfoUpdate(*) 'publisherIds[1]' expected a string value.",
|
|
22
|
+
);
|
|
23
|
+
});
|
|
24
|
+
});
|
|
25
|
+
});
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
import admob, { MaxAdContentRating } from '../src';
|
|
2
|
+
|
|
3
|
+
describe('Admob', function () {
|
|
4
|
+
describe('setRequestConfiguration()', function () {
|
|
5
|
+
it('throws if config is not an object', function () {
|
|
6
|
+
// @ts-ignore
|
|
7
|
+
expect(() => admob().setRequestConfiguration('123')).toThrowError(
|
|
8
|
+
"setRequestConfiguration(*) 'requestConfiguration' expected an object value",
|
|
9
|
+
);
|
|
10
|
+
});
|
|
11
|
+
|
|
12
|
+
describe('maxAdContentRating', function () {
|
|
13
|
+
it('throws if maxAdContentRating is invalid', function () {
|
|
14
|
+
expect(() =>
|
|
15
|
+
admob().setRequestConfiguration({
|
|
16
|
+
maxAdContentRating: 'Y' as MaxAdContentRating,
|
|
17
|
+
}),
|
|
18
|
+
).toThrowError(
|
|
19
|
+
"setRequestConfiguration(*) 'requestConfiguration.maxAdContentRating' expected on of MaxAdContentRating.G, MaxAdContentRating.PG, MaxAdContentRating.T or MaxAdContentRating.MA",
|
|
20
|
+
);
|
|
21
|
+
});
|
|
22
|
+
});
|
|
23
|
+
|
|
24
|
+
describe('tagForChildDirectedTreatment', function () {
|
|
25
|
+
it('throws if tagForChildDirectedTreatment not a boolean', function () {
|
|
26
|
+
expect(() =>
|
|
27
|
+
admob().setRequestConfiguration({
|
|
28
|
+
// @ts-ignore
|
|
29
|
+
tagForChildDirectedTreatment: 'true',
|
|
30
|
+
}),
|
|
31
|
+
).toThrowError(
|
|
32
|
+
"setRequestConfiguration(*) 'requestConfiguration.tagForChildDirectedTreatment' expected a boolean value",
|
|
33
|
+
);
|
|
34
|
+
});
|
|
35
|
+
});
|
|
36
|
+
|
|
37
|
+
describe('tagForUnderAgeOfConsent', function () {
|
|
38
|
+
it('throws if tagForUnderAgeOfConsent not a boolean', function () {
|
|
39
|
+
expect(() =>
|
|
40
|
+
admob().setRequestConfiguration({
|
|
41
|
+
// @ts-ignore
|
|
42
|
+
tagForUnderAgeOfConsent: 'false',
|
|
43
|
+
}),
|
|
44
|
+
).toThrowError(
|
|
45
|
+
"setRequestConfiguration(*) 'requestConfiguration.tagForUnderAgeOfConsent' expected a boolean value",
|
|
46
|
+
);
|
|
47
|
+
});
|
|
48
|
+
});
|
|
49
|
+
|
|
50
|
+
describe('testDeviceIdentifiers', function () {
|
|
51
|
+
it('throws if testDeviceIdentifiers not an array', function () {
|
|
52
|
+
expect(() =>
|
|
53
|
+
admob().setRequestConfiguration({
|
|
54
|
+
// @ts-ignore
|
|
55
|
+
testDeviceIdentifiers: 'EMULATOR',
|
|
56
|
+
}),
|
|
57
|
+
).toThrowError(
|
|
58
|
+
"setRequestConfiguration(*) 'requestConfiguration.testDeviceIdentifiers' expected an array value",
|
|
59
|
+
);
|
|
60
|
+
});
|
|
61
|
+
});
|
|
62
|
+
});
|
|
63
|
+
});
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
import { InterstitialAd } from '../src';
|
|
2
|
+
|
|
3
|
+
describe('Google Mobile Ads Interstitial', function () {
|
|
4
|
+
describe('createForAdRequest', function () {
|
|
5
|
+
it('throws if adUnitId is invalid', function () {
|
|
6
|
+
// @ts-ignore
|
|
7
|
+
expect(() => InterstitialAd.createForAdRequest(123)).toThrowError(
|
|
8
|
+
"'adUnitId' expected an string value",
|
|
9
|
+
);
|
|
10
|
+
});
|
|
11
|
+
|
|
12
|
+
it('throws if requestOptions are invalid', function () {
|
|
13
|
+
// @ts-ignore
|
|
14
|
+
expect(() => InterstitialAd.createForAdRequest('123', 123)).toThrowError(
|
|
15
|
+
"InterstitialAd.createForAdRequest(_, *) 'options' expected an object value.",
|
|
16
|
+
);
|
|
17
|
+
});
|
|
18
|
+
|
|
19
|
+
// has own tests
|
|
20
|
+
it('returns a new instance', function () {
|
|
21
|
+
const i = InterstitialAd.createForAdRequest('abc');
|
|
22
|
+
expect(i.constructor.name).toEqual('InterstitialAd');
|
|
23
|
+
expect(i.adUnitId).toEqual('abc');
|
|
24
|
+
expect(i.loaded).toEqual(false);
|
|
25
|
+
});
|
|
26
|
+
|
|
27
|
+
describe('show', function () {
|
|
28
|
+
it('throws if showing before loaded', function () {
|
|
29
|
+
const i = InterstitialAd.createForAdRequest('abc');
|
|
30
|
+
|
|
31
|
+
expect(() => i.show()).toThrowError(
|
|
32
|
+
'The requested InterstitialAd has not loaded and could not be shown',
|
|
33
|
+
);
|
|
34
|
+
});
|
|
35
|
+
});
|
|
36
|
+
|
|
37
|
+
describe('onAdEvent', function () {
|
|
38
|
+
it('throws if handler is not a function', function () {
|
|
39
|
+
const i = InterstitialAd.createForAdRequest('abc');
|
|
40
|
+
|
|
41
|
+
// @ts-ignore
|
|
42
|
+
expect(() => i.onAdEvent('foo')).toThrowError("'handler' expected a function");
|
|
43
|
+
});
|
|
44
|
+
|
|
45
|
+
it('returns an unsubscriber function', function () {
|
|
46
|
+
const i = InterstitialAd.createForAdRequest('abc');
|
|
47
|
+
const unsub = i.onAdEvent(() => {});
|
|
48
|
+
expect(unsub).toBeDefined();
|
|
49
|
+
unsub();
|
|
50
|
+
});
|
|
51
|
+
});
|
|
52
|
+
});
|
|
53
|
+
});
|
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
import groovy.json.JsonOutput
|
|
2
|
+
import groovy.json.JsonSlurper
|
|
3
|
+
|
|
4
|
+
String fileName = "app.json"
|
|
5
|
+
String jsonRoot = "react-native-google-mobile-ads"
|
|
6
|
+
String jsonRaw = "GOOGLE_MOBILE_ADS_JSON_RAW"
|
|
7
|
+
|
|
8
|
+
File jsonFile = null
|
|
9
|
+
File parentDir = rootProject.projectDir
|
|
10
|
+
|
|
11
|
+
for (int i = 0; i <= 3; i++) {
|
|
12
|
+
if (parentDir == null) break
|
|
13
|
+
parentDir = parentDir.parentFile
|
|
14
|
+
if (parentDir != null) {
|
|
15
|
+
jsonFile = new File(parentDir, fileName)
|
|
16
|
+
if (jsonFile.exists()) break
|
|
17
|
+
}
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
if (jsonFile != null && jsonFile.exists()) {
|
|
21
|
+
rootProject.logger.info ":${project.name} ${fileName} found at ${jsonFile.toString()}"
|
|
22
|
+
Object json = null
|
|
23
|
+
|
|
24
|
+
try {
|
|
25
|
+
json = new JsonSlurper().parseText(jsonFile.text)
|
|
26
|
+
} catch (Exception ignored) {
|
|
27
|
+
rootProject.logger.warn ":${project.name} failed to parse ${fileName} found at ${jsonFile.toString()}."
|
|
28
|
+
rootProject.logger.warn ignored.toString()
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
if (json && json[jsonRoot]) {
|
|
32
|
+
String jsonStr = JsonOutput.toJson(JsonOutput.toJson(json[jsonRoot]))
|
|
33
|
+
|
|
34
|
+
rootProject.ext.googleMobileAdsJson = [
|
|
35
|
+
raw: json[jsonRoot],
|
|
36
|
+
isFlagEnabled: { key, defaultValue ->
|
|
37
|
+
if (json[jsonRoot] == null || json[jsonRoot][key] == null) return defaultValue
|
|
38
|
+
return json[jsonRoot][key] == true ? true : false
|
|
39
|
+
},
|
|
40
|
+
getStringValue: { key, defaultValue ->
|
|
41
|
+
if (json[jsonRoot] == null) return defaultValue
|
|
42
|
+
return json[jsonRoot][key] ? json[jsonRoot][key] : defaultValue
|
|
43
|
+
}
|
|
44
|
+
]
|
|
45
|
+
|
|
46
|
+
rootProject.logger.info ":${project.name} found ${jsonRoot} json root in ${fileName}, creating app build config"
|
|
47
|
+
android {
|
|
48
|
+
defaultConfig {
|
|
49
|
+
buildConfigField "String", jsonRaw, jsonStr
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
} else {
|
|
53
|
+
rootProject.ext.googleAdsJson = false
|
|
54
|
+
rootProject.logger.info ":${project.name} ${fileName} found with no ${jsonRoot} config, skipping"
|
|
55
|
+
android {
|
|
56
|
+
defaultConfig {
|
|
57
|
+
buildConfigField "String", jsonRaw, '"{}"'
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
} else {
|
|
62
|
+
rootProject.ext.googleMobileAdsJson = false
|
|
63
|
+
rootProject.logger.info ":${project.name} no ${fileName} found, skipping"
|
|
64
|
+
android {
|
|
65
|
+
defaultConfig {
|
|
66
|
+
buildConfigField "String", jsonRaw, '"{}"'
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
}
|
|
@@ -0,0 +1,98 @@
|
|
|
1
|
+
import io.invertase.gradle.common.PackageJson
|
|
2
|
+
|
|
3
|
+
buildscript {
|
|
4
|
+
// The Android Gradle plugin is only required when opening the android folder stand-alone.
|
|
5
|
+
// This avoids unnecessary downloads and potential conflicts when the library is included as a
|
|
6
|
+
// module dependency in an application project.
|
|
7
|
+
if (project == rootProject) {
|
|
8
|
+
repositories {
|
|
9
|
+
google()
|
|
10
|
+
mavenCentral()
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
dependencies {
|
|
14
|
+
classpath("com.android.tools.build:gradle:7.0.4")
|
|
15
|
+
}
|
|
16
|
+
}
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
plugins {
|
|
20
|
+
id "io.invertase.gradle.build" version "1.5"
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
def packageJson = PackageJson.getForProject(project)
|
|
24
|
+
def googleMobileAdsVersion = packageJson['sdkVersions']['android']['googleMobileAds']
|
|
25
|
+
def jsonMinSdk = packageJson['sdkVersions']['android']['minSdk']
|
|
26
|
+
def jsonTargetSdk = packageJson['sdkVersions']['android']['targetSdk']
|
|
27
|
+
def jsonCompileSdk = packageJson['sdkVersions']['android']['compileSdk']
|
|
28
|
+
def jsonBuildTools = packageJson['sdkVersions']['android']['buildTools']
|
|
29
|
+
|
|
30
|
+
project.ext {
|
|
31
|
+
set('react-native', [
|
|
32
|
+
versions: [
|
|
33
|
+
android : [
|
|
34
|
+
minSdk : jsonMinSdk,
|
|
35
|
+
targetSdk : jsonTargetSdk,
|
|
36
|
+
compileSdk: jsonCompileSdk,
|
|
37
|
+
// optional as gradle.buildTools comes with one by default
|
|
38
|
+
// overriding here though to match the version RN uses
|
|
39
|
+
buildTools: jsonBuildTools
|
|
40
|
+
],
|
|
41
|
+
|
|
42
|
+
googleMobileAds: [
|
|
43
|
+
sdk: googleMobileAdsVersion,
|
|
44
|
+
],
|
|
45
|
+
|
|
46
|
+
ads : [
|
|
47
|
+
consent: "1.0.6"
|
|
48
|
+
],
|
|
49
|
+
],
|
|
50
|
+
])
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
apply from: file("./app-json.gradle")
|
|
54
|
+
|
|
55
|
+
def appJSONGoogleMobileAdsAppIDString = ""
|
|
56
|
+
def appJSONGoogleMobileAdsDelayAppMeasurementInitBool = false
|
|
57
|
+
|
|
58
|
+
if (rootProject.ext.googleMobileAdsJson) {
|
|
59
|
+
appJSONGoogleMobileAdsAppIDString = rootProject.ext.googleMobileAdsJson.getStringValue("android_app_id", "")
|
|
60
|
+
appJSONGoogleMobileAdsDelayAppMeasurementInitBool = rootProject.ext.googleMobileAdsJson.isFlagEnabled("delay_app_measurement_init", false)
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
if (!appJSONGoogleMobileAdsAppIDString) {
|
|
64
|
+
// todo throw a build error?
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
android {
|
|
68
|
+
defaultConfig {
|
|
69
|
+
multiDexEnabled true
|
|
70
|
+
manifestPlaceholders = [
|
|
71
|
+
appJSONGoogleMobileAdsAppID : appJSONGoogleMobileAdsAppIDString,
|
|
72
|
+
appJSONGoogleMobileAdsDelayAppMeasurementInit: appJSONGoogleMobileAdsDelayAppMeasurementInitBool
|
|
73
|
+
]
|
|
74
|
+
}
|
|
75
|
+
lintOptions {
|
|
76
|
+
disable 'GradleCompatible'
|
|
77
|
+
abortOnError false
|
|
78
|
+
}
|
|
79
|
+
compileOptions {
|
|
80
|
+
sourceCompatibility JavaVersion.VERSION_1_8
|
|
81
|
+
targetCompatibility JavaVersion.VERSION_1_8
|
|
82
|
+
}
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
repositories {
|
|
86
|
+
google()
|
|
87
|
+
mavenCentral()
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
dependencies {
|
|
91
|
+
implementation("com.google.android.gms:play-services-ads:20.5.0") { force = true; }
|
|
92
|
+
implementation "com.google.android.ads.consent:consent-library:${ReactNative.ext.getVersion("ads", "consent")}"
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
ReactNative.shared.applyPackageVersion()
|
|
96
|
+
ReactNative.shared.applyDefaultExcludes()
|
|
97
|
+
ReactNative.module.applyAndroidVersions()
|
|
98
|
+
ReactNative.module.applyReactNativeDependency("api")
|
package/android/lint.xml
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
rootProject.name = 'react-native-google-mobile-ads'
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
<?xml version="1.0" encoding="utf-8"?>
|
|
2
|
+
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
|
|
3
|
+
package="io.invertase.googlemobileads">
|
|
4
|
+
|
|
5
|
+
<uses-permission android:name="android.permission.INTERNET" />
|
|
6
|
+
<uses-permission android:name="android.permission.WAKE_LOCK" />
|
|
7
|
+
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
|
|
8
|
+
|
|
9
|
+
<application>
|
|
10
|
+
<meta-data
|
|
11
|
+
android:name="com.google.android.gms.ads.APPLICATION_ID"
|
|
12
|
+
android:value="${appJSONGoogleMobileAdsAppID}"/>
|
|
13
|
+
<meta-data
|
|
14
|
+
android:name="com.google.android.gms.ads.DELAY_APP_MEASUREMENT_INIT"
|
|
15
|
+
android:value="${appJSONGoogleMobileAdsDelayAppMeasurementInit}"/>
|
|
16
|
+
</application>
|
|
17
|
+
</manifest>
|
|
@@ -0,0 +1,169 @@
|
|
|
1
|
+
package io.invertase.googlemobileads;
|
|
2
|
+
|
|
3
|
+
/*
|
|
4
|
+
* Copyright (c) 2016-present Invertase Limited & Contributors
|
|
5
|
+
*
|
|
6
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
7
|
+
* you may not use this library except in compliance with the License.
|
|
8
|
+
* You may obtain a copy of the License at
|
|
9
|
+
*
|
|
10
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
11
|
+
*
|
|
12
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
13
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
14
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
15
|
+
* See the License for the specific language governing permissions and
|
|
16
|
+
* limitations under the License.
|
|
17
|
+
*
|
|
18
|
+
*/
|
|
19
|
+
|
|
20
|
+
import com.facebook.react.bridge.Promise;
|
|
21
|
+
import com.facebook.react.bridge.ReactApplicationContext;
|
|
22
|
+
import com.facebook.react.bridge.ReactMethod;
|
|
23
|
+
import com.facebook.react.bridge.ReadableMap;
|
|
24
|
+
import io.invertase.googlemobileads.common.RCTConvert;
|
|
25
|
+
import io.invertase.googlemobileads.common.ReactNativeEvent;
|
|
26
|
+
import io.invertase.googlemobileads.common.ReactNativeEventEmitter;
|
|
27
|
+
import io.invertase.googlemobileads.common.ReactNativeJSON;
|
|
28
|
+
import io.invertase.googlemobileads.common.ReactNativeMeta;
|
|
29
|
+
import io.invertase.googlemobileads.common.ReactNativeModule;
|
|
30
|
+
import io.invertase.googlemobileads.common.ReactNativePreferences;
|
|
31
|
+
import java.util.HashMap;
|
|
32
|
+
import java.util.Map;
|
|
33
|
+
|
|
34
|
+
public class ReactNativeAppModule extends ReactNativeModule {
|
|
35
|
+
private static final String TAG = "RNAppModule";
|
|
36
|
+
|
|
37
|
+
ReactNativeAppModule(ReactApplicationContext reactContext) {
|
|
38
|
+
super(reactContext, TAG);
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
@Override
|
|
42
|
+
public void initialize() {
|
|
43
|
+
super.initialize();
|
|
44
|
+
ReactNativeEventEmitter.getSharedInstance().attachReactContext(getContext());
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
@ReactMethod
|
|
48
|
+
public void initializeApp(ReadableMap options, ReadableMap appConfig, Promise promise) {
|
|
49
|
+
// ReactNativeApp reactNativeApp =
|
|
50
|
+
// RCTConvertFirebase.readableMapToFirebaseApp(options, appConfig, getContext());
|
|
51
|
+
|
|
52
|
+
// WritableMap reactNativeAppMap =
|
|
53
|
+
// RCTConvertFirebase.reactNativeAppToWritableMap(reactNativeApp);
|
|
54
|
+
// promise.resolve(reactNativeAppMap);
|
|
55
|
+
promise.resolve(options);
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
@ReactMethod
|
|
59
|
+
public void setAutomaticDataCollectionEnabled(String appName, Boolean enabled) {
|
|
60
|
+
// ReactNativeApp reactNativeApp = ReactNativeApp.getInstance(appName);
|
|
61
|
+
// reactNativeApp.setDataCollectionDefaultEnabled(enabled);
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
@ReactMethod
|
|
65
|
+
public void deleteApp(String appName, Promise promise) {
|
|
66
|
+
// ReactNativeApp reactNativeApp = ReactNativeApp.getInstance(appName);
|
|
67
|
+
|
|
68
|
+
// if (reactNativeApp != null) {
|
|
69
|
+
// reactNativeApp.delete();
|
|
70
|
+
// }
|
|
71
|
+
|
|
72
|
+
promise.resolve(null);
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
@ReactMethod
|
|
76
|
+
public void eventsNotifyReady(Boolean ready) {
|
|
77
|
+
ReactNativeEventEmitter emitter = ReactNativeEventEmitter.getSharedInstance();
|
|
78
|
+
emitter.notifyJsReady(ready);
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
@ReactMethod
|
|
82
|
+
public void eventsGetListeners(Promise promise) {
|
|
83
|
+
ReactNativeEventEmitter emitter = ReactNativeEventEmitter.getSharedInstance();
|
|
84
|
+
promise.resolve(emitter.getListenersMap());
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
@ReactMethod
|
|
88
|
+
public void eventsPing(String eventName, ReadableMap eventBody, Promise promise) {
|
|
89
|
+
ReactNativeEventEmitter emitter = ReactNativeEventEmitter.getSharedInstance();
|
|
90
|
+
emitter.sendEvent(
|
|
91
|
+
new ReactNativeEvent(eventName, RCTConvert.readableMapToWritableMap(eventBody)));
|
|
92
|
+
promise.resolve(RCTConvert.readableMapToWritableMap(eventBody));
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
@ReactMethod
|
|
96
|
+
public void eventsAddListener(String eventName) {
|
|
97
|
+
ReactNativeEventEmitter emitter = ReactNativeEventEmitter.getSharedInstance();
|
|
98
|
+
emitter.addListener(eventName);
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
@ReactMethod
|
|
102
|
+
public void eventsRemoveListener(String eventName, Boolean all) {
|
|
103
|
+
ReactNativeEventEmitter emitter = ReactNativeEventEmitter.getSharedInstance();
|
|
104
|
+
emitter.removeListener(eventName, all);
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
@ReactMethod
|
|
108
|
+
public void addListener(String eventName) {
|
|
109
|
+
// Keep: Required for RN built in Event Emitter Calls.
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
@ReactMethod
|
|
113
|
+
public void removeListeners(Integer count) {
|
|
114
|
+
// Keep: Required for RN built in Event Emitter Calls.
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
/** ------------------ META ------------------ */
|
|
118
|
+
@ReactMethod
|
|
119
|
+
public void metaGetAll(Promise promise) {
|
|
120
|
+
promise.resolve(ReactNativeMeta.getSharedInstance().getAll());
|
|
121
|
+
}
|
|
122
|
+
|
|
123
|
+
/** ------------------ JSON ------------------ */
|
|
124
|
+
@ReactMethod
|
|
125
|
+
public void jsonGetAll(Promise promise) {
|
|
126
|
+
promise.resolve(ReactNativeJSON.getSharedInstance().getAll());
|
|
127
|
+
}
|
|
128
|
+
|
|
129
|
+
/** ------------------ PREFERENCES ------------------ */
|
|
130
|
+
@ReactMethod
|
|
131
|
+
public void preferencesSetBool(String key, boolean value, Promise promise) {
|
|
132
|
+
ReactNativePreferences.getSharedInstance().setBooleanValue(key, value);
|
|
133
|
+
promise.resolve(null);
|
|
134
|
+
}
|
|
135
|
+
|
|
136
|
+
@ReactMethod
|
|
137
|
+
public void preferencesSetString(String key, String value, Promise promise) {
|
|
138
|
+
ReactNativePreferences.getSharedInstance().setStringValue(key, value);
|
|
139
|
+
promise.resolve(null);
|
|
140
|
+
}
|
|
141
|
+
|
|
142
|
+
@ReactMethod
|
|
143
|
+
public void preferencesGetAll(Promise promise) {
|
|
144
|
+
promise.resolve(ReactNativePreferences.getSharedInstance().getAll());
|
|
145
|
+
}
|
|
146
|
+
|
|
147
|
+
@ReactMethod
|
|
148
|
+
public void preferencesClearAll(Promise promise) {
|
|
149
|
+
ReactNativePreferences.getSharedInstance().clearAll();
|
|
150
|
+
promise.resolve(null);
|
|
151
|
+
}
|
|
152
|
+
|
|
153
|
+
@Override
|
|
154
|
+
public Map<String, Object> getConstants() {
|
|
155
|
+
Map<String, Object> constants = new HashMap<>();
|
|
156
|
+
// List<Map<String, Object>> appsList = new ArrayList<>();
|
|
157
|
+
// List<ReactNativeApp> reactNativeApps = ReactNativeApp.getApps(getReactApplicationContext());
|
|
158
|
+
|
|
159
|
+
// for (ReactNativeApp app : reactNativeApps) {
|
|
160
|
+
// appsList.add(RCTConvertFirebase.reactNativeAppToMap(app));
|
|
161
|
+
// }
|
|
162
|
+
|
|
163
|
+
// constants.put("NATIVE_FIREBASE_APPS", appsList);
|
|
164
|
+
|
|
165
|
+
// constants.put("FIREBASE_RAW_JSON", ReactNativeJSON.getSharedInstance().getRawJSON());
|
|
166
|
+
|
|
167
|
+
return constants;
|
|
168
|
+
}
|
|
169
|
+
}
|