@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,221 @@
|
|
|
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 "RNGoogleMobileAdsBannerComponent.h"
|
|
21
|
+
#import <React/RCTLog.h>
|
|
22
|
+
#import "RNGoogleMobileAdsCommon.h"
|
|
23
|
+
|
|
24
|
+
@implementation RNGoogleMobileAdsBannerComponent
|
|
25
|
+
|
|
26
|
+
- (void)dealloc {
|
|
27
|
+
if (_banner) {
|
|
28
|
+
[_banner removeFromSuperview];
|
|
29
|
+
_banner = nil;
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
- (void)didSetProps:(NSArray<NSString *> *)changedProps {
|
|
34
|
+
if (_propsChanged) {
|
|
35
|
+
[self requestAd];
|
|
36
|
+
}
|
|
37
|
+
_propsChanged = false;
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
- (void)initBanner:(GADAdSize)adSize {
|
|
41
|
+
if (_requested) {
|
|
42
|
+
[_banner removeFromSuperview];
|
|
43
|
+
}
|
|
44
|
+
if ([RNGoogleMobileAdsCommon isAdManagerUnit:_unitId]) {
|
|
45
|
+
_banner = [[GAMBannerView alloc] initWithAdSize:adSize];
|
|
46
|
+
|
|
47
|
+
if (GADAdSizeEqualToSize(adSize, GADAdSizeFluid)) {
|
|
48
|
+
_banner.frame = self.bounds;
|
|
49
|
+
_banner.autoresizingMask = (UIViewAutoresizingFlexibleWidth);
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
((GAMBannerView *)_banner).validAdSizes = _sizeConfig[@"sizes"];
|
|
53
|
+
((GAMBannerView *)_banner).appEventDelegate = self;
|
|
54
|
+
((GAMBannerView *)_banner).enableManualImpressions = [_manualImpressionsEnabled boolValue];
|
|
55
|
+
} else {
|
|
56
|
+
_banner = [[GADBannerView alloc] initWithAdSize:adSize];
|
|
57
|
+
}
|
|
58
|
+
_banner.rootViewController = [UIApplication sharedApplication].delegate.window.rootViewController;
|
|
59
|
+
_banner.delegate = self;
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
- (void)setUnitId:(NSString *)unitId {
|
|
63
|
+
_unitId = unitId;
|
|
64
|
+
_propsChanged = true;
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
- (void)setSizeConfig:(NSDictionary *)sizeConfig {
|
|
68
|
+
NSArray *sizes = sizeConfig[@"sizes"];
|
|
69
|
+
__block NSMutableArray *adSizes = [[NSMutableArray alloc] initWithCapacity:sizes.count];
|
|
70
|
+
CGFloat maxHeight = sizeConfig[@"maxHeight"] ? [sizeConfig[@"maxHeight"] doubleValue] : -1;
|
|
71
|
+
CGFloat width = sizeConfig[@"width"] ? [sizeConfig[@"width"] doubleValue] : -1;
|
|
72
|
+
[sizes enumerateObjectsUsingBlock:^(id jsonValue, NSUInteger idx, __unused BOOL *stop) {
|
|
73
|
+
GADAdSize adSize = [RNGoogleMobileAdsCommon stringToAdSize:jsonValue
|
|
74
|
+
withMaxHeight:maxHeight
|
|
75
|
+
andWidth:width];
|
|
76
|
+
if (GADAdSizeEqualToSize(adSize, GADAdSizeInvalid)) {
|
|
77
|
+
RCTLogWarn(@"Invalid adSize %@", jsonValue);
|
|
78
|
+
} else {
|
|
79
|
+
[adSizes addObject:NSValueFromGADAdSize(adSize)];
|
|
80
|
+
}
|
|
81
|
+
}];
|
|
82
|
+
_sizeConfig = @{
|
|
83
|
+
@"sizes" : adSizes,
|
|
84
|
+
@"maxHeight" : [NSNumber numberWithFloat:maxHeight],
|
|
85
|
+
@"width" : [NSNumber numberWithFloat:width]
|
|
86
|
+
};
|
|
87
|
+
_propsChanged = true;
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
- (void)setRequest:(NSString *)request {
|
|
91
|
+
NSData *jsonData = [request dataUsingEncoding:NSUTF8StringEncoding];
|
|
92
|
+
NSError *error = nil;
|
|
93
|
+
_request = [NSJSONSerialization JSONObjectWithData:jsonData options:kNilOptions error:&error];
|
|
94
|
+
if (error) {
|
|
95
|
+
NSLog(@"Error parsing JSON: %@", error.localizedDescription);
|
|
96
|
+
}
|
|
97
|
+
_propsChanged = true;
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
- (void)setManualImpressionsEnabled:(BOOL *)manualImpressionsEnabled {
|
|
101
|
+
_manualImpressionsEnabled = [NSNumber numberWithBool:manualImpressionsEnabled];
|
|
102
|
+
_propsChanged = true;
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
- (GADAdSize)getInitialAdSize {
|
|
106
|
+
NSArray *sizes = _sizeConfig[@"sizes"];
|
|
107
|
+
for (NSValue *sizeValue in sizes) {
|
|
108
|
+
GADAdSize adSize = GADAdSizeFromNSValue(sizeValue);
|
|
109
|
+
if (GADAdSizeEqualToSize(adSize, GADAdSizeFluid)) {
|
|
110
|
+
return GADAdSizeFluid;
|
|
111
|
+
}
|
|
112
|
+
}
|
|
113
|
+
return GADAdSizeFromNSValue(sizes[0]);
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
- (void)requestAd {
|
|
117
|
+
#ifndef __LP64__
|
|
118
|
+
return; // prevent crash on 32bit
|
|
119
|
+
#endif
|
|
120
|
+
|
|
121
|
+
if (_unitId == nil || _sizeConfig == nil || _request == nil || _manualImpressionsEnabled == nil) {
|
|
122
|
+
[self setRequested:NO];
|
|
123
|
+
return;
|
|
124
|
+
}
|
|
125
|
+
|
|
126
|
+
[self initBanner:[self getInitialAdSize]];
|
|
127
|
+
[self addSubview:_banner];
|
|
128
|
+
_banner.adUnitID = _unitId;
|
|
129
|
+
[self setRequested:YES];
|
|
130
|
+
__weak typeof(self) weakSelf = self;
|
|
131
|
+
_banner.paidEventHandler = ^(GADAdValue *_Nonnull value) {
|
|
132
|
+
typeof(self) strongSelf = weakSelf;
|
|
133
|
+
if (strongSelf) {
|
|
134
|
+
[strongSelf sendEvent:@"onPaid"
|
|
135
|
+
payload:@{
|
|
136
|
+
@"value" : value.value,
|
|
137
|
+
@"precision" : @(value.precision),
|
|
138
|
+
@"currency" : value.currencyCode,
|
|
139
|
+
}];
|
|
140
|
+
}
|
|
141
|
+
};
|
|
142
|
+
[self load];
|
|
143
|
+
}
|
|
144
|
+
|
|
145
|
+
- (void)load {
|
|
146
|
+
[_banner loadRequest:[RNGoogleMobileAdsCommon buildAdRequest:_request]];
|
|
147
|
+
[self sendEvent:@"onSizeChange"
|
|
148
|
+
payload:@{
|
|
149
|
+
@"width" : @(_banner.bounds.size.width),
|
|
150
|
+
@"height" : @(_banner.bounds.size.height),
|
|
151
|
+
}];
|
|
152
|
+
}
|
|
153
|
+
|
|
154
|
+
- (void)sendEvent:(NSString *)type payload:(NSDictionary *_Nullable)payload {
|
|
155
|
+
if (!self.onNativeEvent) {
|
|
156
|
+
return;
|
|
157
|
+
}
|
|
158
|
+
|
|
159
|
+
NSMutableDictionary *event = [@{
|
|
160
|
+
@"type" : type,
|
|
161
|
+
} mutableCopy];
|
|
162
|
+
|
|
163
|
+
if (payload != nil) {
|
|
164
|
+
[event addEntriesFromDictionary:payload];
|
|
165
|
+
}
|
|
166
|
+
|
|
167
|
+
self.onNativeEvent(event);
|
|
168
|
+
}
|
|
169
|
+
|
|
170
|
+
- (void)bannerViewDidReceiveAd:(GADBannerView *)bannerView {
|
|
171
|
+
[self sendEvent:@"onAdLoaded"
|
|
172
|
+
payload:@{
|
|
173
|
+
@"width" : @(bannerView.bounds.size.width),
|
|
174
|
+
@"height" : @(bannerView.bounds.size.height),
|
|
175
|
+
}];
|
|
176
|
+
}
|
|
177
|
+
|
|
178
|
+
- (void)bannerView:(GADBannerView *)bannerView didFailToReceiveAdWithError:(NSError *)error {
|
|
179
|
+
NSDictionary *errorAndMessage = [RNGoogleMobileAdsCommon getCodeAndMessageFromAdError:error];
|
|
180
|
+
[self sendEvent:@"onAdFailedToLoad" payload:errorAndMessage];
|
|
181
|
+
}
|
|
182
|
+
|
|
183
|
+
- (void)bannerViewWillPresentScreen:(GADBannerView *)bannerView {
|
|
184
|
+
[self sendEvent:@"onAdOpened" payload:nil];
|
|
185
|
+
}
|
|
186
|
+
|
|
187
|
+
- (void)bannerViewDidRecordImpression:(GADBannerView *)bannerView {
|
|
188
|
+
[self sendEvent:@"onAdImpression" payload:nil];
|
|
189
|
+
}
|
|
190
|
+
|
|
191
|
+
- (void)bannerViewDidRecordClick:(GADBannerView *)bannerView {
|
|
192
|
+
[self sendEvent:@"onAdClicked" payload:nil];
|
|
193
|
+
}
|
|
194
|
+
|
|
195
|
+
- (void)bannerViewWillDismissScreen:(GADBannerView *)bannerView {
|
|
196
|
+
// not in use
|
|
197
|
+
}
|
|
198
|
+
|
|
199
|
+
- (void)bannerViewDidDismissScreen:(GADBannerView *)bannerView {
|
|
200
|
+
[self sendEvent:@"onAdClosed" payload:nil];
|
|
201
|
+
}
|
|
202
|
+
|
|
203
|
+
- (void)adView:(nonnull GADBannerView *)banner
|
|
204
|
+
didReceiveAppEvent:(nonnull NSString *)name
|
|
205
|
+
withInfo:(nullable NSString *)info {
|
|
206
|
+
[self sendEvent:@"onAppEvent"
|
|
207
|
+
payload:@{
|
|
208
|
+
@"name" : name,
|
|
209
|
+
@"data" : info ?: @"",
|
|
210
|
+
}];
|
|
211
|
+
}
|
|
212
|
+
|
|
213
|
+
- (void)recordManualImpression {
|
|
214
|
+
if ([_banner class] == [GAMBannerView class]) {
|
|
215
|
+
[((GAMBannerView *)_banner) recordImpression];
|
|
216
|
+
}
|
|
217
|
+
}
|
|
218
|
+
|
|
219
|
+
@end
|
|
220
|
+
|
|
221
|
+
#endif
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
#if !TARGET_OS_MACCATALYST
|
|
2
|
+
|
|
3
|
+
// This guard prevent this file to be compiled in the old architecture.
|
|
4
|
+
#ifdef RCT_NEW_ARCH_ENABLED
|
|
5
|
+
#import <GoogleMobileAds/GADAppEventDelegate.h>
|
|
6
|
+
#import <GoogleMobileAds/GADBannerView.h>
|
|
7
|
+
#import <GoogleMobileAds/GADBannerViewDelegate.h>
|
|
8
|
+
#import <React/RCTViewComponentView.h>
|
|
9
|
+
#import <UIKit/UIKit.h>
|
|
10
|
+
|
|
11
|
+
#ifndef NativeComponentExampleComponentView_h
|
|
12
|
+
#define NativeComponentExampleComponentView_h
|
|
13
|
+
|
|
14
|
+
NS_ASSUME_NONNULL_BEGIN
|
|
15
|
+
|
|
16
|
+
@interface RNGoogleMobileAdsBannerView
|
|
17
|
+
: RCTViewComponentView <GADBannerViewDelegate, GADAppEventDelegate>
|
|
18
|
+
|
|
19
|
+
@property GADBannerView *banner;
|
|
20
|
+
@property(nonatomic, assign) BOOL requested;
|
|
21
|
+
|
|
22
|
+
@property(nonatomic, copy) NSDictionary *sizeConfig;
|
|
23
|
+
@property(nonatomic, copy) NSString *unitId;
|
|
24
|
+
@property(nonatomic, copy) NSDictionary *request;
|
|
25
|
+
@property(nonatomic, copy) NSNumber *manualImpressionsEnabled;
|
|
26
|
+
|
|
27
|
+
@end
|
|
28
|
+
|
|
29
|
+
NS_ASSUME_NONNULL_END
|
|
30
|
+
|
|
31
|
+
#endif /* NativeComponentExampleComponentView_h */
|
|
32
|
+
#endif /* RCT_NEW_ARCH_ENABLED */
|
|
33
|
+
|
|
34
|
+
#endif
|
|
@@ -0,0 +1,282 @@
|
|
|
1
|
+
#if !TARGET_OS_MACCATALYST
|
|
2
|
+
|
|
3
|
+
// This guard prevent the code from being compiled in the old architecture
|
|
4
|
+
#ifdef RCT_NEW_ARCH_ENABLED
|
|
5
|
+
#import "RNGoogleMobileAdsBannerView.h"
|
|
6
|
+
#import "RNGoogleMobileAdsCommon.h"
|
|
7
|
+
|
|
8
|
+
#import <react/renderer/components/RNGoogleMobileAdsSpec/ComponentDescriptors.h>
|
|
9
|
+
#import <react/renderer/components/RNGoogleMobileAdsSpec/EventEmitters.h>
|
|
10
|
+
#import <react/renderer/components/RNGoogleMobileAdsSpec/Props.h>
|
|
11
|
+
#import <react/renderer/components/RNGoogleMobileAdsSpec/RCTComponentViewHelpers.h>
|
|
12
|
+
|
|
13
|
+
#import "RCTFabricComponentsPlugins.h"
|
|
14
|
+
|
|
15
|
+
using namespace facebook::react;
|
|
16
|
+
|
|
17
|
+
@interface RNGoogleMobileAdsBannerView () <RCTRNGoogleMobileAdsBannerViewViewProtocol>
|
|
18
|
+
|
|
19
|
+
@end
|
|
20
|
+
|
|
21
|
+
@implementation RNGoogleMobileAdsBannerView
|
|
22
|
+
|
|
23
|
+
+ (ComponentDescriptorProvider)componentDescriptorProvider {
|
|
24
|
+
return concreteComponentDescriptorProvider<RNGoogleMobileAdsBannerViewComponentDescriptor>();
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
- (instancetype)initWithFrame:(CGRect)frame {
|
|
28
|
+
if (self = [super initWithFrame:frame]) {
|
|
29
|
+
static const auto defaultProps = std::make_shared<const RNGoogleMobileAdsBannerViewProps>();
|
|
30
|
+
_props = defaultProps;
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
return self;
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
- (void)prepareForRecycle {
|
|
37
|
+
[super prepareForRecycle];
|
|
38
|
+
static const auto defaultProps = std::make_shared<const RNGoogleMobileAdsBannerViewProps>();
|
|
39
|
+
_props = defaultProps;
|
|
40
|
+
|
|
41
|
+
if (_banner) {
|
|
42
|
+
[_banner removeFromSuperview];
|
|
43
|
+
_banner = nil;
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
- (void)updateProps:(Props::Shared const &)props oldProps:(Props::Shared const &)oldProps {
|
|
48
|
+
const auto &oldViewProps =
|
|
49
|
+
*std::static_pointer_cast<RNGoogleMobileAdsBannerViewProps const>(_props);
|
|
50
|
+
const auto &newViewProps =
|
|
51
|
+
*std::static_pointer_cast<RNGoogleMobileAdsBannerViewProps const>(props);
|
|
52
|
+
|
|
53
|
+
BOOL propsChanged = false;
|
|
54
|
+
|
|
55
|
+
if (oldViewProps.unitId != newViewProps.unitId) {
|
|
56
|
+
_unitId = [[NSString alloc] initWithUTF8String:newViewProps.unitId.c_str()];
|
|
57
|
+
propsChanged = true;
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
if (oldViewProps.sizeConfig.sizes != newViewProps.sizeConfig.sizes ||
|
|
61
|
+
oldViewProps.sizeConfig.maxHeight != newViewProps.sizeConfig.maxHeight ||
|
|
62
|
+
oldViewProps.sizeConfig.width != newViewProps.sizeConfig.width) {
|
|
63
|
+
NSMutableArray *adSizes =
|
|
64
|
+
[NSMutableArray arrayWithCapacity:newViewProps.sizeConfig.sizes.size()];
|
|
65
|
+
CGFloat maxAdHeight =
|
|
66
|
+
newViewProps.sizeConfig.maxHeight > 0 ? newViewProps.sizeConfig.maxHeight : -1;
|
|
67
|
+
CGFloat width = newViewProps.sizeConfig.width > 0 ? newViewProps.sizeConfig.width : -1;
|
|
68
|
+
for (auto i = 0; i < newViewProps.sizeConfig.sizes.size(); i++) {
|
|
69
|
+
NSString *jsonValue =
|
|
70
|
+
[[NSString alloc] initWithUTF8String:newViewProps.sizeConfig.sizes[i].c_str()];
|
|
71
|
+
GADAdSize adSize = [RNGoogleMobileAdsCommon stringToAdSize:jsonValue
|
|
72
|
+
withMaxHeight:maxAdHeight
|
|
73
|
+
andWidth:width];
|
|
74
|
+
if (GADAdSizeEqualToSize(adSize, GADAdSizeInvalid)) {
|
|
75
|
+
RCTLogWarn(@"Invalid adSize %@", jsonValue);
|
|
76
|
+
} else {
|
|
77
|
+
[adSizes addObject:NSValueFromGADAdSize(adSize)];
|
|
78
|
+
}
|
|
79
|
+
}
|
|
80
|
+
_sizeConfig = @{
|
|
81
|
+
@"sizes" : adSizes,
|
|
82
|
+
@"maxHeight" : [NSNumber numberWithFloat:maxAdHeight],
|
|
83
|
+
@"width" : [NSNumber numberWithFloat:width]
|
|
84
|
+
};
|
|
85
|
+
propsChanged = true;
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
if (_request == nil) {
|
|
89
|
+
_request = [NSDictionary dictionary];
|
|
90
|
+
}
|
|
91
|
+
if (oldViewProps.request != newViewProps.request) {
|
|
92
|
+
NSString *jsonString = [[NSString alloc] initWithUTF8String:newViewProps.request.c_str()];
|
|
93
|
+
NSData *jsonData = [jsonString dataUsingEncoding:NSUTF8StringEncoding];
|
|
94
|
+
NSError *error = nil;
|
|
95
|
+
_request = [NSJSONSerialization JSONObjectWithData:jsonData options:kNilOptions error:&error];
|
|
96
|
+
if (error) {
|
|
97
|
+
NSLog(@"Error parsing JSON: %@", error.localizedDescription);
|
|
98
|
+
}
|
|
99
|
+
propsChanged = true;
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
if (_manualImpressionsEnabled == nil) {
|
|
103
|
+
_manualImpressionsEnabled = [NSNumber numberWithBool:oldViewProps.manualImpressionsEnabled];
|
|
104
|
+
}
|
|
105
|
+
if (oldViewProps.manualImpressionsEnabled != newViewProps.manualImpressionsEnabled) {
|
|
106
|
+
_manualImpressionsEnabled = [NSNumber numberWithBool:newViewProps.manualImpressionsEnabled];
|
|
107
|
+
propsChanged = true;
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
if (propsChanged) {
|
|
111
|
+
[self requestAd];
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
[super updateProps:props oldProps:oldProps];
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
- (void)dealloc {
|
|
118
|
+
if (_banner) {
|
|
119
|
+
[_banner removeFromSuperview];
|
|
120
|
+
_banner = nil;
|
|
121
|
+
}
|
|
122
|
+
}
|
|
123
|
+
|
|
124
|
+
#pragma mark - Methods
|
|
125
|
+
|
|
126
|
+
- (void)initBanner:(GADAdSize)adSize {
|
|
127
|
+
if (_requested) {
|
|
128
|
+
[_banner removeFromSuperview];
|
|
129
|
+
}
|
|
130
|
+
if ([RNGoogleMobileAdsCommon isAdManagerUnit:_unitId]) {
|
|
131
|
+
_banner = [[GAMBannerView alloc] initWithAdSize:adSize];
|
|
132
|
+
|
|
133
|
+
((GAMBannerView *)_banner).validAdSizes = _sizeConfig[@"sizes"];
|
|
134
|
+
((GAMBannerView *)_banner).appEventDelegate = self;
|
|
135
|
+
((GAMBannerView *)_banner).enableManualImpressions = [_manualImpressionsEnabled boolValue];
|
|
136
|
+
} else {
|
|
137
|
+
_banner = [[GADBannerView alloc] initWithAdSize:adSize];
|
|
138
|
+
}
|
|
139
|
+
_banner.paidEventHandler = ^(GADAdValue *_Nonnull value) {
|
|
140
|
+
std::dynamic_pointer_cast<const facebook::react::RNGoogleMobileAdsBannerViewEventEmitter>(
|
|
141
|
+
_eventEmitter)
|
|
142
|
+
->onNativeEvent(facebook::react::RNGoogleMobileAdsBannerViewEventEmitter::OnNativeEvent {
|
|
143
|
+
.type = "onPaid", .value = value.value.doubleValue,
|
|
144
|
+
.precision = @(value.precision).doubleValue, .currency = value.currencyCode.UTF8String
|
|
145
|
+
});
|
|
146
|
+
};
|
|
147
|
+
_banner.rootViewController = [UIApplication sharedApplication].delegate.window.rootViewController;
|
|
148
|
+
_banner.delegate = self;
|
|
149
|
+
}
|
|
150
|
+
|
|
151
|
+
- (void)requestAd {
|
|
152
|
+
#ifndef __LP64__
|
|
153
|
+
return; // prevent crash on 32bit
|
|
154
|
+
#endif
|
|
155
|
+
|
|
156
|
+
if (_unitId == nil || _sizeConfig == nil || _request == nil || _manualImpressionsEnabled == nil) {
|
|
157
|
+
[self setRequested:NO];
|
|
158
|
+
return;
|
|
159
|
+
} else {
|
|
160
|
+
[self initBanner:GADAdSizeFromNSValue(_sizeConfig[@"sizes"][0])];
|
|
161
|
+
[self addSubview:_banner];
|
|
162
|
+
_banner.adUnitID = _unitId;
|
|
163
|
+
[self setRequested:YES];
|
|
164
|
+
[self load];
|
|
165
|
+
}
|
|
166
|
+
}
|
|
167
|
+
|
|
168
|
+
- (void)load {
|
|
169
|
+
[_banner loadRequest:[RNGoogleMobileAdsCommon buildAdRequest:_request]];
|
|
170
|
+
if (_eventEmitter != nullptr) {
|
|
171
|
+
std::dynamic_pointer_cast<const facebook::react::RNGoogleMobileAdsBannerViewEventEmitter>(
|
|
172
|
+
_eventEmitter)
|
|
173
|
+
->onNativeEvent(facebook::react::RNGoogleMobileAdsBannerViewEventEmitter::OnNativeEvent{
|
|
174
|
+
.type = "onSizeChange",
|
|
175
|
+
.width = _banner.bounds.size.width,
|
|
176
|
+
.height = _banner.bounds.size.height});
|
|
177
|
+
}
|
|
178
|
+
}
|
|
179
|
+
|
|
180
|
+
- (void)handleCommand:(const NSString *)commandName args:(const NSArray *)args {
|
|
181
|
+
if ([commandName isEqual:@"recordManualImpression"]) {
|
|
182
|
+
[self recordManualImpression];
|
|
183
|
+
} else if ([commandName isEqual:@"load"]) {
|
|
184
|
+
[self load];
|
|
185
|
+
}
|
|
186
|
+
}
|
|
187
|
+
|
|
188
|
+
- (void)recordManualImpression {
|
|
189
|
+
if ([_banner class] == [GAMBannerView class]) {
|
|
190
|
+
[((GAMBannerView *)_banner) recordImpression];
|
|
191
|
+
}
|
|
192
|
+
}
|
|
193
|
+
|
|
194
|
+
#pragma mark - Events
|
|
195
|
+
|
|
196
|
+
- (void)bannerViewDidReceiveAd:(GADBannerView *)bannerView {
|
|
197
|
+
if (_eventEmitter != nullptr) {
|
|
198
|
+
std::dynamic_pointer_cast<const facebook::react::RNGoogleMobileAdsBannerViewEventEmitter>(
|
|
199
|
+
_eventEmitter)
|
|
200
|
+
->onNativeEvent(facebook::react::RNGoogleMobileAdsBannerViewEventEmitter::OnNativeEvent{
|
|
201
|
+
.type = "onAdLoaded",
|
|
202
|
+
.width = bannerView.bounds.size.width,
|
|
203
|
+
.height = bannerView.bounds.size.height});
|
|
204
|
+
}
|
|
205
|
+
}
|
|
206
|
+
|
|
207
|
+
- (void)bannerView:(GADBannerView *)bannerView didFailToReceiveAdWithError:(NSError *)error {
|
|
208
|
+
NSDictionary *errorAndMessage = [RNGoogleMobileAdsCommon getCodeAndMessageFromAdError:error];
|
|
209
|
+
if (_eventEmitter != nullptr) {
|
|
210
|
+
std::dynamic_pointer_cast<const facebook::react::RNGoogleMobileAdsBannerViewEventEmitter>(
|
|
211
|
+
_eventEmitter)
|
|
212
|
+
->onNativeEvent(facebook::react::RNGoogleMobileAdsBannerViewEventEmitter::OnNativeEvent{
|
|
213
|
+
.type = "onAdFailedToLoad",
|
|
214
|
+
.code = std::string([[errorAndMessage valueForKey:@"code"] UTF8String]),
|
|
215
|
+
.message = std::string([[errorAndMessage valueForKey:@"message"] UTF8String])});
|
|
216
|
+
}
|
|
217
|
+
}
|
|
218
|
+
|
|
219
|
+
- (void)bannerViewWillPresentScreen:(GADBannerView *)bannerView {
|
|
220
|
+
if (_eventEmitter != nullptr) {
|
|
221
|
+
std::dynamic_pointer_cast<const facebook::react::RNGoogleMobileAdsBannerViewEventEmitter>(
|
|
222
|
+
_eventEmitter)
|
|
223
|
+
->onNativeEvent(facebook::react::RNGoogleMobileAdsBannerViewEventEmitter::OnNativeEvent{
|
|
224
|
+
.type = "onAdOpened"});
|
|
225
|
+
}
|
|
226
|
+
}
|
|
227
|
+
|
|
228
|
+
- (void)bannerViewDidRecordImpression:(GADBannerView *)bannerView {
|
|
229
|
+
if (_eventEmitter != nullptr) {
|
|
230
|
+
std::dynamic_pointer_cast<const facebook::react::RNGoogleMobileAdsBannerViewEventEmitter>(
|
|
231
|
+
_eventEmitter)
|
|
232
|
+
->onNativeEvent(facebook::react::RNGoogleMobileAdsBannerViewEventEmitter::OnNativeEvent{
|
|
233
|
+
.type = "onAdImpression"});
|
|
234
|
+
}
|
|
235
|
+
}
|
|
236
|
+
|
|
237
|
+
- (void)bannerViewDidRecordClick:(GADBannerView *)bannerView {
|
|
238
|
+
if (_eventEmitter != nullptr) {
|
|
239
|
+
std::dynamic_pointer_cast<const facebook::react::RNGoogleMobileAdsBannerViewEventEmitter>(
|
|
240
|
+
_eventEmitter)
|
|
241
|
+
->onNativeEvent(facebook::react::RNGoogleMobileAdsBannerViewEventEmitter::OnNativeEvent{
|
|
242
|
+
.type = "onAdClicked"});
|
|
243
|
+
}
|
|
244
|
+
}
|
|
245
|
+
|
|
246
|
+
- (void)bannerViewWillDismissScreen:(GADBannerView *)bannerView {
|
|
247
|
+
// not in use
|
|
248
|
+
}
|
|
249
|
+
|
|
250
|
+
- (void)bannerViewDidDismissScreen:(GADBannerView *)bannerView {
|
|
251
|
+
if (_eventEmitter != nullptr) {
|
|
252
|
+
std::dynamic_pointer_cast<const facebook::react::RNGoogleMobileAdsBannerViewEventEmitter>(
|
|
253
|
+
_eventEmitter)
|
|
254
|
+
->onNativeEvent(facebook::react::RNGoogleMobileAdsBannerViewEventEmitter::OnNativeEvent{
|
|
255
|
+
.type = "onAdClosed"});
|
|
256
|
+
}
|
|
257
|
+
}
|
|
258
|
+
|
|
259
|
+
- (void)adView:(nonnull GADBannerView *)banner
|
|
260
|
+
didReceiveAppEvent:(nonnull NSString *)name
|
|
261
|
+
withInfo:(nullable NSString *)info {
|
|
262
|
+
if (_eventEmitter != nullptr) {
|
|
263
|
+
std::dynamic_pointer_cast<const facebook::react::RNGoogleMobileAdsBannerViewEventEmitter>(
|
|
264
|
+
_eventEmitter)
|
|
265
|
+
->onNativeEvent(facebook::react::RNGoogleMobileAdsBannerViewEventEmitter::OnNativeEvent{
|
|
266
|
+
.type = "onAppEvent",
|
|
267
|
+
.name = std::string([name UTF8String]),
|
|
268
|
+
.data = std::string(info ? [info UTF8String] : "")});
|
|
269
|
+
}
|
|
270
|
+
}
|
|
271
|
+
|
|
272
|
+
@end
|
|
273
|
+
|
|
274
|
+
#pragma mark - RNGoogleMobileAdsBannerViewCls
|
|
275
|
+
|
|
276
|
+
Class<RCTComponentViewProtocol> RNGoogleMobileAdsBannerViewCls(void) {
|
|
277
|
+
return RNGoogleMobileAdsBannerView.class;
|
|
278
|
+
}
|
|
279
|
+
|
|
280
|
+
#endif
|
|
281
|
+
|
|
282
|
+
#endif
|
|
@@ -0,0 +1,87 @@
|
|
|
1
|
+
//
|
|
2
|
+
/**
|
|
3
|
+
* Copyright (c) 2016-present Invertase Limited & Contributors
|
|
4
|
+
*
|
|
5
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
6
|
+
* you may not use this library except in compliance with the License.
|
|
7
|
+
* You may obtain a copy of the License at
|
|
8
|
+
*
|
|
9
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
10
|
+
*
|
|
11
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
12
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
13
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
14
|
+
* See the License for the specific language governing permissions and
|
|
15
|
+
* limitations under the License.
|
|
16
|
+
*
|
|
17
|
+
*/
|
|
18
|
+
|
|
19
|
+
#ifndef RCT_NEW_ARCH_ENABLED
|
|
20
|
+
#import <React/RCTUIManager.h>
|
|
21
|
+
#import <React/RCTViewManager.h>
|
|
22
|
+
|
|
23
|
+
#import "RNGoogleMobileAdsBannerComponent.h"
|
|
24
|
+
|
|
25
|
+
@interface RNGoogleMobileAdsBannerViewManager : RCTViewManager
|
|
26
|
+
@end
|
|
27
|
+
|
|
28
|
+
@implementation RNGoogleMobileAdsBannerViewManager
|
|
29
|
+
|
|
30
|
+
RCT_EXPORT_MODULE(RNGoogleMobileAdsBannerView);
|
|
31
|
+
|
|
32
|
+
RCT_EXPORT_VIEW_PROPERTY(sizeConfig, NSDictionary);
|
|
33
|
+
|
|
34
|
+
RCT_EXPORT_VIEW_PROPERTY(unitId, NSString);
|
|
35
|
+
|
|
36
|
+
RCT_EXPORT_VIEW_PROPERTY(request, NSString);
|
|
37
|
+
|
|
38
|
+
RCT_EXPORT_VIEW_PROPERTY(manualImpressionsEnabled, BOOL);
|
|
39
|
+
|
|
40
|
+
RCT_EXPORT_VIEW_PROPERTY(onNativeEvent, RCTBubblingEventBlock);
|
|
41
|
+
|
|
42
|
+
RCT_EXPORT_METHOD(recordManualImpression : (nonnull NSNumber *)reactTag) {
|
|
43
|
+
#if !TARGET_OS_MACCATALYST
|
|
44
|
+
[self.bridge.uiManager
|
|
45
|
+
addUIBlock:^(RCTUIManager *uiManager, NSDictionary<NSNumber *, UIView *> *viewRegistry) {
|
|
46
|
+
RNGoogleMobileAdsBannerComponent *banner = viewRegistry[reactTag];
|
|
47
|
+
if (!banner || ![banner isKindOfClass:[RNGoogleMobileAdsBannerComponent class]]) {
|
|
48
|
+
RCTLogError(@"Cannot find NativeView with tag #%@", reactTag);
|
|
49
|
+
return;
|
|
50
|
+
}
|
|
51
|
+
[banner recordManualImpression];
|
|
52
|
+
}];
|
|
53
|
+
#endif
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
RCT_EXPORT_METHOD(load : (nonnull NSNumber *)reactTag) {
|
|
57
|
+
#if !TARGET_OS_MACCATALYST
|
|
58
|
+
[self.bridge.uiManager
|
|
59
|
+
addUIBlock:^(RCTUIManager *uiManager, NSDictionary<NSNumber *, UIView *> *viewRegistry) {
|
|
60
|
+
RNGoogleMobileAdsBannerComponent *banner = viewRegistry[reactTag];
|
|
61
|
+
if (!banner || ![banner isKindOfClass:[RNGoogleMobileAdsBannerComponent class]]) {
|
|
62
|
+
RCTLogError(@"Cannot find NativeView with tag #%@", reactTag);
|
|
63
|
+
return;
|
|
64
|
+
}
|
|
65
|
+
[banner load];
|
|
66
|
+
}];
|
|
67
|
+
#endif
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
@synthesize bridge = _bridge;
|
|
71
|
+
|
|
72
|
+
- (UIView *)view {
|
|
73
|
+
#if TARGET_OS_MACCATALYST
|
|
74
|
+
return nil;
|
|
75
|
+
#else
|
|
76
|
+
RNGoogleMobileAdsBannerComponent *banner = [RNGoogleMobileAdsBannerComponent new];
|
|
77
|
+
return banner;
|
|
78
|
+
#endif
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
- (dispatch_queue_t)methodQueue {
|
|
82
|
+
return dispatch_get_main_queue();
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
@end
|
|
86
|
+
|
|
87
|
+
#endif
|
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
//
|
|
2
|
+
/**
|
|
3
|
+
* Copyright (c) 2016-present Invertase Limited & Contributors
|
|
4
|
+
*
|
|
5
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
6
|
+
* you may not use this library except in compliance with the License.
|
|
7
|
+
* You may obtain a copy of the License at
|
|
8
|
+
*
|
|
9
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
10
|
+
*
|
|
11
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
12
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
13
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
14
|
+
* See the License for the specific language governing permissions and
|
|
15
|
+
* limitations under the License.
|
|
16
|
+
*
|
|
17
|
+
*/
|
|
18
|
+
|
|
19
|
+
#if !TARGET_OS_MACCATALYST
|
|
20
|
+
|
|
21
|
+
#import <GoogleMobileAds/GoogleMobileAds.h>
|
|
22
|
+
#import <React/RCTBridgeModule.h>
|
|
23
|
+
|
|
24
|
+
@interface RNGoogleMobileAdsCommon : NSObject
|
|
25
|
+
|
|
26
|
+
+ (GAMRequest *_Nonnull)buildAdRequest:(NSDictionary *_Nonnull)adRequestOptions;
|
|
27
|
+
|
|
28
|
+
+ (NSDictionary *_Nonnull)getCodeAndMessageFromAdError:(NSError *_Nonnull)error;
|
|
29
|
+
|
|
30
|
+
+ (void)sendAdEvent:(NSString *_Nonnull)event
|
|
31
|
+
requestId:(NSNumber *_Nonnull)requestId
|
|
32
|
+
type:(NSString *_Nonnull)type
|
|
33
|
+
adUnitId:(NSString *_Nonnull)adUnitId
|
|
34
|
+
error:(nullable NSDictionary *)error
|
|
35
|
+
data:(nullable NSDictionary *)data;
|
|
36
|
+
|
|
37
|
+
+ (GADAdSize)stringToAdSize:(NSString *_Nonnull)value
|
|
38
|
+
withMaxHeight:(CGFloat)maxHeight
|
|
39
|
+
andWidth:(CGFloat)adWidth;
|
|
40
|
+
|
|
41
|
+
+ (BOOL)isAdManagerUnit:(NSString *_Nonnull)unitId;
|
|
42
|
+
|
|
43
|
+
+ (nullable UIViewController *)currentViewController;
|
|
44
|
+
|
|
45
|
+
@end
|
|
46
|
+
|
|
47
|
+
@interface RNGADInterstitial : GADInterstitialAd
|
|
48
|
+
@property(nonatomic) NSNumber *_Nonnull requestId;
|
|
49
|
+
- (void)setRequestId:(NSNumber *_Nonnull)requestId;
|
|
50
|
+
@end
|
|
51
|
+
|
|
52
|
+
@interface RNGADRewarded : GADRewardedAd
|
|
53
|
+
@property(nonatomic) NSNumber *_Nonnull requestId;
|
|
54
|
+
- (void)setRequestId:(NSNumber *_Nonnull)requestId;
|
|
55
|
+
@end
|
|
56
|
+
|
|
57
|
+
extern NSString *_Nonnull const GOOGLE_MOBILE_ADS_EVENT_APP_OPEN;
|
|
58
|
+
extern NSString *_Nonnull const GOOGLE_MOBILE_ADS_EVENT_INTERSTITIAL;
|
|
59
|
+
extern NSString *_Nonnull const GOOGLE_MOBILE_ADS_EVENT_REWARDED;
|
|
60
|
+
extern NSString *_Nonnull const GOOGLE_MOBILE_ADS_EVENT_REWARDED_INTERSTITIAL;
|
|
61
|
+
|
|
62
|
+
extern NSString *_Nonnull const GOOGLE_MOBILE_ADS_EVENT_LOADED;
|
|
63
|
+
extern NSString *_Nonnull const GOOGLE_MOBILE_ADS_EVENT_ERROR;
|
|
64
|
+
extern NSString *_Nonnull const GOOGLE_MOBILE_ADS_EVENT_OPENED;
|
|
65
|
+
extern NSString *_Nonnull const GOOGLE_MOBILE_ADS_EVENT_CLICKED;
|
|
66
|
+
extern NSString *_Nonnull const GOOGLE_MOBILE_ADS_EVENT_CLOSED;
|
|
67
|
+
extern NSString *_Nonnull const GOOGLE_MOBILE_ADS_EVENT_APP_EVENT;
|
|
68
|
+
|
|
69
|
+
extern NSString *_Nonnull const GOOGLE_MOBILE_ADS_EVENT_REWARDED_LOADED;
|
|
70
|
+
extern NSString *_Nonnull const GOOGLE_MOBILE_ADS_EVENT_REWARDED_EARNED_REWARD;
|
|
71
|
+
|
|
72
|
+
#endif
|