@javascriptcommon/react-native-google-mobile-ads 16.3.3
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 +181 -0
- package/RNGoogleMobileAds.podspec +74 -0
- package/__tests__/banner.test.tsx +53 -0
- package/__tests__/consent.test.ts +33 -0
- package/__tests__/googleMobileAds.test.ts +108 -0
- package/__tests__/interstitial.test.ts +140 -0
- package/__tests__/nativeEventEmitter.test.ts +72 -0
- package/__tests__/requestOptions.test.tsx +82 -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 +149 -0
- package/android/lint.xml +5 -0
- package/android/settings.gradle +1 -0
- package/android/src/main/AndroidManifest.xml +23 -0
- package/android/src/main/java/io/invertase/googlemobileads/OnNativeEvent.kt +23 -0
- package/android/src/main/java/io/invertase/googlemobileads/ReactNativeAppModule.java +152 -0
- package/android/src/main/java/io/invertase/googlemobileads/ReactNativeGoogleMobileAdsAppOpenModule.kt +92 -0
- package/android/src/main/java/io/invertase/googlemobileads/ReactNativeGoogleMobileAdsBannerAdViewManager.java +303 -0
- package/android/src/main/java/io/invertase/googlemobileads/ReactNativeGoogleMobileAdsCommon.java +277 -0
- package/android/src/main/java/io/invertase/googlemobileads/ReactNativeGoogleMobileAdsConsentModule.java +293 -0
- package/android/src/main/java/io/invertase/googlemobileads/ReactNativeGoogleMobileAdsEvent.java +76 -0
- package/android/src/main/java/io/invertase/googlemobileads/ReactNativeGoogleMobileAdsFullScreenAdModule.kt +201 -0
- package/android/src/main/java/io/invertase/googlemobileads/ReactNativeGoogleMobileAdsInterstitialModule.kt +92 -0
- package/android/src/main/java/io/invertase/googlemobileads/ReactNativeGoogleMobileAdsMediaViewManager.java +79 -0
- package/android/src/main/java/io/invertase/googlemobileads/ReactNativeGoogleMobileAdsModule.kt +178 -0
- package/android/src/main/java/io/invertase/googlemobileads/ReactNativeGoogleMobileAdsNativeAdViewManager.java +164 -0
- package/android/src/main/java/io/invertase/googlemobileads/ReactNativeGoogleMobileAdsNativeModule.kt +172 -0
- package/android/src/main/java/io/invertase/googlemobileads/ReactNativeGoogleMobileAdsPackage.kt +113 -0
- package/android/src/main/java/io/invertase/googlemobileads/ReactNativeGoogleMobileAdsRewardedInterstitialModule.kt +127 -0
- package/android/src/main/java/io/invertase/googlemobileads/ReactNativeGoogleMobileAdsRewardedModule.kt +121 -0
- package/android/src/main/java/io/invertase/googlemobileads/common/RCTConvert.java +111 -0
- package/android/src/main/java/io/invertase/googlemobileads/common/ReactNativeAdView.java +128 -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 +429 -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/android/src/oldarch/com/facebook/react/viewmanagers/RNGoogleMobileAdsMediaViewManagerDelegate.java +32 -0
- package/android/src/oldarch/com/facebook/react/viewmanagers/RNGoogleMobileAdsMediaViewManagerInterface.java +10 -0
- package/android/src/oldarch/com/facebook/react/viewmanagers/RNGoogleMobileAdsNativeViewManagerDelegate.java +36 -0
- package/android/src/oldarch/com/facebook/react/viewmanagers/RNGoogleMobileAdsNativeViewManagerInterface.java +10 -0
- package/android/src/oldarch/io/invertase/googlemobileads/NativeGoogleMobileAdsNativeModuleSpec.kt +18 -0
- package/app.plugin.js +1 -0
- package/babel.config.js +8 -0
- package/docs/ad-inspector.mdx +47 -0
- package/docs/common-reasons-for-ads-not-showing.mdx +111 -0
- package/docs/displaying-ads-hook.mdx +103 -0
- package/docs/displaying-ads.mdx +512 -0
- package/docs/european-user-consent.mdx +315 -0
- package/docs/img/logo_admob_192px.svg +19 -0
- package/docs/impression-level-ad-revenue.mdx +41 -0
- package/docs/index.mdx +508 -0
- package/docs/mediation.mdx +323 -0
- package/docs/migrating-to-v15.mdx +7 -0
- package/docs/migrating-to-v5.mdx +63 -0
- package/docs/migrating-to-v6.mdx +111 -0
- package/docs/native-ads.mdx +385 -0
- package/docs/testing.mdx +17 -0
- package/docs/video-ad_volume-control.mdx +49 -0
- package/docs.json +36 -0
- package/ios/RNGoogleMobileAds/RNGoogleMobileAds-Bridging-Header.h +5 -0
- package/ios/RNGoogleMobileAds/RNGoogleMobileAdsAppOpenModule.h +36 -0
- package/ios/RNGoogleMobileAds/RNGoogleMobileAdsAppOpenModule.mm +104 -0
- package/ios/RNGoogleMobileAds/RNGoogleMobileAdsBannerComponent.h +44 -0
- package/ios/RNGoogleMobileAds/RNGoogleMobileAdsBannerComponent.m +221 -0
- package/ios/RNGoogleMobileAds/RNGoogleMobileAdsBannerView.h +34 -0
- package/ios/RNGoogleMobileAds/RNGoogleMobileAdsBannerView.mm +282 -0
- package/ios/RNGoogleMobileAds/RNGoogleMobileAdsBannerViewManager.mm +87 -0
- package/ios/RNGoogleMobileAds/RNGoogleMobileAdsCommon.h +72 -0
- package/ios/RNGoogleMobileAds/RNGoogleMobileAdsCommon.mm +248 -0
- package/ios/RNGoogleMobileAds/RNGoogleMobileAdsConsentModule.h +36 -0
- package/ios/RNGoogleMobileAds/RNGoogleMobileAdsConsentModule.mm +356 -0
- package/ios/RNGoogleMobileAds/RNGoogleMobileAdsFullScreenAd.h +53 -0
- package/ios/RNGoogleMobileAds/RNGoogleMobileAdsFullScreenAd.mm +220 -0
- package/ios/RNGoogleMobileAds/RNGoogleMobileAdsFullScreenContentDelegate.h +36 -0
- package/ios/RNGoogleMobileAds/RNGoogleMobileAdsFullScreenContentDelegate.mm +80 -0
- package/ios/RNGoogleMobileAds/RNGoogleMobileAdsInterstitialModule.h +36 -0
- package/ios/RNGoogleMobileAds/RNGoogleMobileAdsInterstitialModule.mm +106 -0
- package/ios/RNGoogleMobileAds/RNGoogleMobileAdsMediaView.h +52 -0
- package/ios/RNGoogleMobileAds/RNGoogleMobileAdsMediaView.mm +155 -0
- package/ios/RNGoogleMobileAds/RNGoogleMobileAdsModule.h +32 -0
- package/ios/RNGoogleMobileAds/RNGoogleMobileAdsModule.mm +180 -0
- package/ios/RNGoogleMobileAds/RNGoogleMobileAdsNativeModule.h +35 -0
- package/ios/RNGoogleMobileAds/RNGoogleMobileAdsNativeModule.mm +321 -0
- package/ios/RNGoogleMobileAds/RNGoogleMobileAdsNativeView.h +51 -0
- package/ios/RNGoogleMobileAds/RNGoogleMobileAdsNativeView.mm +251 -0
- package/ios/RNGoogleMobileAds/RNGoogleMobileAdsRewardedInterstitialModule.h +37 -0
- package/ios/RNGoogleMobileAds/RNGoogleMobileAdsRewardedInterstitialModule.mm +106 -0
- package/ios/RNGoogleMobileAds/RNGoogleMobileAdsRewardedModule.h +36 -0
- package/ios/RNGoogleMobileAds/RNGoogleMobileAdsRewardedModule.mm +104 -0
- package/ios/RNGoogleMobileAds/common/RNAppModule.h +24 -0
- package/ios/RNGoogleMobileAds/common/RNAppModule.mm +95 -0
- package/ios/RNGoogleMobileAds/common/RNRCTEventEmitter.h +73 -0
- package/ios/RNGoogleMobileAds/common/RNRCTEventEmitter.mm +150 -0
- package/ios/RNGoogleMobileAds/common/RNSharedUtils.h +43 -0
- package/ios/RNGoogleMobileAds/common/RNSharedUtils.mm +34 -0
- package/ios/RNGoogleMobileAds.xcodeproj/project.pbxproj +377 -0
- package/ios/RNGoogleMobileAds.xcodeproj/xcshareddata/IDETemplateMacros.plist +24 -0
- package/ios_config.sh +192 -0
- package/jest.config.js +7 -0
- package/jest.setup.ts +92 -0
- package/lib/commonjs/AdEventType.js +72 -0
- package/lib/commonjs/AdEventType.js.map +1 -0
- package/lib/commonjs/AdsConsent.js +117 -0
- package/lib/commonjs/AdsConsent.js.map +1 -0
- package/lib/commonjs/AdsConsentPurposes.js +180 -0
- package/lib/commonjs/AdsConsentPurposes.js.map +1 -0
- package/lib/commonjs/AdsConsentSpecialFeatures.js +54 -0
- package/lib/commonjs/AdsConsentSpecialFeatures.js.map +1 -0
- package/lib/commonjs/BannerAdSize.js +75 -0
- package/lib/commonjs/BannerAdSize.js.map +1 -0
- package/lib/commonjs/GAMAdEventType.js +44 -0
- package/lib/commonjs/GAMAdEventType.js.map +1 -0
- package/lib/commonjs/MaxAdContentRating.js +42 -0
- package/lib/commonjs/MaxAdContentRating.js.map +1 -0
- package/lib/commonjs/MobileAds.js +63 -0
- package/lib/commonjs/MobileAds.js.map +1 -0
- package/lib/commonjs/NativeAdEventType.js +50 -0
- package/lib/commonjs/NativeAdEventType.js.map +1 -0
- package/lib/commonjs/RewardedAdEventType.js +66 -0
- package/lib/commonjs/RewardedAdEventType.js.map +1 -0
- package/lib/commonjs/TestIds.js +66 -0
- package/lib/commonjs/TestIds.js.map +1 -0
- package/lib/commonjs/ads/AppOpenAd.js +54 -0
- package/lib/commonjs/ads/AppOpenAd.js.map +1 -0
- package/lib/commonjs/ads/BannerAd.js +45 -0
- package/lib/commonjs/ads/BannerAd.js.map +1 -0
- package/lib/commonjs/ads/BaseAd.js +155 -0
- package/lib/commonjs/ads/BaseAd.js.map +1 -0
- package/lib/commonjs/ads/GAMBannerAd.js +49 -0
- package/lib/commonjs/ads/GAMBannerAd.js.map +1 -0
- package/lib/commonjs/ads/GAMInterstitialAd.js +42 -0
- package/lib/commonjs/ads/GAMInterstitialAd.js.map +1 -0
- package/lib/commonjs/ads/InterstitialAd.js +115 -0
- package/lib/commonjs/ads/InterstitialAd.js.map +1 -0
- package/lib/commonjs/ads/MobileAd.js +153 -0
- package/lib/commonjs/ads/MobileAd.js.map +1 -0
- package/lib/commonjs/ads/RewardedAd.js +128 -0
- package/lib/commonjs/ads/RewardedAd.js.map +1 -0
- package/lib/commonjs/ads/RewardedInterstitialAd.js +128 -0
- package/lib/commonjs/ads/RewardedInterstitialAd.js.map +1 -0
- package/lib/commonjs/ads/native-ad/NativeAd.js +123 -0
- package/lib/commonjs/ads/native-ad/NativeAd.js.map +1 -0
- package/lib/commonjs/ads/native-ad/NativeAdContext.js +26 -0
- package/lib/commonjs/ads/native-ad/NativeAdContext.js.map +1 -0
- package/lib/commonjs/ads/native-ad/NativeAdView.js +52 -0
- package/lib/commonjs/ads/native-ad/NativeAdView.js.map +1 -0
- package/lib/commonjs/ads/native-ad/NativeAsset.js +70 -0
- package/lib/commonjs/ads/native-ad/NativeAsset.js.map +1 -0
- package/lib/commonjs/ads/native-ad/NativeMediaView.js +61 -0
- package/lib/commonjs/ads/native-ad/NativeMediaView.js.map +1 -0
- package/lib/commonjs/common/constants.js +17 -0
- package/lib/commonjs/common/constants.js.map +1 -0
- package/lib/commonjs/common/debounce.js +18 -0
- package/lib/commonjs/common/debounce.js.map +1 -0
- package/lib/commonjs/common/index.js +47 -0
- package/lib/commonjs/common/index.js.map +1 -0
- package/lib/commonjs/common/ref.js +46 -0
- package/lib/commonjs/common/ref.js.map +1 -0
- package/lib/commonjs/common/validate.js +132 -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/hooks/useAppOpenAd.js +44 -0
- package/lib/commonjs/hooks/useAppOpenAd.js.map +1 -0
- package/lib/commonjs/hooks/useForeground.js +45 -0
- package/lib/commonjs/hooks/useForeground.js.map +1 -0
- package/lib/commonjs/hooks/useFullScreenAd.js +121 -0
- package/lib/commonjs/hooks/useFullScreenAd.js.map +1 -0
- package/lib/commonjs/hooks/useInterstitialAd.js +44 -0
- package/lib/commonjs/hooks/useInterstitialAd.js.map +1 -0
- package/lib/commonjs/hooks/useRewardedAd.js +44 -0
- package/lib/commonjs/hooks/useRewardedAd.js.map +1 -0
- package/lib/commonjs/hooks/useRewardedInterstitialAd.js +44 -0
- package/lib/commonjs/hooks/useRewardedInterstitialAd.js.map +1 -0
- package/lib/commonjs/index.js +337 -0
- package/lib/commonjs/index.js.map +1 -0
- package/lib/commonjs/internal/GoogleMobileAdsNativeEventEmitter.js +54 -0
- package/lib/commonjs/internal/GoogleMobileAdsNativeEventEmitter.js.map +1 -0
- package/lib/commonjs/internal/NativeError.js +53 -0
- package/lib/commonjs/internal/NativeError.js.map +1 -0
- package/lib/commonjs/internal/SharedEventEmitter.js +27 -0
- package/lib/commonjs/internal/SharedEventEmitter.js.map +1 -0
- package/lib/commonjs/package.json +1 -0
- package/lib/commonjs/specs/components/GoogleMobileAdsBannerViewNativeComponent.ts +62 -0
- package/lib/commonjs/specs/components/GoogleMobileAdsMediaViewNativeComponent.ts +30 -0
- package/lib/commonjs/specs/components/GoogleMobileAdsNativeViewNativeComponent.ts +45 -0
- package/lib/commonjs/specs/modules/NativeAppModule.js +24 -0
- package/lib/commonjs/specs/modules/NativeAppModule.js.map +1 -0
- package/lib/commonjs/specs/modules/NativeAppOpenModule.js +25 -0
- package/lib/commonjs/specs/modules/NativeAppOpenModule.js.map +1 -0
- package/lib/commonjs/specs/modules/NativeConsentModule.js +105 -0
- package/lib/commonjs/specs/modules/NativeConsentModule.js.map +1 -0
- package/lib/commonjs/specs/modules/NativeGoogleMobileAdsModule.js +25 -0
- package/lib/commonjs/specs/modules/NativeGoogleMobileAdsModule.js.map +1 -0
- package/lib/commonjs/specs/modules/NativeGoogleMobileAdsNativeModule.js +25 -0
- package/lib/commonjs/specs/modules/NativeGoogleMobileAdsNativeModule.js.map +1 -0
- package/lib/commonjs/specs/modules/NativeInterstitialModule.js +25 -0
- package/lib/commonjs/specs/modules/NativeInterstitialModule.js.map +1 -0
- package/lib/commonjs/specs/modules/NativeRewardedInterstitialModule.js +25 -0
- package/lib/commonjs/specs/modules/NativeRewardedInterstitialModule.js.map +1 -0
- package/lib/commonjs/specs/modules/NativeRewardedModule.js +25 -0
- package/lib/commonjs/specs/modules/NativeRewardedModule.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/AdEventsListener.js +6 -0
- package/lib/commonjs/types/AdEventsListener.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/AdStates.js +6 -0
- package/lib/commonjs/types/AdStates.js.map +1 -0
- package/lib/commonjs/types/AdapterStatus.js +21 -0
- package/lib/commonjs/types/AdapterStatus.js.map +1 -0
- package/lib/commonjs/types/AppEvent.js +2 -0
- package/lib/commonjs/types/AppEvent.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/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/NativeAdRequestOptions.js +37 -0
- package/lib/commonjs/types/NativeAdRequestOptions.js.map +1 -0
- package/lib/commonjs/types/PaidEventListener.js +6 -0
- package/lib/commonjs/types/PaidEventListener.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/types/index.js +138 -0
- package/lib/commonjs/types/index.js.map +1 -0
- package/lib/commonjs/validateAdRequestConfiguration.js +57 -0
- package/lib/commonjs/validateAdRequestConfiguration.js.map +1 -0
- package/lib/commonjs/validateAdRequestOptions.js +121 -0
- package/lib/commonjs/validateAdRequestOptions.js.map +1 -0
- package/lib/commonjs/validateAdShowOptions.js +41 -0
- package/lib/commonjs/validateAdShowOptions.js.map +1 -0
- package/lib/commonjs/validateNativeAdRequestOptions.js +51 -0
- package/lib/commonjs/validateNativeAdRequestOptions.js.map +1 -0
- package/lib/commonjs/version.js +9 -0
- package/lib/commonjs/version.js.map +1 -0
- package/lib/module/AdEventType.js +69 -0
- package/lib/module/AdEventType.js.map +1 -0
- package/lib/module/AdsConsent.js +113 -0
- package/lib/module/AdsConsent.js.map +1 -0
- package/lib/module/AdsConsentPurposes.js +177 -0
- package/lib/module/AdsConsentPurposes.js.map +1 -0
- package/lib/module/AdsConsentSpecialFeatures.js +51 -0
- package/lib/module/AdsConsentSpecialFeatures.js.map +1 -0
- package/lib/module/BannerAdSize.js +72 -0
- package/lib/module/BannerAdSize.js.map +1 -0
- package/lib/module/GAMAdEventType.js +41 -0
- package/lib/module/GAMAdEventType.js.map +1 -0
- package/lib/module/MaxAdContentRating.js +39 -0
- package/lib/module/MaxAdContentRating.js.map +1 -0
- package/lib/module/MobileAds.js +57 -0
- package/lib/module/MobileAds.js.map +1 -0
- package/lib/module/NativeAdEventType.js +46 -0
- package/lib/module/NativeAdEventType.js.map +1 -0
- package/lib/module/RewardedAdEventType.js +63 -0
- package/lib/module/RewardedAdEventType.js.map +1 -0
- package/lib/module/TestIds.js +62 -0
- package/lib/module/TestIds.js.map +1 -0
- package/lib/module/ads/AppOpenAd.js +48 -0
- package/lib/module/ads/AppOpenAd.js.map +1 -0
- package/lib/module/ads/BannerAd.js +39 -0
- package/lib/module/ads/BannerAd.js.map +1 -0
- package/lib/module/ads/BaseAd.js +149 -0
- package/lib/module/ads/BaseAd.js.map +1 -0
- package/lib/module/ads/GAMBannerAd.js +43 -0
- package/lib/module/ads/GAMBannerAd.js.map +1 -0
- package/lib/module/ads/GAMInterstitialAd.js +37 -0
- package/lib/module/ads/GAMInterstitialAd.js.map +1 -0
- package/lib/module/ads/InterstitialAd.js +110 -0
- package/lib/module/ads/InterstitialAd.js.map +1 -0
- package/lib/module/ads/MobileAd.js +148 -0
- package/lib/module/ads/MobileAd.js.map +1 -0
- package/lib/module/ads/RewardedAd.js +123 -0
- package/lib/module/ads/RewardedAd.js.map +1 -0
- package/lib/module/ads/RewardedInterstitialAd.js +123 -0
- package/lib/module/ads/RewardedInterstitialAd.js.map +1 -0
- package/lib/module/ads/native-ad/NativeAd.js +117 -0
- package/lib/module/ads/native-ad/NativeAd.js.map +1 -0
- package/lib/module/ads/native-ad/NativeAdContext.js +22 -0
- package/lib/module/ads/native-ad/NativeAdContext.js.map +1 -0
- package/lib/module/ads/native-ad/NativeAdView.js +45 -0
- package/lib/module/ads/native-ad/NativeAdView.js.map +1 -0
- package/lib/module/ads/native-ad/NativeAsset.js +65 -0
- package/lib/module/ads/native-ad/NativeAsset.js.map +1 -0
- package/lib/module/ads/native-ad/NativeMediaView.js +54 -0
- package/lib/module/ads/native-ad/NativeMediaView.js.map +1 -0
- package/lib/module/common/constants.js +13 -0
- package/lib/module/common/constants.js.map +1 -0
- package/lib/module/common/debounce.js +13 -0
- package/lib/module/common/debounce.js.map +1 -0
- package/lib/module/common/index.js +28 -0
- package/lib/module/common/index.js.map +1 -0
- package/lib/module/common/ref.js +41 -0
- package/lib/module/common/ref.js.map +1 -0
- package/lib/module/common/validate.js +119 -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/hooks/useAppOpenAd.js +40 -0
- package/lib/module/hooks/useAppOpenAd.js.map +1 -0
- package/lib/module/hooks/useForeground.js +42 -0
- package/lib/module/hooks/useForeground.js.map +1 -0
- package/lib/module/hooks/useFullScreenAd.js +117 -0
- package/lib/module/hooks/useFullScreenAd.js.map +1 -0
- package/lib/module/hooks/useInterstitialAd.js +40 -0
- package/lib/module/hooks/useInterstitialAd.js.map +1 -0
- package/lib/module/hooks/useRewardedAd.js +40 -0
- package/lib/module/hooks/useRewardedAd.js.map +1 -0
- package/lib/module/hooks/useRewardedInterstitialAd.js +40 -0
- package/lib/module/hooks/useRewardedInterstitialAd.js.map +1 -0
- package/lib/module/index.js +54 -0
- package/lib/module/index.js.map +1 -0
- package/lib/module/internal/GoogleMobileAdsNativeEventEmitter.js +49 -0
- package/lib/module/internal/GoogleMobileAdsNativeEventEmitter.js.map +1 -0
- package/lib/module/internal/NativeError.js +48 -0
- package/lib/module/internal/NativeError.js.map +1 -0
- package/lib/module/internal/SharedEventEmitter.js +22 -0
- package/lib/module/internal/SharedEventEmitter.js.map +1 -0
- package/lib/module/specs/components/GoogleMobileAdsBannerViewNativeComponent.ts +62 -0
- package/lib/module/specs/components/GoogleMobileAdsMediaViewNativeComponent.ts +30 -0
- package/lib/module/specs/components/GoogleMobileAdsNativeViewNativeComponent.ts +45 -0
- package/lib/module/specs/modules/NativeAppModule.js +21 -0
- package/lib/module/specs/modules/NativeAppModule.js.map +1 -0
- package/lib/module/specs/modules/NativeAppOpenModule.js +22 -0
- package/lib/module/specs/modules/NativeAppOpenModule.js.map +1 -0
- package/lib/module/specs/modules/NativeConsentModule.js +108 -0
- package/lib/module/specs/modules/NativeConsentModule.js.map +1 -0
- package/lib/module/specs/modules/NativeGoogleMobileAdsModule.js +22 -0
- package/lib/module/specs/modules/NativeGoogleMobileAdsModule.js.map +1 -0
- package/lib/module/specs/modules/NativeGoogleMobileAdsNativeModule.js +22 -0
- package/lib/module/specs/modules/NativeGoogleMobileAdsNativeModule.js.map +1 -0
- package/lib/module/specs/modules/NativeInterstitialModule.js +22 -0
- package/lib/module/specs/modules/NativeInterstitialModule.js.map +1 -0
- package/lib/module/specs/modules/NativeRewardedInterstitialModule.js +22 -0
- package/lib/module/specs/modules/NativeRewardedInterstitialModule.js.map +1 -0
- package/lib/module/specs/modules/NativeRewardedModule.js +22 -0
- package/lib/module/specs/modules/NativeRewardedModule.js.map +1 -0
- package/lib/module/types/AdEventListener.js +4 -0
- package/lib/module/types/AdEventListener.js.map +1 -0
- package/lib/module/types/AdEventsListener.js +4 -0
- package/lib/module/types/AdEventsListener.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/AdStates.js +4 -0
- package/lib/module/types/AdStates.js.map +1 -0
- package/lib/module/types/AdapterStatus.js +18 -0
- package/lib/module/types/AdapterStatus.js.map +1 -0
- package/lib/module/types/AppEvent.js +2 -0
- package/lib/module/types/AppEvent.js.map +1 -0
- package/lib/module/types/BannerAdProps.js +4 -0
- package/lib/module/types/BannerAdProps.js.map +1 -0
- package/lib/module/types/MobileAd.interface.js +4 -0
- package/lib/module/types/MobileAd.interface.js.map +1 -0
- package/lib/module/types/MobileAdsModule.interface.js +4 -0
- package/lib/module/types/MobileAdsModule.interface.js.map +1 -0
- package/lib/module/types/NativeAdRequestOptions.js +34 -0
- package/lib/module/types/NativeAdRequestOptions.js.map +1 -0
- package/lib/module/types/PaidEventListener.js +4 -0
- package/lib/module/types/PaidEventListener.js.map +1 -0
- package/lib/module/types/RequestConfiguration.js +4 -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/types/index.js +32 -0
- package/lib/module/types/index.js.map +1 -0
- package/lib/module/validateAdRequestConfiguration.js +53 -0
- package/lib/module/validateAdRequestConfiguration.js.map +1 -0
- package/lib/module/validateAdRequestOptions.js +117 -0
- package/lib/module/validateAdRequestOptions.js.map +1 -0
- package/lib/module/validateAdShowOptions.js +37 -0
- package/lib/module/validateAdShowOptions.js.map +1 -0
- package/lib/module/validateNativeAdRequestOptions.js +47 -0
- package/lib/module/validateNativeAdRequestOptions.js.map +1 -0
- package/lib/module/version.js +5 -0
- package/lib/module/version.js.map +1 -0
- package/lib/typescript/AdEventType.d.ts +49 -0
- package/lib/typescript/AdEventType.d.ts.map +1 -0
- package/lib/typescript/AdsConsent.d.ts +3 -0
- package/lib/typescript/AdsConsent.d.ts.map +1 -0
- package/lib/typescript/AdsConsentPurposes.d.ts +149 -0
- package/lib/typescript/AdsConsentPurposes.d.ts.map +1 -0
- package/lib/typescript/AdsConsentSpecialFeatures.d.ts +23 -0
- package/lib/typescript/AdsConsentSpecialFeatures.d.ts.map +1 -0
- package/lib/typescript/BannerAdSize.d.ts +91 -0
- package/lib/typescript/BannerAdSize.d.ts.map +1 -0
- package/lib/typescript/GAMAdEventType.d.ts +21 -0
- package/lib/typescript/GAMAdEventType.d.ts.map +1 -0
- package/lib/typescript/MaxAdContentRating.d.ts +19 -0
- package/lib/typescript/MaxAdContentRating.d.ts.map +1 -0
- package/lib/typescript/MobileAds.d.ts +15 -0
- package/lib/typescript/MobileAds.d.ts.map +1 -0
- package/lib/typescript/NativeAdEventType.d.ts +43 -0
- package/lib/typescript/NativeAdEventType.d.ts.map +1 -0
- package/lib/typescript/RewardedAdEventType.d.ts +43 -0
- package/lib/typescript/RewardedAdEventType.d.ts.map +1 -0
- package/lib/typescript/TestIds.d.ts +19 -0
- package/lib/typescript/TestIds.d.ts.map +1 -0
- package/lib/typescript/ads/AppOpenAd.d.ts +12 -0
- package/lib/typescript/ads/AppOpenAd.d.ts.map +1 -0
- package/lib/typescript/ads/BannerAd.d.ts +8 -0
- package/lib/typescript/ads/BannerAd.d.ts.map +1 -0
- package/lib/typescript/ads/BaseAd.d.ts +4 -0
- package/lib/typescript/ads/BaseAd.d.ts.map +1 -0
- package/lib/typescript/ads/GAMBannerAd.d.ts +9 -0
- package/lib/typescript/ads/GAMBannerAd.d.ts.map +1 -0
- package/lib/typescript/ads/GAMInterstitialAd.d.ts +34 -0
- package/lib/typescript/ads/GAMInterstitialAd.d.ts.map +1 -0
- package/lib/typescript/ads/InterstitialAd.d.ts +73 -0
- package/lib/typescript/ads/InterstitialAd.d.ts.map +1 -0
- package/lib/typescript/ads/MobileAd.d.ts +54 -0
- package/lib/typescript/ads/MobileAd.d.ts.map +1 -0
- package/lib/typescript/ads/RewardedAd.d.ts +83 -0
- package/lib/typescript/ads/RewardedAd.d.ts.map +1 -0
- package/lib/typescript/ads/RewardedInterstitialAd.d.ts +83 -0
- package/lib/typescript/ads/RewardedInterstitialAd.d.ts.map +1 -0
- package/lib/typescript/ads/native-ad/NativeAd.d.ts +48 -0
- package/lib/typescript/ads/native-ad/NativeAd.d.ts.map +1 -0
- package/lib/typescript/ads/native-ad/NativeAdContext.d.ts +10 -0
- package/lib/typescript/ads/native-ad/NativeAdContext.d.ts.map +1 -0
- package/lib/typescript/ads/native-ad/NativeAdView.d.ts +8 -0
- package/lib/typescript/ads/native-ad/NativeAdView.d.ts.map +1 -0
- package/lib/typescript/ads/native-ad/NativeAsset.d.ts +18 -0
- package/lib/typescript/ads/native-ad/NativeAsset.d.ts.map +1 -0
- package/lib/typescript/ads/native-ad/NativeMediaView.d.ts +7 -0
- package/lib/typescript/ads/native-ad/NativeMediaView.d.ts.map +1 -0
- package/lib/typescript/common/constants.d.ts +7 -0
- package/lib/typescript/common/constants.d.ts.map +1 -0
- package/lib/typescript/common/debounce.d.ts +2 -0
- package/lib/typescript/common/debounce.d.ts.map +1 -0
- package/lib/typescript/common/index.d.ts +4 -0
- package/lib/typescript/common/index.d.ts.map +1 -0
- package/lib/typescript/common/ref.d.ts +13 -0
- package/lib/typescript/common/ref.d.ts.map +1 -0
- package/lib/typescript/common/validate.d.ts +62 -0
- package/lib/typescript/common/validate.d.ts.map +1 -0
- package/lib/typescript/hooks/useAppOpenAd.d.ts +10 -0
- package/lib/typescript/hooks/useAppOpenAd.d.ts.map +1 -0
- package/lib/typescript/hooks/useForeground.d.ts +7 -0
- package/lib/typescript/hooks/useForeground.d.ts.map +1 -0
- package/lib/typescript/hooks/useFullScreenAd.d.ts +7 -0
- package/lib/typescript/hooks/useFullScreenAd.d.ts.map +1 -0
- package/lib/typescript/hooks/useInterstitialAd.d.ts +10 -0
- package/lib/typescript/hooks/useInterstitialAd.d.ts.map +1 -0
- package/lib/typescript/hooks/useRewardedAd.d.ts +10 -0
- package/lib/typescript/hooks/useRewardedAd.d.ts.map +1 -0
- package/lib/typescript/hooks/useRewardedInterstitialAd.d.ts +10 -0
- package/lib/typescript/hooks/useRewardedInterstitialAd.d.ts.map +1 -0
- package/lib/typescript/index.d.ts +32 -0
- package/lib/typescript/index.d.ts.map +1 -0
- package/lib/typescript/internal/GoogleMobileAdsNativeEventEmitter.d.ts +13 -0
- package/lib/typescript/internal/GoogleMobileAdsNativeEventEmitter.d.ts.map +1 -0
- package/lib/typescript/internal/NativeError.d.ts +27 -0
- package/lib/typescript/internal/NativeError.d.ts.map +1 -0
- package/lib/typescript/internal/SharedEventEmitter.d.ts +3 -0
- package/lib/typescript/internal/SharedEventEmitter.d.ts.map +1 -0
- package/lib/typescript/specs/components/GoogleMobileAdsBannerViewNativeComponent.d.ts +35 -0
- package/lib/typescript/specs/components/GoogleMobileAdsBannerViewNativeComponent.d.ts.map +1 -0
- package/lib/typescript/specs/components/GoogleMobileAdsMediaViewNativeComponent.d.ts +9 -0
- package/lib/typescript/specs/components/GoogleMobileAdsMediaViewNativeComponent.d.ts.map +1 -0
- package/lib/typescript/specs/components/GoogleMobileAdsNativeViewNativeComponent.d.ts +14 -0
- package/lib/typescript/specs/components/GoogleMobileAdsNativeViewNativeComponent.d.ts.map +1 -0
- package/lib/typescript/specs/modules/NativeAppModule.d.ts +23 -0
- package/lib/typescript/specs/modules/NativeAppModule.d.ts.map +1 -0
- package/lib/typescript/specs/modules/NativeAppOpenModule.d.ts +25 -0
- package/lib/typescript/specs/modules/NativeAppOpenModule.d.ts.map +1 -0
- package/lib/typescript/specs/modules/NativeConsentModule.d.ts +498 -0
- package/lib/typescript/specs/modules/NativeConsentModule.d.ts.map +1 -0
- package/lib/typescript/specs/modules/NativeGoogleMobileAdsModule.d.ts +14 -0
- package/lib/typescript/specs/modules/NativeGoogleMobileAdsModule.d.ts.map +1 -0
- package/lib/typescript/specs/modules/NativeGoogleMobileAdsNativeModule.d.ts +42 -0
- package/lib/typescript/specs/modules/NativeGoogleMobileAdsNativeModule.d.ts.map +1 -0
- package/lib/typescript/specs/modules/NativeInterstitialModule.d.ts +25 -0
- package/lib/typescript/specs/modules/NativeInterstitialModule.d.ts.map +1 -0
- package/lib/typescript/specs/modules/NativeRewardedInterstitialModule.d.ts +25 -0
- package/lib/typescript/specs/modules/NativeRewardedInterstitialModule.d.ts.map +1 -0
- package/lib/typescript/specs/modules/NativeRewardedModule.d.ts +25 -0
- package/lib/typescript/specs/modules/NativeRewardedModule.d.ts.map +1 -0
- package/lib/typescript/types/AdEventListener.d.ts +8 -0
- package/lib/typescript/types/AdEventListener.d.ts.map +1 -0
- package/lib/typescript/types/AdEventsListener.d.ts +9 -0
- package/lib/typescript/types/AdEventsListener.d.ts.map +1 -0
- package/lib/typescript/types/AdShowOptions.d.ts +13 -0
- package/lib/typescript/types/AdShowOptions.d.ts.map +1 -0
- package/lib/typescript/types/AdStates.d.ts +91 -0
- package/lib/typescript/types/AdStates.d.ts.map +1 -0
- package/lib/typescript/types/AdapterStatus.d.ts +19 -0
- package/lib/typescript/types/AdapterStatus.d.ts.map +1 -0
- package/lib/typescript/types/AppEvent.d.ts +14 -0
- package/lib/typescript/types/AppEvent.d.ts.map +1 -0
- package/lib/typescript/types/BannerAdProps.d.ts +175 -0
- package/lib/typescript/types/BannerAdProps.d.ts.map +1 -0
- package/lib/typescript/types/MobileAd.interface.d.ts +90 -0
- package/lib/typescript/types/MobileAd.interface.d.ts.map +1 -0
- package/lib/typescript/types/MobileAdsModule.interface.d.ts +75 -0
- package/lib/typescript/types/MobileAdsModule.interface.d.ts.map +1 -0
- package/lib/typescript/types/NativeAdRequestOptions.d.ts +36 -0
- package/lib/typescript/types/NativeAdRequestOptions.d.ts.map +1 -0
- package/lib/typescript/types/PaidEventListener.d.ts +8 -0
- package/lib/typescript/types/PaidEventListener.d.ts.map +1 -0
- package/lib/typescript/types/RequestConfiguration.d.ts +37 -0
- package/lib/typescript/types/RequestConfiguration.d.ts.map +1 -0
- package/lib/typescript/types/RequestOptions.d.ts +133 -0
- package/lib/typescript/types/RequestOptions.d.ts.map +1 -0
- package/lib/typescript/types/RewardedAdReward.d.ts +14 -0
- package/lib/typescript/types/RewardedAdReward.d.ts.map +1 -0
- package/lib/typescript/types/index.d.ts +13 -0
- package/lib/typescript/types/index.d.ts.map +1 -0
- package/lib/typescript/validateAdRequestConfiguration.d.ts +3 -0
- package/lib/typescript/validateAdRequestConfiguration.d.ts.map +1 -0
- package/lib/typescript/validateAdRequestOptions.d.ts +3 -0
- package/lib/typescript/validateAdRequestOptions.d.ts.map +1 -0
- package/lib/typescript/validateAdShowOptions.d.ts +3 -0
- package/lib/typescript/validateAdShowOptions.d.ts.map +1 -0
- package/lib/typescript/validateNativeAdRequestOptions.d.ts +3 -0
- package/lib/typescript/validateNativeAdRequestOptions.d.ts.map +1 -0
- package/lib/typescript/version.d.ts +2 -0
- package/lib/typescript/version.d.ts.map +1 -0
- package/package.json +176 -0
- package/plugin/__tests__/__snapshots__/plugin.test.ts.snap +739 -0
- package/plugin/__tests__/fixtures/app.config.js +24 -0
- package/plugin/__tests__/fixtures/app.config.ts +24 -0
- package/plugin/__tests__/fixtures/app.json +24 -0
- package/plugin/__tests__/fixtures/package.json +19 -0
- package/plugin/__tests__/fixtures/without-params/app.config.js +11 -0
- package/plugin/__tests__/fixtures/without-params/app.config.ts +11 -0
- package/plugin/__tests__/fixtures/without-params/app.json +11 -0
- package/plugin/__tests__/plugin.test.ts +115 -0
- package/plugin/build/index.d.ts +12 -0
- package/plugin/build/index.js +109 -0
- package/plugin/jest.config.js +1 -0
- package/plugin/src/index.ts +205 -0
- package/plugin/tsconfig.json +9 -0
- package/plugin/tsconfig.tsbuildinfo +1 -0
- package/react-native.config.js +19 -0
- package/src/AdEventType.ts +70 -0
- package/src/AdsConsent.ts +170 -0
- package/src/AdsConsentPurposes.ts +182 -0
- package/src/AdsConsentSpecialFeatures.ts +48 -0
- package/src/BannerAdSize.ts +78 -0
- package/src/GAMAdEventType.ts +37 -0
- package/src/MaxAdContentRating.ts +38 -0
- package/src/MobileAds.ts +77 -0
- package/src/NativeAdEventType.ts +51 -0
- package/src/RewardedAdEventType.ts +60 -0
- package/src/TestIds.ts +60 -0
- package/src/ads/AppOpenAd.ts +62 -0
- package/src/ads/BannerAd.tsx +37 -0
- package/src/ads/BaseAd.tsx +185 -0
- package/src/ads/GAMBannerAd.tsx +43 -0
- package/src/ads/GAMInterstitialAd.ts +45 -0
- package/src/ads/InterstitialAd.ts +122 -0
- package/src/ads/MobileAd.ts +227 -0
- package/src/ads/RewardedAd.ts +142 -0
- package/src/ads/RewardedInterstitialAd.ts +144 -0
- package/src/ads/native-ad/NativeAd.ts +159 -0
- package/src/ads/native-ad/NativeAdContext.ts +26 -0
- package/src/ads/native-ad/NativeAdView.tsx +43 -0
- package/src/ads/native-ad/NativeAsset.tsx +66 -0
- package/src/ads/native-ad/NativeMediaView.tsx +44 -0
- package/src/common/constants.ts +9 -0
- package/src/common/debounce.ts +15 -0
- package/src/common/index.ts +30 -0
- package/src/common/ref.ts +46 -0
- package/src/common/validate.ts +116 -0
- package/src/declarations.d.ts +3 -0
- package/src/hooks/useAppOpenAd.ts +46 -0
- package/src/hooks/useForeground.ts +41 -0
- package/src/hooks/useFullScreenAd.ts +112 -0
- package/src/hooks/useInterstitialAd.ts +46 -0
- package/src/hooks/useRewardedAd.ts +46 -0
- package/src/hooks/useRewardedInterstitialAd.ts +47 -0
- package/src/index.ts +60 -0
- package/src/internal/GoogleMobileAdsNativeEventEmitter.ts +58 -0
- package/src/internal/NativeError.ts +56 -0
- package/src/internal/SharedEventEmitter.ts +20 -0
- package/src/specs/components/GoogleMobileAdsBannerViewNativeComponent.ts +62 -0
- package/src/specs/components/GoogleMobileAdsMediaViewNativeComponent.ts +30 -0
- package/src/specs/components/GoogleMobileAdsNativeViewNativeComponent.ts +45 -0
- package/src/specs/modules/NativeAppModule.ts +57 -0
- package/src/specs/modules/NativeAppOpenModule.ts +26 -0
- package/src/specs/modules/NativeConsentModule.ts +532 -0
- package/src/specs/modules/NativeGoogleMobileAdsModule.ts +33 -0
- package/src/specs/modules/NativeGoogleMobileAdsNativeModule.ts +70 -0
- package/src/specs/modules/NativeInterstitialModule.ts +26 -0
- package/src/specs/modules/NativeRewardedInterstitialModule.ts +32 -0
- package/src/specs/modules/NativeRewardedModule.ts +26 -0
- package/src/types/AdEventListener.ts +34 -0
- package/src/types/AdEventsListener.ts +24 -0
- package/src/types/AdShowOptions.ts +12 -0
- package/src/types/AdStates.ts +92 -0
- package/src/types/AdapterStatus.ts +20 -0
- package/src/types/AppEvent.ts +14 -0
- package/src/types/BannerAdProps.ts +184 -0
- package/src/types/MobileAd.interface.ts +113 -0
- package/src/types/MobileAdsModule.interface.ts +80 -0
- package/src/types/NativeAdRequestOptions.ts +55 -0
- package/src/types/PaidEventListener.ts +9 -0
- package/src/types/RequestConfiguration.ts +40 -0
- package/src/types/RequestOptions.ts +137 -0
- package/src/types/RewardedAdReward.ts +14 -0
- package/src/types/index.ts +29 -0
- package/src/validateAdRequestConfiguration.ts +66 -0
- package/src/validateAdRequestOptions.ts +154 -0
- package/src/validateAdShowOptions.ts +41 -0
- package/src/validateNativeAdRequestOptions.ts +50 -0
- package/src/version.ts +2 -0
|
@@ -0,0 +1,60 @@
|
|
|
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 RewardedAdEventType {
|
|
19
|
+
/**
|
|
20
|
+
* An event fired when a rewarded ad has loaded.
|
|
21
|
+
*
|
|
22
|
+
* This type differs from `AdEventType.LOADED` as when a rewarded ad is loaded,
|
|
23
|
+
* an additional data payload is provided to the event handler containing the ad reward
|
|
24
|
+
* (assuming the user earns the reward).
|
|
25
|
+
*
|
|
26
|
+
* The reward contains a `type` and `amount`.
|
|
27
|
+
*
|
|
28
|
+
* #### Example
|
|
29
|
+
*
|
|
30
|
+
* ```js
|
|
31
|
+
* import { RewardedAdEventType } from 'react-native-google-mobile-ads';
|
|
32
|
+
*
|
|
33
|
+
* rewardedAd.addEventListener(RewardedAdEventType.LOADED, (reward) => {
|
|
34
|
+
* console.log(`Rewarded Ad loaded with ${data.amount} ${data.type} as reward`);
|
|
35
|
+
* // E.g. "Rewarded Ad loaded with 50 coins as reward"
|
|
36
|
+
* rewardedAd.show();
|
|
37
|
+
* });
|
|
38
|
+
* ```
|
|
39
|
+
*/
|
|
40
|
+
LOADED = 'rewarded_loaded',
|
|
41
|
+
|
|
42
|
+
/**
|
|
43
|
+
* An event fired when the user earned the reward for the video. If the user does not earn a reward,
|
|
44
|
+
* the `AdEventType.CLOSED` event will be fired with no rewarded event.
|
|
45
|
+
*
|
|
46
|
+
* The reward contains a `type` and `amount`.
|
|
47
|
+
*
|
|
48
|
+
* #### Example
|
|
49
|
+
*
|
|
50
|
+
* ```js
|
|
51
|
+
* import { RewardedAdEventType } from 'react-native-google-mobile-ads';
|
|
52
|
+
*
|
|
53
|
+
* rewardedAd.addEventListener(RewardedAdEventType.EARNED_REWARD, (reward) => {
|
|
54
|
+
* console.log(`User earned ${data.amount} ${data.type}`);
|
|
55
|
+
* // E.g. "User earned 50 coins"
|
|
56
|
+
* });
|
|
57
|
+
* ```
|
|
58
|
+
*/
|
|
59
|
+
EARNED_REWARD = 'rewarded_earned_reward',
|
|
60
|
+
}
|
package/src/TestIds.ts
ADDED
|
@@ -0,0 +1,60 @@
|
|
|
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 { Platform } from 'react-native';
|
|
19
|
+
|
|
20
|
+
export const TestIds = {
|
|
21
|
+
APP_OPEN: '',
|
|
22
|
+
ADAPTIVE_BANNER: '',
|
|
23
|
+
BANNER: '',
|
|
24
|
+
INTERSTITIAL: '',
|
|
25
|
+
REWARDED: '',
|
|
26
|
+
REWARDED_INTERSTITIAL: '',
|
|
27
|
+
NATIVE: '',
|
|
28
|
+
NATIVE_VIDEO: '',
|
|
29
|
+
GAM_APP_OPEN: '/21775744923/example/app-open',
|
|
30
|
+
GAM_BANNER: '/21775744923/example/fixed-size-banner',
|
|
31
|
+
GAM_INTERSTITIAL: '/21775744923/example/interstitial',
|
|
32
|
+
GAM_REWARDED: '/21775744923/example/rewarded',
|
|
33
|
+
GAM_REWARDED_INTERSTITIAL: '/21775744923/example/rewarded-interstitial',
|
|
34
|
+
GAM_NATIVE: '/21775744923/example/native',
|
|
35
|
+
GAM_NATIVE_VIDEO: '/21775744923/example/native-video',
|
|
36
|
+
...Platform.select({
|
|
37
|
+
android: {
|
|
38
|
+
APP_OPEN: 'ca-app-pub-3940256099942544/9257395921',
|
|
39
|
+
ADAPTIVE_BANNER: 'ca-app-pub-3940256099942544/9214589741',
|
|
40
|
+
BANNER: 'ca-app-pub-3940256099942544/6300978111',
|
|
41
|
+
INTERSTITIAL: 'ca-app-pub-3940256099942544/1033173712',
|
|
42
|
+
INTERSTITIAL_VIDEO: 'ca-app-pub-3940256099942544/8691691433',
|
|
43
|
+
REWARDED: 'ca-app-pub-3940256099942544/5224354917',
|
|
44
|
+
REWARDED_INTERSTITIAL: 'ca-app-pub-3940256099942544/5354046379',
|
|
45
|
+
NATIVE: 'ca-app-pub-3940256099942544/2247696110',
|
|
46
|
+
NATIVE_VIDEO: 'ca-app-pub-3940256099942544/1044960115',
|
|
47
|
+
},
|
|
48
|
+
ios: {
|
|
49
|
+
APP_OPEN: 'ca-app-pub-3940256099942544/5575463023',
|
|
50
|
+
ADAPTIVE_BANNER: 'ca-app-pub-3940256099942544/2435281174',
|
|
51
|
+
BANNER: 'ca-app-pub-3940256099942544/2934735716',
|
|
52
|
+
INTERSTITIAL: 'ca-app-pub-3940256099942544/4411468910',
|
|
53
|
+
INTERSTITIAL_VIDEO: 'ca-app-pub-3940256099942544/5135589807',
|
|
54
|
+
REWARDED: 'ca-app-pub-3940256099942544/1712485313',
|
|
55
|
+
REWARDED_INTERSTITIAL: 'ca-app-pub-3940256099942544/6978759866',
|
|
56
|
+
NATIVE: 'ca-app-pub-3940256099942544/3986624511',
|
|
57
|
+
NATIVE_VIDEO: 'ca-app-pub-3940256099942544/2521693316',
|
|
58
|
+
},
|
|
59
|
+
}),
|
|
60
|
+
};
|
|
@@ -0,0 +1,62 @@
|
|
|
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 { isString } from '../common';
|
|
19
|
+
import { validateAdRequestOptions } from '../validateAdRequestOptions';
|
|
20
|
+
import { MobileAd } from './MobileAd';
|
|
21
|
+
import { AdEventType } from '../AdEventType';
|
|
22
|
+
import { AdEventListener } from '../types/AdEventListener';
|
|
23
|
+
import { AdEventsListener } from '../types/AdEventsListener';
|
|
24
|
+
import { RequestOptions } from '../types/RequestOptions';
|
|
25
|
+
import NativeAppOpenModule from '../specs/modules/NativeAppOpenModule';
|
|
26
|
+
|
|
27
|
+
export class AppOpenAd extends MobileAd {
|
|
28
|
+
protected static _appOpenRequest = 0;
|
|
29
|
+
|
|
30
|
+
static createForAdRequest(adUnitId: string, requestOptions?: RequestOptions) {
|
|
31
|
+
if (!isString(adUnitId)) {
|
|
32
|
+
throw new Error("AppOpenAd.createForAdRequest(*) 'adUnitId' expected an string value.");
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
let options = {};
|
|
36
|
+
try {
|
|
37
|
+
options = validateAdRequestOptions(requestOptions);
|
|
38
|
+
} catch (e) {
|
|
39
|
+
if (e instanceof Error) {
|
|
40
|
+
throw new Error(`AppOpenAd.createForAdRequest(_, *) ${e.message}.`);
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
const requestId = AppOpenAd._appOpenRequest++;
|
|
45
|
+
return new AppOpenAd(
|
|
46
|
+
'app_open',
|
|
47
|
+
requestId,
|
|
48
|
+
adUnitId,
|
|
49
|
+
NativeAppOpenModule.appOpenLoad.bind(this),
|
|
50
|
+
NativeAppOpenModule.appOpenShow.bind(this),
|
|
51
|
+
options,
|
|
52
|
+
);
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
addAdEventsListener<T extends AdEventType>(listener: AdEventsListener<T>): () => void {
|
|
56
|
+
return this._addAdEventsListener(listener);
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
addAdEventListener<T extends AdEventType>(type: T, listener: AdEventListener<T>) {
|
|
60
|
+
return this._addAdEventListener(type, listener);
|
|
61
|
+
}
|
|
62
|
+
}
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Copyright (c) 2016-present Invertase Limited & Contributors
|
|
3
|
+
*
|
|
4
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
5
|
+
* you may not use this library except in compliance with the License.
|
|
6
|
+
* You may obtain a copy of the License at
|
|
7
|
+
*
|
|
8
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
9
|
+
*
|
|
10
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
11
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
12
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
13
|
+
* See the License for the specific language governing permissions and
|
|
14
|
+
* limitations under the License.
|
|
15
|
+
*
|
|
16
|
+
*/
|
|
17
|
+
|
|
18
|
+
import React, { createRef } from 'react';
|
|
19
|
+
import { BannerAdProps } from '../types/BannerAdProps';
|
|
20
|
+
import { BaseAd } from './BaseAd';
|
|
21
|
+
import GoogleMobileAdsBannerView, {
|
|
22
|
+
Commands,
|
|
23
|
+
} from '../specs/components/GoogleMobileAdsBannerViewNativeComponent';
|
|
24
|
+
|
|
25
|
+
export class BannerAd extends React.Component<BannerAdProps> {
|
|
26
|
+
private ref = createRef<React.ComponentRef<typeof GoogleMobileAdsBannerView>>();
|
|
27
|
+
|
|
28
|
+
load() {
|
|
29
|
+
if (this.ref.current) {
|
|
30
|
+
Commands.load(this.ref.current);
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
render() {
|
|
35
|
+
return <BaseAd ref={this.ref} sizes={[this.props.size]} {...this.props} />;
|
|
36
|
+
}
|
|
37
|
+
}
|
|
@@ -0,0 +1,185 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Copyright (c) 2016-present Invertase Limited & Contributors
|
|
3
|
+
*
|
|
4
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
5
|
+
* you may not use this library except in compliance with the License.
|
|
6
|
+
* You may obtain a copy of the License at
|
|
7
|
+
*
|
|
8
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
9
|
+
*
|
|
10
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
11
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
12
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
13
|
+
* See the License for the specific language governing permissions and
|
|
14
|
+
* limitations under the License.
|
|
15
|
+
*
|
|
16
|
+
*/
|
|
17
|
+
|
|
18
|
+
import React, { useState, useEffect, useMemo } from 'react';
|
|
19
|
+
import { DimensionValue, NativeSyntheticEvent, Platform } from 'react-native';
|
|
20
|
+
import { isFunction } from '../common';
|
|
21
|
+
import { RevenuePrecisions } from '../common/constants';
|
|
22
|
+
import { NativeError } from '../internal/NativeError';
|
|
23
|
+
import GoogleMobileAdsBannerView from '../specs/components/GoogleMobileAdsBannerViewNativeComponent';
|
|
24
|
+
import type { NativeEvent } from '../specs/components/GoogleMobileAdsBannerViewNativeComponent';
|
|
25
|
+
import { BannerAdSize, GAMBannerAdSize } from '../BannerAdSize';
|
|
26
|
+
import { validateAdRequestOptions } from '../validateAdRequestOptions';
|
|
27
|
+
import { GAMBannerAdProps } from '../types/BannerAdProps';
|
|
28
|
+
import { debounce } from '../common/debounce';
|
|
29
|
+
|
|
30
|
+
const sizeRegex = /([0-9]+)x([0-9]+)/;
|
|
31
|
+
|
|
32
|
+
export const BaseAd = React.forwardRef<
|
|
33
|
+
React.ComponentRef<typeof GoogleMobileAdsBannerView>,
|
|
34
|
+
GAMBannerAdProps
|
|
35
|
+
>(
|
|
36
|
+
(
|
|
37
|
+
{ unitId, sizes, maxHeight, width, requestOptions, manualImpressionsEnabled, ...props },
|
|
38
|
+
ref,
|
|
39
|
+
) => {
|
|
40
|
+
const [dimensions, setDimensions] = useState<(number | DimensionValue)[]>([0, 0]);
|
|
41
|
+
|
|
42
|
+
const debouncedSetDimensions = debounce(setDimensions, 100);
|
|
43
|
+
|
|
44
|
+
useEffect(() => {
|
|
45
|
+
if (!unitId) {
|
|
46
|
+
throw new Error("BannerAd: 'unitId' expected a valid string unit ID.");
|
|
47
|
+
}
|
|
48
|
+
}, [unitId]);
|
|
49
|
+
|
|
50
|
+
useEffect(() => {
|
|
51
|
+
if (
|
|
52
|
+
sizes.length === 0 ||
|
|
53
|
+
!sizes.every(
|
|
54
|
+
size => size in BannerAdSize || size in GAMBannerAdSize || sizeRegex.test(size),
|
|
55
|
+
)
|
|
56
|
+
) {
|
|
57
|
+
throw new Error("BannerAd: 'size(s)' expected a valid BannerAdSize or custom size string.");
|
|
58
|
+
}
|
|
59
|
+
}, [sizes]);
|
|
60
|
+
|
|
61
|
+
const validatedRequestOptions = useMemo(() => {
|
|
62
|
+
if (requestOptions) {
|
|
63
|
+
try {
|
|
64
|
+
return validateAdRequestOptions(requestOptions);
|
|
65
|
+
} catch (e) {
|
|
66
|
+
if (e instanceof Error) {
|
|
67
|
+
throw new Error(`BannerAd: ${e.message}`);
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
return {};
|
|
72
|
+
}, [requestOptions]);
|
|
73
|
+
|
|
74
|
+
function onNativeEvent(event: NativeSyntheticEvent<NativeEvent>) {
|
|
75
|
+
const nativeEvent = event.nativeEvent as
|
|
76
|
+
| {
|
|
77
|
+
type: 'onAdLoaded' | 'onSizeChange';
|
|
78
|
+
width: number;
|
|
79
|
+
height: number;
|
|
80
|
+
}
|
|
81
|
+
| { type: 'onAdOpened' | 'onAdClosed' | 'onAdImpression' | 'onAdClicked' }
|
|
82
|
+
| {
|
|
83
|
+
type: 'onAdFailedToLoad';
|
|
84
|
+
code: string;
|
|
85
|
+
message: string;
|
|
86
|
+
}
|
|
87
|
+
| {
|
|
88
|
+
type: 'onAppEvent';
|
|
89
|
+
name: string;
|
|
90
|
+
data?: string;
|
|
91
|
+
}
|
|
92
|
+
| {
|
|
93
|
+
type: 'onPaid';
|
|
94
|
+
currency: string;
|
|
95
|
+
precision: RevenuePrecisions;
|
|
96
|
+
value: number;
|
|
97
|
+
};
|
|
98
|
+
const { type } = nativeEvent;
|
|
99
|
+
|
|
100
|
+
if (isFunction(props[type])) {
|
|
101
|
+
let eventHandler, eventPayload;
|
|
102
|
+
switch (type) {
|
|
103
|
+
case 'onAdLoaded':
|
|
104
|
+
case 'onSizeChange':
|
|
105
|
+
eventPayload = {
|
|
106
|
+
width: nativeEvent.width,
|
|
107
|
+
height: nativeEvent.height,
|
|
108
|
+
};
|
|
109
|
+
if ((eventHandler = props[type])) eventHandler(eventPayload);
|
|
110
|
+
break;
|
|
111
|
+
case 'onAdFailedToLoad':
|
|
112
|
+
eventPayload = NativeError.fromEvent(nativeEvent, 'googleMobileAds');
|
|
113
|
+
if ((eventHandler = props[type])) eventHandler(eventPayload);
|
|
114
|
+
break;
|
|
115
|
+
case 'onAppEvent':
|
|
116
|
+
eventPayload = {
|
|
117
|
+
name: nativeEvent.name,
|
|
118
|
+
data: nativeEvent.data,
|
|
119
|
+
};
|
|
120
|
+
if ((eventHandler = props[type])) eventHandler(eventPayload);
|
|
121
|
+
break;
|
|
122
|
+
case 'onPaid':
|
|
123
|
+
const handler = props[type];
|
|
124
|
+
if (handler) {
|
|
125
|
+
handler({
|
|
126
|
+
currency: nativeEvent.currency,
|
|
127
|
+
precision: nativeEvent.precision,
|
|
128
|
+
value: nativeEvent.value,
|
|
129
|
+
});
|
|
130
|
+
}
|
|
131
|
+
break;
|
|
132
|
+
default:
|
|
133
|
+
if ((eventHandler = props[type])) eventHandler();
|
|
134
|
+
}
|
|
135
|
+
}
|
|
136
|
+
|
|
137
|
+
if (type === 'onAdLoaded' || type === 'onSizeChange') {
|
|
138
|
+
const width = Math.ceil(nativeEvent.width);
|
|
139
|
+
const height = Math.ceil(nativeEvent.height);
|
|
140
|
+
|
|
141
|
+
if (width && height && JSON.stringify([width, height]) !== JSON.stringify(dimensions)) {
|
|
142
|
+
/**
|
|
143
|
+
* On Android, it seems the ad size is not always the definitive on the first onAdLoaded event.
|
|
144
|
+
* So if we change the size here with an incorrect value, then we relayout the ad on native side
|
|
145
|
+
* and it might cause an incorrect size to be set.
|
|
146
|
+
*
|
|
147
|
+
* To reproduce this issue, go to the example app, on the "GAMBanner Fluid" example
|
|
148
|
+
* and reload the ad several times
|
|
149
|
+
*
|
|
150
|
+
* on my low-end Samsung A10s, it always took less than 100ms in debug mode to get the correct size
|
|
151
|
+
* hence the 100ms debounce
|
|
152
|
+
*/
|
|
153
|
+
if (sizes.includes(GAMBannerAdSize.FLUID) && Platform.OS === 'android') {
|
|
154
|
+
debouncedSetDimensions([width, height]);
|
|
155
|
+
} else {
|
|
156
|
+
setDimensions([width, height]);
|
|
157
|
+
}
|
|
158
|
+
}
|
|
159
|
+
}
|
|
160
|
+
}
|
|
161
|
+
|
|
162
|
+
const style = sizes.includes(GAMBannerAdSize.FLUID)
|
|
163
|
+
? {
|
|
164
|
+
width: '100%' as DimensionValue,
|
|
165
|
+
height: dimensions[1],
|
|
166
|
+
}
|
|
167
|
+
: {
|
|
168
|
+
width: dimensions[0],
|
|
169
|
+
height: dimensions[1],
|
|
170
|
+
};
|
|
171
|
+
|
|
172
|
+
return (
|
|
173
|
+
<GoogleMobileAdsBannerView
|
|
174
|
+
ref={ref}
|
|
175
|
+
sizeConfig={{ sizes, maxHeight, width }}
|
|
176
|
+
style={style}
|
|
177
|
+
unitId={unitId}
|
|
178
|
+
request={JSON.stringify(validatedRequestOptions)}
|
|
179
|
+
manualImpressionsEnabled={!!manualImpressionsEnabled}
|
|
180
|
+
onNativeEvent={onNativeEvent}
|
|
181
|
+
/>
|
|
182
|
+
);
|
|
183
|
+
},
|
|
184
|
+
);
|
|
185
|
+
BaseAd.displayName = 'BaseAd';
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Copyright (c) 2016-present Invertase Limited & Contributors
|
|
3
|
+
*
|
|
4
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
5
|
+
* you may not use this library except in compliance with the License.
|
|
6
|
+
* You may obtain a copy of the License at
|
|
7
|
+
*
|
|
8
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
9
|
+
*
|
|
10
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
11
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
12
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
13
|
+
* See the License for the specific language governing permissions and
|
|
14
|
+
* limitations under the License.
|
|
15
|
+
*
|
|
16
|
+
*/
|
|
17
|
+
|
|
18
|
+
import React, { createRef } from 'react';
|
|
19
|
+
import { GAMBannerAdProps } from '../types/BannerAdProps';
|
|
20
|
+
import { BaseAd } from './BaseAd';
|
|
21
|
+
import GoogleMobileAdsBannerView, {
|
|
22
|
+
Commands,
|
|
23
|
+
} from '../specs/components/GoogleMobileAdsBannerViewNativeComponent';
|
|
24
|
+
|
|
25
|
+
export class GAMBannerAd extends React.Component<GAMBannerAdProps> {
|
|
26
|
+
private ref = createRef<React.ComponentRef<typeof GoogleMobileAdsBannerView>>();
|
|
27
|
+
|
|
28
|
+
recordManualImpression() {
|
|
29
|
+
if (this.ref.current) {
|
|
30
|
+
Commands.recordManualImpression(this.ref.current);
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
load() {
|
|
35
|
+
if (this.ref.current) {
|
|
36
|
+
Commands.load(this.ref.current);
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
render() {
|
|
41
|
+
return <BaseAd ref={this.ref} {...this.props} />;
|
|
42
|
+
}
|
|
43
|
+
}
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
import { AdEventType } from '../AdEventType';
|
|
2
|
+
import { GAMAdEventType } from '../GAMAdEventType';
|
|
3
|
+
import { AdEventListener } from '../types/AdEventListener';
|
|
4
|
+
import { AdEventsListener } from '../types/AdEventsListener';
|
|
5
|
+
import { RequestOptions } from '../types/RequestOptions';
|
|
6
|
+
import { InterstitialAd } from './InterstitialAd';
|
|
7
|
+
|
|
8
|
+
export class GAMInterstitialAd extends InterstitialAd {
|
|
9
|
+
/**
|
|
10
|
+
* Creates a new GAMInterstitialAd instance.
|
|
11
|
+
*
|
|
12
|
+
* #### Example
|
|
13
|
+
*
|
|
14
|
+
* ```js
|
|
15
|
+
* import { GAMInterstitialAd, AdEventType, TestIds } from 'react-native-google-mobile-ads';
|
|
16
|
+
*
|
|
17
|
+
* const interstitialAd = await GAMInterstitialAd.createForAdRequest(TestIds.GAM_INTERSTITIAL, {
|
|
18
|
+
* requestAgent: 'CoolAds',
|
|
19
|
+
* });
|
|
20
|
+
*
|
|
21
|
+
* interstitialAd.addAdEventListener(AdEventType.Loaded, () => {
|
|
22
|
+
* interstitialAd.show();
|
|
23
|
+
* });
|
|
24
|
+
*
|
|
25
|
+
* interstitialAd.load();
|
|
26
|
+
* ```
|
|
27
|
+
*
|
|
28
|
+
* @param adUnitId The Ad Unit ID for the Interstitial. You can find this on your Google Mobile Ads dashboard.
|
|
29
|
+
* @param requestOptions Optional RequestOptions used to load the ad.
|
|
30
|
+
*/
|
|
31
|
+
static createForAdRequest(adUnitId: string, requestOptions?: RequestOptions) {
|
|
32
|
+
return super.createForAdRequest(adUnitId, requestOptions) as GAMInterstitialAd;
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
addAdEventsListener<T extends AdEventType | GAMAdEventType>(listener: AdEventsListener<T>) {
|
|
36
|
+
return this._addAdEventsListener(listener);
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
addAdEventListener<T extends AdEventType | GAMAdEventType>(
|
|
40
|
+
type: T,
|
|
41
|
+
listener: AdEventListener<T>,
|
|
42
|
+
) {
|
|
43
|
+
return this._addAdEventListener(type, listener);
|
|
44
|
+
}
|
|
45
|
+
}
|
|
@@ -0,0 +1,122 @@
|
|
|
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 { isString } from '../common';
|
|
19
|
+
import { validateAdRequestOptions } from '../validateAdRequestOptions';
|
|
20
|
+
import { MobileAd } from './MobileAd';
|
|
21
|
+
import { AdEventType } from '../AdEventType';
|
|
22
|
+
import { AdEventListener } from '../types/AdEventListener';
|
|
23
|
+
import { AdEventsListener } from '../types/AdEventsListener';
|
|
24
|
+
import { RequestOptions } from '../types/RequestOptions';
|
|
25
|
+
import NativeInterstitialModule from '../specs/modules/NativeInterstitialModule';
|
|
26
|
+
|
|
27
|
+
/**
|
|
28
|
+
* A class for interacting and showing Interstitial Ads.
|
|
29
|
+
*
|
|
30
|
+
* An Interstitial advert can be pre-loaded and shown at a suitable point in your apps flow, such as at the end of a level
|
|
31
|
+
* in a game. An Interstitial is a full screen advert, laid on-top of your entire application which the user can interact with.
|
|
32
|
+
* Interactions are passed back via events which should be handled accordingly inside of your app.
|
|
33
|
+
*
|
|
34
|
+
* #### Example
|
|
35
|
+
*
|
|
36
|
+
* First create a new Interstitial instance, passing in your Ad Unit ID from the Google Mobile Ads configuration console, and any additional
|
|
37
|
+
* request options. The example below will present a test advert, and only request a non-personalized ad.
|
|
38
|
+
*
|
|
39
|
+
* ```js
|
|
40
|
+
* import { InterstitialAd, TestIds } from 'react-native-google-mobile-ads';
|
|
41
|
+
*
|
|
42
|
+
* const interstitial = InterstitialAd.createForAdRequest(TestIds.INTERSTITIAL, {
|
|
43
|
+
* requestNonPersonalizedAdsOnly: true,
|
|
44
|
+
* });
|
|
45
|
+
* ```
|
|
46
|
+
*
|
|
47
|
+
* Each advert needs to be loaded from Google Mobile Ads before being shown. It is recommended this is performed before the user
|
|
48
|
+
* reaches the checkpoint to show the advert, so it's ready to go. Before loading the advert, we need to setup
|
|
49
|
+
* event listeners to listen for updates from Google Mobile Ads, such as advert loaded or failed to load.
|
|
50
|
+
*
|
|
51
|
+
* Event types match the `AdEventType` interface. Once the advert has loaded, we can trigger it to show:
|
|
52
|
+
*
|
|
53
|
+
* ```js
|
|
54
|
+
* import { AdEventType } from 'react-native-google-mobile-ads';
|
|
55
|
+
*
|
|
56
|
+
* interstitialAd.addAdEventListener(AdEventType.Loaded, () => {
|
|
57
|
+
* interstitialAd.show();
|
|
58
|
+
* });
|
|
59
|
+
*
|
|
60
|
+
* interstitial.load();
|
|
61
|
+
* ```
|
|
62
|
+
*
|
|
63
|
+
* The advert will be presented to the user, and several more events can be triggered such as the user clicking the
|
|
64
|
+
* advert or closing it.
|
|
65
|
+
*/
|
|
66
|
+
export class InterstitialAd extends MobileAd {
|
|
67
|
+
protected static _interstitialRequest = 0;
|
|
68
|
+
/**
|
|
69
|
+
* Creates a new InterstitialAd instance.
|
|
70
|
+
*
|
|
71
|
+
* #### Example
|
|
72
|
+
*
|
|
73
|
+
* ```js
|
|
74
|
+
* import { InterstitialAd, AdEventType, TestIds } from 'react-native-google-mobile-ads';
|
|
75
|
+
*
|
|
76
|
+
* const interstitialAd = await InterstitialAd.createForAdRequest(TestIds.INTERSTITIAL, {
|
|
77
|
+
* requestAgent: 'CoolAds',
|
|
78
|
+
* });
|
|
79
|
+
*
|
|
80
|
+
* interstitialAd.addAdEventListener(AdEventType.Loaded, () => {
|
|
81
|
+
* interstitialAd.show();
|
|
82
|
+
* });
|
|
83
|
+
*
|
|
84
|
+
* interstitialAd.load();
|
|
85
|
+
* ```
|
|
86
|
+
*
|
|
87
|
+
* @param adUnitId The Ad Unit ID for the Interstitial. You can find this on your Google Mobile Ads dashboard.
|
|
88
|
+
* @param requestOptions Optional RequestOptions used to load the ad.
|
|
89
|
+
*/
|
|
90
|
+
static createForAdRequest(adUnitId: string, requestOptions?: RequestOptions) {
|
|
91
|
+
if (!isString(adUnitId)) {
|
|
92
|
+
throw new Error("InterstitialAd.createForAdRequest(*) 'adUnitId' expected an string value.");
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
let options = {};
|
|
96
|
+
try {
|
|
97
|
+
options = validateAdRequestOptions(requestOptions);
|
|
98
|
+
} catch (e) {
|
|
99
|
+
if (e instanceof Error) {
|
|
100
|
+
throw new Error(`InterstitialAd.createForAdRequest(_, *) ${e.message}.`);
|
|
101
|
+
}
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
const requestId = InterstitialAd._interstitialRequest++;
|
|
105
|
+
return new InterstitialAd(
|
|
106
|
+
'interstitial',
|
|
107
|
+
requestId,
|
|
108
|
+
adUnitId,
|
|
109
|
+
NativeInterstitialModule.interstitialLoad.bind(this),
|
|
110
|
+
NativeInterstitialModule.interstitialShow.bind(this),
|
|
111
|
+
options,
|
|
112
|
+
);
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
addAdEventsListener<T extends AdEventType>(listener: AdEventsListener<T>) {
|
|
116
|
+
return this._addAdEventsListener(listener);
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
addAdEventListener<T extends AdEventType>(type: T, listener: AdEventListener<T>) {
|
|
120
|
+
return this._addAdEventListener(type, listener);
|
|
121
|
+
}
|
|
122
|
+
}
|