@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,220 @@
|
|
|
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
|
+
#if !TARGET_OS_MACCATALYST
|
|
19
|
+
|
|
20
|
+
#import "RNGoogleMobileAdsFullScreenAd.h"
|
|
21
|
+
#import "RNGoogleMobileAdsCommon.h"
|
|
22
|
+
|
|
23
|
+
@implementation RNGoogleMobileAdsFullScreenAd
|
|
24
|
+
|
|
25
|
+
- (instancetype)init {
|
|
26
|
+
if (self = [super init]) {
|
|
27
|
+
_adMap = [NSMutableDictionary new];
|
|
28
|
+
_delegateMap = [NSMutableDictionary new];
|
|
29
|
+
}
|
|
30
|
+
return self;
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
- (void)dealloc {
|
|
34
|
+
[self invalidate];
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
- (void)invalidate {
|
|
38
|
+
[_adMap removeAllObjects];
|
|
39
|
+
[_delegateMap removeAllObjects];
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
- (NSString *)getAdEventName {
|
|
43
|
+
@throw [NSException exceptionWithName:@"MethodNotImplemented"
|
|
44
|
+
reason:@"Method `getAdEventName` must be overridden"
|
|
45
|
+
userInfo:nil];
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
- (void)loadAd:(NSString *)adUnitId
|
|
49
|
+
adRequest:(GAMRequest *)adRequest
|
|
50
|
+
completionHandler:
|
|
51
|
+
(void (^)(id<GADFullScreenPresentingAd> ad, NSError *error))completionHandler {
|
|
52
|
+
@throw [NSException exceptionWithName:@"MethodNotImplemented"
|
|
53
|
+
reason:@"Method `loadAd` must be overridden"
|
|
54
|
+
userInfo:nil];
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
- (void)sendAdEvent:(NSString *)type
|
|
58
|
+
requestId:(int)requestId
|
|
59
|
+
adUnitId:(NSString *)adUnitId
|
|
60
|
+
error:(NSDictionary *)error
|
|
61
|
+
data:(NSDictionary *)data {
|
|
62
|
+
[RNGoogleMobileAdsCommon sendAdEvent:[self getAdEventName]
|
|
63
|
+
requestId:@(requestId)
|
|
64
|
+
type:type
|
|
65
|
+
adUnitId:adUnitId
|
|
66
|
+
error:error
|
|
67
|
+
data:data];
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
- (void)loadWithRequestId:(int)requestId
|
|
71
|
+
adUnitId:(NSString *)adUnitId
|
|
72
|
+
adRequestOptions:(NSDictionary *)adRequestOptions {
|
|
73
|
+
GAMRequest *adRequest = [RNGoogleMobileAdsCommon buildAdRequest:adRequestOptions];
|
|
74
|
+
RNGoogleMobileAdsFullScreenContentDelegate *delegate =
|
|
75
|
+
[[RNGoogleMobileAdsFullScreenContentDelegate alloc] initWithAdEventName:[self getAdEventName]
|
|
76
|
+
requestId:requestId
|
|
77
|
+
adUnitId:adUnitId];
|
|
78
|
+
|
|
79
|
+
__weak __typeof(self) weakSelf = self;
|
|
80
|
+
[self loadAd:adUnitId
|
|
81
|
+
adRequest:adRequest
|
|
82
|
+
completionHandler:^(id<GADFullScreenPresentingAd> ad, NSError *error) {
|
|
83
|
+
if (error) {
|
|
84
|
+
NSDictionary *codeAndMessage =
|
|
85
|
+
[RNGoogleMobileAdsCommon getCodeAndMessageFromAdError:error];
|
|
86
|
+
[weakSelf sendAdEvent:GOOGLE_MOBILE_ADS_EVENT_ERROR
|
|
87
|
+
requestId:requestId
|
|
88
|
+
adUnitId:adUnitId
|
|
89
|
+
error:codeAndMessage
|
|
90
|
+
data:nil];
|
|
91
|
+
return;
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
NSString *eventType = GOOGLE_MOBILE_ADS_EVENT_LOADED;
|
|
95
|
+
NSDictionary *data = nil;
|
|
96
|
+
|
|
97
|
+
// Set up paid event handler
|
|
98
|
+
GADPaidEventHandler paidEventHandler = ^(GADAdValue *value) {
|
|
99
|
+
[weakSelf sendAdEvent:@"paid"
|
|
100
|
+
requestId:requestId
|
|
101
|
+
adUnitId:adUnitId
|
|
102
|
+
error:nil
|
|
103
|
+
data:@{
|
|
104
|
+
@"value" : value.value,
|
|
105
|
+
@"precision" : @(value.precision),
|
|
106
|
+
@"currency" : value.currencyCode
|
|
107
|
+
}];
|
|
108
|
+
};
|
|
109
|
+
|
|
110
|
+
if ([ad isKindOfClass:[GADRewardedAd class]]) {
|
|
111
|
+
[(GADRewardedAd *)ad setPaidEventHandler:paidEventHandler];
|
|
112
|
+
} else if ([ad isKindOfClass:[GADRewardedInterstitialAd class]]) {
|
|
113
|
+
[(GADRewardedInterstitialAd *)ad setPaidEventHandler:paidEventHandler];
|
|
114
|
+
} else if ([ad isKindOfClass:[GADInterstitialAd class]]) {
|
|
115
|
+
[(GADInterstitialAd *)ad setPaidEventHandler:paidEventHandler];
|
|
116
|
+
} else if ([ad isKindOfClass:[GADAppOpenAd class]]) {
|
|
117
|
+
[(GADAppOpenAd *)ad setPaidEventHandler:paidEventHandler];
|
|
118
|
+
}
|
|
119
|
+
|
|
120
|
+
if ([ad isKindOfClass:[GADRewardedAd class]] ||
|
|
121
|
+
[ad isKindOfClass:[GADRewardedInterstitialAd class]]) {
|
|
122
|
+
NSDictionary *serverSideVerificationOptions =
|
|
123
|
+
adRequestOptions[@"serverSideVerificationOptions"];
|
|
124
|
+
if (serverSideVerificationOptions) {
|
|
125
|
+
GADServerSideVerificationOptions *options =
|
|
126
|
+
[[GADServerSideVerificationOptions alloc] init];
|
|
127
|
+
options.userIdentifier = serverSideVerificationOptions[@"userId"];
|
|
128
|
+
options.customRewardString = serverSideVerificationOptions[@"customData"];
|
|
129
|
+
|
|
130
|
+
if ([ad isKindOfClass:[GADRewardedAd class]]) {
|
|
131
|
+
[(GADRewardedAd *)ad setServerSideVerificationOptions:options];
|
|
132
|
+
} else if ([ad isKindOfClass:[GADRewardedInterstitialAd class]]) {
|
|
133
|
+
[(GADRewardedInterstitialAd *)ad setServerSideVerificationOptions:options];
|
|
134
|
+
}
|
|
135
|
+
}
|
|
136
|
+
|
|
137
|
+
eventType = GOOGLE_MOBILE_ADS_EVENT_REWARDED_LOADED;
|
|
138
|
+
GADAdReward *adReward =
|
|
139
|
+
[(GADRewardedAd *)ad adReward] ?: [(GADRewardedInterstitialAd *)ad adReward];
|
|
140
|
+
data = @{@"type" : adReward.type, @"amount" : adReward.amount};
|
|
141
|
+
}
|
|
142
|
+
|
|
143
|
+
if ([ad isKindOfClass:[GAMInterstitialAd class]]) {
|
|
144
|
+
[(GAMInterstitialAd *)ad setAppEventDelegate:delegate];
|
|
145
|
+
}
|
|
146
|
+
|
|
147
|
+
ad.fullScreenContentDelegate = delegate;
|
|
148
|
+
weakSelf.adMap[@(requestId)] = ad;
|
|
149
|
+
weakSelf.delegateMap[@(requestId)] = delegate;
|
|
150
|
+
|
|
151
|
+
[weakSelf sendAdEvent:eventType requestId:requestId adUnitId:adUnitId error:nil data:data];
|
|
152
|
+
}];
|
|
153
|
+
}
|
|
154
|
+
|
|
155
|
+
- (void)showWithRequestId:(int)requestId
|
|
156
|
+
adUnitId:(NSString *)adUnitId
|
|
157
|
+
showOptions:(NSDictionary *)showOptions
|
|
158
|
+
resolve:(RCTPromiseResolveBlock)resolve
|
|
159
|
+
reject:(RCTPromiseRejectBlock)reject {
|
|
160
|
+
UIViewController *viewController = [RNGoogleMobileAdsCommon currentViewController];
|
|
161
|
+
if (!viewController) {
|
|
162
|
+
[RNSharedUtils
|
|
163
|
+
rejectPromiseWithUserInfo:reject
|
|
164
|
+
userInfo:@{
|
|
165
|
+
@"code" : @"nil-vc",
|
|
166
|
+
@"message" :
|
|
167
|
+
@"Ad attempted to show but the current View Controller was nil."
|
|
168
|
+
}];
|
|
169
|
+
return;
|
|
170
|
+
}
|
|
171
|
+
|
|
172
|
+
id<GADFullScreenPresentingAd> ad = self.adMap[@(requestId)];
|
|
173
|
+
if (!ad) {
|
|
174
|
+
[RNSharedUtils rejectPromiseWithUserInfo:reject
|
|
175
|
+
userInfo:@{
|
|
176
|
+
@"code" : @"not-ready",
|
|
177
|
+
@"message" : @"Ad attempted to show but was not ready."
|
|
178
|
+
}];
|
|
179
|
+
return;
|
|
180
|
+
}
|
|
181
|
+
|
|
182
|
+
if ([ad isKindOfClass:[GADAppOpenAd class]]) {
|
|
183
|
+
[(GADAppOpenAd *)ad presentFromRootViewController:viewController];
|
|
184
|
+
} else if ([ad isKindOfClass:[GADInterstitialAd class]]) {
|
|
185
|
+
[(GADInterstitialAd *)ad presentFromRootViewController:viewController];
|
|
186
|
+
} else if ([ad isKindOfClass:[GADRewardedAd class]]) {
|
|
187
|
+
[(GADRewardedAd *)ad presentFromRootViewController:viewController
|
|
188
|
+
userDidEarnRewardHandler:^{
|
|
189
|
+
NSDictionary *rewardData = @{
|
|
190
|
+
@"type" : [(GADRewardedAd *)ad adReward].type,
|
|
191
|
+
@"amount" : [(GADRewardedAd *)ad adReward].amount
|
|
192
|
+
};
|
|
193
|
+
[self sendAdEvent:GOOGLE_MOBILE_ADS_EVENT_REWARDED_EARNED_REWARD
|
|
194
|
+
requestId:requestId
|
|
195
|
+
adUnitId:adUnitId
|
|
196
|
+
error:nil
|
|
197
|
+
data:rewardData];
|
|
198
|
+
}];
|
|
199
|
+
} else if ([ad isKindOfClass:[GADRewardedInterstitialAd class]]) {
|
|
200
|
+
[(GADRewardedInterstitialAd *)ad
|
|
201
|
+
presentFromRootViewController:viewController
|
|
202
|
+
userDidEarnRewardHandler:^{
|
|
203
|
+
NSDictionary *rewardData = @{
|
|
204
|
+
@"type" : [(GADRewardedInterstitialAd *)ad adReward].type,
|
|
205
|
+
@"amount" : [(GADRewardedInterstitialAd *)ad adReward].amount
|
|
206
|
+
};
|
|
207
|
+
[self sendAdEvent:GOOGLE_MOBILE_ADS_EVENT_REWARDED_EARNED_REWARD
|
|
208
|
+
requestId:requestId
|
|
209
|
+
adUnitId:adUnitId
|
|
210
|
+
error:nil
|
|
211
|
+
data:rewardData];
|
|
212
|
+
}];
|
|
213
|
+
}
|
|
214
|
+
|
|
215
|
+
resolve(nil);
|
|
216
|
+
}
|
|
217
|
+
|
|
218
|
+
@end
|
|
219
|
+
|
|
220
|
+
#endif
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Copyright (c) 2016-present Invertase Limited & Contributors
|
|
3
|
+
*
|
|
4
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
5
|
+
* you may not use this library except in compliance with the License.
|
|
6
|
+
* You may obtain a copy of the License at
|
|
7
|
+
*
|
|
8
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
9
|
+
*
|
|
10
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
11
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
12
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
13
|
+
* See the License for the specific language governing permissions and
|
|
14
|
+
* limitations under the License.
|
|
15
|
+
*
|
|
16
|
+
*/
|
|
17
|
+
|
|
18
|
+
#if !TARGET_OS_MACCATALYST
|
|
19
|
+
|
|
20
|
+
#import <Foundation/Foundation.h>
|
|
21
|
+
#import <GoogleMobileAds/GoogleMobileAds.h>
|
|
22
|
+
|
|
23
|
+
@interface RNGoogleMobileAdsFullScreenContentDelegate
|
|
24
|
+
: NSObject <GADFullScreenContentDelegate, GADAppEventDelegate>
|
|
25
|
+
|
|
26
|
+
@property(nonatomic, strong, readonly) NSString *adEventName;
|
|
27
|
+
@property(nonatomic, assign, readonly) int requestId;
|
|
28
|
+
@property(nonatomic, strong, readonly) NSString *adUnitId;
|
|
29
|
+
|
|
30
|
+
- (instancetype)initWithAdEventName:(NSString *)adEventName
|
|
31
|
+
requestId:(int)requestId
|
|
32
|
+
adUnitId:(NSString *)adUnitId;
|
|
33
|
+
|
|
34
|
+
@end
|
|
35
|
+
|
|
36
|
+
#endif
|
|
@@ -0,0 +1,80 @@
|
|
|
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
|
+
#if !TARGET_OS_MACCATALYST
|
|
19
|
+
|
|
20
|
+
#import "RNGoogleMobileAdsFullScreenContentDelegate.h"
|
|
21
|
+
#import "RNGoogleMobileAdsCommon.h"
|
|
22
|
+
|
|
23
|
+
@implementation RNGoogleMobileAdsFullScreenContentDelegate
|
|
24
|
+
|
|
25
|
+
- (instancetype)initWithAdEventName:(NSString *)adEventName
|
|
26
|
+
requestId:(int)requestId
|
|
27
|
+
adUnitId:(NSString *)adUnitId {
|
|
28
|
+
if (self = [super init]) {
|
|
29
|
+
_adEventName = adEventName;
|
|
30
|
+
_requestId = requestId;
|
|
31
|
+
_adUnitId = adUnitId;
|
|
32
|
+
}
|
|
33
|
+
return self;
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
- (void)adWillPresentFullScreenContent:(id<GADFullScreenPresentingAd>)ad {
|
|
37
|
+
[self sendAdEventWithType:GOOGLE_MOBILE_ADS_EVENT_OPENED error:nil data:nil];
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
- (void)ad:(id<GADFullScreenPresentingAd>)ad
|
|
41
|
+
didFailToPresentFullScreenContentWithError:(NSError *)error {
|
|
42
|
+
NSDictionary *errorInfo = [RNGoogleMobileAdsCommon getCodeAndMessageFromAdError:error];
|
|
43
|
+
[self sendAdEventWithType:GOOGLE_MOBILE_ADS_EVENT_ERROR error:errorInfo data:nil];
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
- (void)adDidDismissFullScreenContent:(id<GADFullScreenPresentingAd>)ad {
|
|
47
|
+
[self sendAdEventWithType:GOOGLE_MOBILE_ADS_EVENT_CLOSED error:nil data:nil];
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
- (void)adDidRecordClick:(id<GADFullScreenPresentingAd>)ad {
|
|
51
|
+
[self sendAdEventWithType:GOOGLE_MOBILE_ADS_EVENT_CLICKED error:nil data:nil];
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
- (void)adDidRecordImpression:(id<GADFullScreenPresentingAd>)ad {
|
|
55
|
+
// Not implemented yet
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
- (void)interstitialAd:(GADInterstitialAd *)interstitialAd
|
|
59
|
+
didReceiveAppEvent:(NSString *)name
|
|
60
|
+
withInfo:(nullable NSString *)info {
|
|
61
|
+
NSDictionary *data = @{@"name" : name, @"data" : info ?: @""};
|
|
62
|
+
[self sendAdEventWithType:GOOGLE_MOBILE_ADS_EVENT_APP_EVENT error:nil data:data];
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
#pragma mark - Private
|
|
66
|
+
|
|
67
|
+
- (void)sendAdEventWithType:(NSString *)type
|
|
68
|
+
error:(nullable NSDictionary *)error
|
|
69
|
+
data:(nullable NSDictionary *)data {
|
|
70
|
+
[RNGoogleMobileAdsCommon sendAdEvent:self.adEventName
|
|
71
|
+
requestId:@(self.requestId)
|
|
72
|
+
type:type
|
|
73
|
+
adUnitId:self.adUnitId
|
|
74
|
+
error:error
|
|
75
|
+
data:data];
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
@end
|
|
79
|
+
|
|
80
|
+
#endif
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Copyright (c) 2016-present Invertase Limited & Contributors
|
|
3
|
+
*
|
|
4
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
5
|
+
* you may not use this library except in compliance with the License.
|
|
6
|
+
* You may obtain a copy of the License at
|
|
7
|
+
*
|
|
8
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
9
|
+
*
|
|
10
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
11
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
12
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
13
|
+
* See the License for the specific language governing permissions and
|
|
14
|
+
* limitations under the License.
|
|
15
|
+
*
|
|
16
|
+
*/
|
|
17
|
+
|
|
18
|
+
#if !TARGET_OS_MACCATALYST
|
|
19
|
+
|
|
20
|
+
#import <Foundation/Foundation.h>
|
|
21
|
+
|
|
22
|
+
#ifdef RCT_NEW_ARCH_ENABLED
|
|
23
|
+
|
|
24
|
+
#import <RNGoogleMobileAdsSpec/RNGoogleMobileAdsSpec.h>
|
|
25
|
+
@interface RNGoogleMobileAdsInterstitialModule : NSObject <NativeInterstitialModuleSpec>
|
|
26
|
+
|
|
27
|
+
#else
|
|
28
|
+
|
|
29
|
+
#import <React/RCTBridgeModule.h>
|
|
30
|
+
@interface RNGoogleMobileAdsInterstitialModule : NSObject <RCTBridgeModule>
|
|
31
|
+
|
|
32
|
+
#endif
|
|
33
|
+
|
|
34
|
+
@end
|
|
35
|
+
|
|
36
|
+
#endif
|
|
@@ -0,0 +1,106 @@
|
|
|
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
|
+
#if !TARGET_OS_MACCATALYST
|
|
19
|
+
|
|
20
|
+
#import "RNGoogleMobileAdsInterstitialModule.h"
|
|
21
|
+
#import <GoogleMobileAds/GoogleMobileAds.h>
|
|
22
|
+
#ifdef RCT_NEW_ARCH_ENABLED
|
|
23
|
+
#import "RNGoogleMobileAdsSpec.h"
|
|
24
|
+
#endif
|
|
25
|
+
#import "RNGoogleMobileAdsCommon.h"
|
|
26
|
+
#import "RNGoogleMobileAdsFullScreenAd.h"
|
|
27
|
+
|
|
28
|
+
@interface RNGoogleMobileAdsInterstitialAd : RNGoogleMobileAdsFullScreenAd
|
|
29
|
+
|
|
30
|
+
@end
|
|
31
|
+
|
|
32
|
+
@implementation RNGoogleMobileAdsInterstitialAd
|
|
33
|
+
|
|
34
|
+
- (NSString *)getAdEventName {
|
|
35
|
+
return GOOGLE_MOBILE_ADS_EVENT_INTERSTITIAL;
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
- (void)loadAd:(NSString *)adUnitId
|
|
39
|
+
adRequest:(GAMRequest *)adRequest
|
|
40
|
+
completionHandler:
|
|
41
|
+
(void (^)(GAMInterstitialAd *_Nullable ad, NSError *_Nullable error))completionHandler {
|
|
42
|
+
[GAMInterstitialAd loadWithAdManagerAdUnitID:adUnitId
|
|
43
|
+
request:adRequest
|
|
44
|
+
completionHandler:completionHandler];
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
@end
|
|
48
|
+
|
|
49
|
+
@implementation RNGoogleMobileAdsInterstitialModule {
|
|
50
|
+
RNGoogleMobileAdsInterstitialAd *_ad;
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
RCT_EXPORT_MODULE();
|
|
54
|
+
|
|
55
|
+
- (dispatch_queue_t)methodQueue {
|
|
56
|
+
return dispatch_get_main_queue();
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
+ (BOOL)requiresMainQueueSetup {
|
|
60
|
+
return YES;
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
RCT_EXPORT_METHOD(interstitialLoad
|
|
64
|
+
: (double)requestId adUnitId
|
|
65
|
+
: (NSString *)adUnitId requestOptions
|
|
66
|
+
: (NSDictionary *)requestOptions) {
|
|
67
|
+
[_ad loadWithRequestId:requestId adUnitId:adUnitId adRequestOptions:requestOptions];
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
RCT_EXPORT_METHOD(interstitialShow
|
|
71
|
+
: (double)requestId adUnitId
|
|
72
|
+
: (NSString *)adUnitId showOptions
|
|
73
|
+
: (NSDictionary *)showOptions resolve
|
|
74
|
+
: (RCTPromiseResolveBlock)resolve reject
|
|
75
|
+
: (RCTPromiseRejectBlock)reject) {
|
|
76
|
+
[_ad showWithRequestId:requestId
|
|
77
|
+
adUnitId:adUnitId
|
|
78
|
+
showOptions:showOptions
|
|
79
|
+
resolve:resolve
|
|
80
|
+
reject:reject];
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
RCT_EXPORT_METHOD(invalidate) { [_ad invalidate]; }
|
|
84
|
+
|
|
85
|
+
#ifdef RCT_NEW_ARCH_ENABLED
|
|
86
|
+
- (std::shared_ptr<facebook::react::TurboModule>)getTurboModule:
|
|
87
|
+
(const facebook::react::ObjCTurboModule::InitParams &)params {
|
|
88
|
+
return std::make_shared<facebook::react::NativeInterstitialModuleSpecJSI>(params);
|
|
89
|
+
}
|
|
90
|
+
#endif
|
|
91
|
+
|
|
92
|
+
- (instancetype)init {
|
|
93
|
+
self = [super init];
|
|
94
|
+
if (self) {
|
|
95
|
+
_ad = [[RNGoogleMobileAdsInterstitialAd alloc] init];
|
|
96
|
+
}
|
|
97
|
+
return self;
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
- (void)dealloc {
|
|
101
|
+
[self invalidate];
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
@end
|
|
105
|
+
|
|
106
|
+
#endif
|
|
@@ -0,0 +1,52 @@
|
|
|
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 <GoogleMobileAds/GADNativeAd.h>
|
|
19
|
+
#import <React/RCTBridge.h>
|
|
20
|
+
#import <React/RCTUIManager.h>
|
|
21
|
+
|
|
22
|
+
#ifdef RCT_NEW_ARCH_ENABLED
|
|
23
|
+
#import <React/RCTViewComponentView.h>
|
|
24
|
+
#else
|
|
25
|
+
#import <React/RCTView.h>
|
|
26
|
+
#endif
|
|
27
|
+
|
|
28
|
+
NS_ASSUME_NONNULL_BEGIN
|
|
29
|
+
|
|
30
|
+
#ifdef RCT_NEW_ARCH_ENABLED
|
|
31
|
+
@interface RNGoogleMobileAdsMediaView : RCTViewComponentView
|
|
32
|
+
|
|
33
|
+
// this setters/getters here are provided by RCTViewComponentView super, we just narrow the type.
|
|
34
|
+
@property(nonatomic, strong, nullable) GADMediaView *contentView;
|
|
35
|
+
#else
|
|
36
|
+
@interface RNGoogleMobileAdsMediaView : GADMediaView
|
|
37
|
+
|
|
38
|
+
- (instancetype)initWithBridge:(RCTBridge *)bridge;
|
|
39
|
+
#endif
|
|
40
|
+
|
|
41
|
+
@property(nonatomic, copy) NSString *responseId;
|
|
42
|
+
@property(nonatomic, copy) NSString *resizeMode;
|
|
43
|
+
|
|
44
|
+
@end
|
|
45
|
+
|
|
46
|
+
#ifndef RCT_NEW_ARCH_ENABLED
|
|
47
|
+
@interface RNGoogleMobileAdsMediaViewManager : RCTViewManager
|
|
48
|
+
|
|
49
|
+
@end
|
|
50
|
+
#endif
|
|
51
|
+
|
|
52
|
+
NS_ASSUME_NONNULL_END
|
|
@@ -0,0 +1,155 @@
|
|
|
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 "RNGoogleMobileAdsMediaView.h"
|
|
19
|
+
#import "RNGoogleMobileAdsNativeModule.h"
|
|
20
|
+
|
|
21
|
+
#ifdef RCT_NEW_ARCH_ENABLED
|
|
22
|
+
#import <react/renderer/components/RNGoogleMobileAdsSpec/ComponentDescriptors.h>
|
|
23
|
+
#import <react/renderer/components/RNGoogleMobileAdsSpec/EventEmitters.h>
|
|
24
|
+
#import <react/renderer/components/RNGoogleMobileAdsSpec/Props.h>
|
|
25
|
+
#import <react/renderer/components/RNGoogleMobileAdsSpec/RCTComponentViewHelpers.h>
|
|
26
|
+
|
|
27
|
+
#import "RCTFabricComponentsPlugins.h"
|
|
28
|
+
#endif
|
|
29
|
+
|
|
30
|
+
@interface RCTBridge (Private)
|
|
31
|
+
+ (RCTBridge *)currentBridge;
|
|
32
|
+
@end
|
|
33
|
+
|
|
34
|
+
#ifdef RCT_NEW_ARCH_ENABLED
|
|
35
|
+
using namespace facebook::react;
|
|
36
|
+
|
|
37
|
+
@interface RNGoogleMobileAdsMediaView () <RCTRNGoogleMobileAdsMediaViewViewProtocol>
|
|
38
|
+
@end
|
|
39
|
+
#endif
|
|
40
|
+
|
|
41
|
+
@implementation RNGoogleMobileAdsMediaView {
|
|
42
|
+
__weak RCTBridge *_bridge;
|
|
43
|
+
__weak RNGoogleMobileAdsNativeModule *_nativeModule;
|
|
44
|
+
GADMediaView *_mediaView;
|
|
45
|
+
UIViewContentMode _contentMode;
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
#ifdef RCT_NEW_ARCH_ENABLED
|
|
49
|
+
#pragma mark - Fabric specific
|
|
50
|
+
|
|
51
|
+
@dynamic contentView; // provided by superclass, but we narrow the type in our declaration
|
|
52
|
+
|
|
53
|
+
- (instancetype)initWithFrame:(CGRect)frame {
|
|
54
|
+
if (self = [super initWithFrame:frame]) {
|
|
55
|
+
static const auto defaultProps = std::make_shared<const RNGoogleMobileAdsBannerViewProps>();
|
|
56
|
+
_props = defaultProps;
|
|
57
|
+
|
|
58
|
+
_bridge = [RCTBridge currentBridge];
|
|
59
|
+
_nativeModule = [_bridge moduleForClass:RNGoogleMobileAdsNativeModule.class];
|
|
60
|
+
_mediaView = [[GADMediaView alloc] init];
|
|
61
|
+
_contentMode = UIViewContentModeScaleAspectFill;
|
|
62
|
+
self.contentView = _mediaView;
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
return self;
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
#pragma mark - RCTComponentViewProtocol
|
|
69
|
+
|
|
70
|
+
+ (ComponentDescriptorProvider)componentDescriptorProvider {
|
|
71
|
+
return concreteComponentDescriptorProvider<RNGoogleMobileAdsMediaViewComponentDescriptor>();
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
+ (BOOL)shouldBeRecycled {
|
|
75
|
+
return NO;
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
- (void)updateProps:(Props::Shared const &)props oldProps:(Props::Shared const &)oldProps {
|
|
79
|
+
const auto &oldViewProps =
|
|
80
|
+
*std::static_pointer_cast<RNGoogleMobileAdsMediaViewProps const>(_props);
|
|
81
|
+
const auto &newViewProps =
|
|
82
|
+
*std::static_pointer_cast<RNGoogleMobileAdsMediaViewProps const>(props);
|
|
83
|
+
|
|
84
|
+
if (oldViewProps.responseId != newViewProps.responseId) {
|
|
85
|
+
NSString *responseId = [[NSString alloc] initWithUTF8String:newViewProps.responseId.c_str()];
|
|
86
|
+
[self setResponseId:responseId];
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
if (oldViewProps.resizeMode != newViewProps.resizeMode) {
|
|
90
|
+
NSString *resizeMode = [[NSString alloc] initWithUTF8String:newViewProps.resizeMode.c_str()];
|
|
91
|
+
[self setResizeMode:resizeMode];
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
[super updateProps:props oldProps:oldProps];
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
#else
|
|
98
|
+
#pragma mark - Paper specific
|
|
99
|
+
|
|
100
|
+
- (instancetype)initWithBridge:(RCTBridge *)bridge {
|
|
101
|
+
if (self = [super init]) {
|
|
102
|
+
_bridge = bridge;
|
|
103
|
+
_nativeModule = [_bridge moduleForClass:RNGoogleMobileAdsNativeModule.class];
|
|
104
|
+
_mediaView = self;
|
|
105
|
+
}
|
|
106
|
+
return self;
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
#endif // RCT_NEW_ARCH_ENABLED
|
|
110
|
+
|
|
111
|
+
#pragma mark - Common logics
|
|
112
|
+
|
|
113
|
+
- (void)setResponseId:(NSString *)responseId {
|
|
114
|
+
_responseId = responseId;
|
|
115
|
+
GADNativeAd *nativeAd = [_nativeModule nativeAdForResponseId:responseId];
|
|
116
|
+
_mediaView.mediaContent = nativeAd.mediaContent;
|
|
117
|
+
_mediaView.contentMode = _contentMode;
|
|
118
|
+
}
|
|
119
|
+
|
|
120
|
+
- (void)setResizeMode:(NSString *)resizeMode {
|
|
121
|
+
_resizeMode = resizeMode;
|
|
122
|
+
if ([resizeMode isEqualToString:@"cover"]) {
|
|
123
|
+
_contentMode = UIViewContentModeScaleAspectFill;
|
|
124
|
+
} else if ([resizeMode isEqualToString:@"contain"]) {
|
|
125
|
+
_contentMode = UIViewContentModeScaleAspectFit;
|
|
126
|
+
} else if ([resizeMode isEqualToString:@"stretch"]) {
|
|
127
|
+
_contentMode = UIViewContentModeScaleToFill;
|
|
128
|
+
}
|
|
129
|
+
_mediaView.contentMode = _contentMode;
|
|
130
|
+
}
|
|
131
|
+
|
|
132
|
+
@end
|
|
133
|
+
|
|
134
|
+
#ifndef RCT_NEW_ARCH_ENABLED
|
|
135
|
+
|
|
136
|
+
@implementation RNGoogleMobileAdsMediaViewManager
|
|
137
|
+
|
|
138
|
+
RCT_EXPORT_MODULE(RNGoogleMobileAdsMediaView)
|
|
139
|
+
|
|
140
|
+
RCT_EXPORT_VIEW_PROPERTY(responseId, NSString)
|
|
141
|
+
RCT_EXPORT_VIEW_PROPERTY(resizeMode, NSString)
|
|
142
|
+
|
|
143
|
+
- (UIView *)view {
|
|
144
|
+
return [[RNGoogleMobileAdsMediaView alloc] initWithBridge:self.bridge];
|
|
145
|
+
}
|
|
146
|
+
|
|
147
|
+
@end
|
|
148
|
+
|
|
149
|
+
#endif
|
|
150
|
+
|
|
151
|
+
#ifdef RCT_NEW_ARCH_ENABLED
|
|
152
|
+
Class<RCTComponentViewProtocol> RNGoogleMobileAdsMediaViewCls(void) {
|
|
153
|
+
return RNGoogleMobileAdsMediaView.class;
|
|
154
|
+
}
|
|
155
|
+
#endif
|