react-native-google-mobile-ads 4.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +32 -0
- package/README.md +65 -0
- package/RNGoogleMobileAds.podspec +42 -0
- package/__tests__/consent.test.ts +25 -0
- package/__tests__/googleMobileAds.test.ts +63 -0
- package/__tests__/interstitial.test.ts +53 -0
- package/__tests__/requestOptions.test.tsx +4 -0
- package/__tests__/rewarded.test.tsx +4 -0
- package/__tests__/showOptions.test.tsx +4 -0
- package/android/.editorconfig +10 -0
- package/android/app-json.gradle +69 -0
- package/android/build.gradle +98 -0
- package/android/lint.xml +5 -0
- package/android/settings.gradle +1 -0
- package/android/src/main/AndroidManifest.xml +17 -0
- package/android/src/main/java/io/invertase/googlemobileads/ReactNativeAppModule.java +169 -0
- package/android/src/main/java/io/invertase/googlemobileads/ReactNativeGoogleMobileAdsAppOpenModule.java +161 -0
- package/android/src/main/java/io/invertase/googlemobileads/ReactNativeGoogleMobileAdsBannerAdViewManager.java +209 -0
- package/android/src/main/java/io/invertase/googlemobileads/ReactNativeGoogleMobileAdsCommon.java +256 -0
- package/android/src/main/java/io/invertase/googlemobileads/ReactNativeGoogleMobileAdsConsentModule.java +226 -0
- package/android/src/main/java/io/invertase/googlemobileads/ReactNativeGoogleMobileAdsEvent.java +72 -0
- package/android/src/main/java/io/invertase/googlemobileads/ReactNativeGoogleMobileAdsInterstitialModule.java +159 -0
- package/android/src/main/java/io/invertase/googlemobileads/ReactNativeGoogleMobileAdsModule.java +143 -0
- package/android/src/main/java/io/invertase/googlemobileads/ReactNativeGoogleMobileAdsPackage.java +48 -0
- package/android/src/main/java/io/invertase/googlemobileads/ReactNativeGoogleMobileAdsRewardedModule.java +177 -0
- package/android/src/main/java/io/invertase/googlemobileads/common/RCTConvert.java +111 -0
- package/android/src/main/java/io/invertase/googlemobileads/common/ReactNativeApp.java +34 -0
- package/android/src/main/java/io/invertase/googlemobileads/common/ReactNativeEvent.java +41 -0
- package/android/src/main/java/io/invertase/googlemobileads/common/ReactNativeEventEmitter.java +150 -0
- package/android/src/main/java/io/invertase/googlemobileads/common/ReactNativeInitProvider.java +77 -0
- package/android/src/main/java/io/invertase/googlemobileads/common/ReactNativeJSON.java +107 -0
- package/android/src/main/java/io/invertase/googlemobileads/common/ReactNativeMeta.java +92 -0
- package/android/src/main/java/io/invertase/googlemobileads/common/ReactNativeModule.java +96 -0
- package/android/src/main/java/io/invertase/googlemobileads/common/ReactNativePreferences.java +86 -0
- package/android/src/main/java/io/invertase/googlemobileads/common/SharedUtils.java +427 -0
- package/android/src/main/java/io/invertase/googlemobileads/common/TaskExecutorService.java +124 -0
- package/android/src/main/java/io/invertase/googlemobileads/interfaces/ContextProvider.java +30 -0
- package/android/src/main/java/io/invertase/googlemobileads/interfaces/NativeError.java +28 -0
- package/android/src/main/java/io/invertase/googlemobileads/interfaces/NativeEvent.java +26 -0
- package/babel.config.js +18 -0
- package/docs/displaying-ads.mdx +319 -0
- package/docs/european-user-consent.mdx +258 -0
- package/docs/img/logo_admob_192px.svg +19 -0
- package/docs/index.mdx +168 -0
- package/docs.json +9 -0
- package/ios/RNGoogleMobileAds/RNGoogleMobileAdsAppOpenModule.h +29 -0
- package/ios/RNGoogleMobileAds/RNGoogleMobileAdsAppOpenModule.m +98 -0
- package/ios/RNGoogleMobileAds/RNGoogleMobileAdsBannerViewManager.h +23 -0
- package/ios/RNGoogleMobileAds/RNGoogleMobileAdsBannerViewManager.m +153 -0
- package/ios/RNGoogleMobileAds/RNGoogleMobileAdsCommon.h +60 -0
- package/ios/RNGoogleMobileAds/RNGoogleMobileAdsCommon.m +201 -0
- package/ios/RNGoogleMobileAds/RNGoogleMobileAdsConsentModule.h +26 -0
- package/ios/RNGoogleMobileAds/RNGoogleMobileAdsConsentModule.m +179 -0
- package/ios/RNGoogleMobileAds/RNGoogleMobileAdsFullScreenContentDelegate.h +32 -0
- package/ios/RNGoogleMobileAds/RNGoogleMobileAdsFullScreenContentDelegate.m +57 -0
- package/ios/RNGoogleMobileAds/RNGoogleMobileAdsInterstitialModule.h +25 -0
- package/ios/RNGoogleMobileAds/RNGoogleMobileAdsInterstitialModule.m +124 -0
- package/ios/RNGoogleMobileAds/RNGoogleMobileAdsModule.h +24 -0
- package/ios/RNGoogleMobileAds/RNGoogleMobileAdsModule.m +104 -0
- package/ios/RNGoogleMobileAds/RNGoogleMobileAdsRewardedModule.h +25 -0
- package/ios/RNGoogleMobileAds/RNGoogleMobileAdsRewardedModule.m +173 -0
- package/ios/RNGoogleMobileAds/common/RNAppModule.h +24 -0
- package/ios/RNGoogleMobileAds/common/RNAppModule.m +158 -0
- package/ios/RNGoogleMobileAds/common/RNJSON.h +34 -0
- package/ios/RNGoogleMobileAds/common/RNJSON.m +93 -0
- package/ios/RNGoogleMobileAds/common/RNMeta.h +30 -0
- package/ios/RNGoogleMobileAds/common/RNMeta.m +61 -0
- package/ios/RNGoogleMobileAds/common/RNPreferences.h +44 -0
- package/ios/RNGoogleMobileAds/common/RNPreferences.m +94 -0
- package/ios/RNGoogleMobileAds/common/RNRCTEventEmitter.h +73 -0
- package/ios/RNGoogleMobileAds/common/RNRCTEventEmitter.m +150 -0
- package/ios/RNGoogleMobileAds/common/RNSharedUtils.h +48 -0
- package/ios/RNGoogleMobileAds/common/RNSharedUtils.m +56 -0
- package/ios/RNGoogleMobileAds.xcodeproj/project.pbxproj +377 -0
- package/ios/RNGoogleMobileAds.xcodeproj/xcshareddata/IDETemplateMacros.plist +24 -0
- package/ios_config.sh +140 -0
- package/jest.config.js +6 -0
- package/jest.setup.ts +29 -0
- package/lib/commonjs/AdEventType.js +34 -0
- package/lib/commonjs/AdEventType.js.map +1 -0
- package/lib/commonjs/AdsConsent.js +160 -0
- package/lib/commonjs/AdsConsent.js.map +1 -0
- package/lib/commonjs/AdsConsentDebugGeography.js +38 -0
- package/lib/commonjs/AdsConsentDebugGeography.js.map +1 -0
- package/lib/commonjs/AdsConsentStatus.js +36 -0
- package/lib/commonjs/AdsConsentStatus.js.map +1 -0
- package/lib/commonjs/BannerAdSize.js +38 -0
- package/lib/commonjs/BannerAdSize.js.map +1 -0
- package/lib/commonjs/MaxAdContentRating.js +33 -0
- package/lib/commonjs/MaxAdContentRating.js.map +1 -0
- package/lib/commonjs/MobileAds.js +67 -0
- package/lib/commonjs/MobileAds.js.map +1 -0
- package/lib/commonjs/RewardedAdEventType.js +31 -0
- package/lib/commonjs/RewardedAdEventType.js.map +1 -0
- package/lib/commonjs/TestIds.js +47 -0
- package/lib/commonjs/TestIds.js.map +1 -0
- package/lib/commonjs/ads/AppOpenAd.js +96 -0
- package/lib/commonjs/ads/AppOpenAd.js.map +1 -0
- package/lib/commonjs/ads/BannerAd.js +128 -0
- package/lib/commonjs/ads/BannerAd.js.map +1 -0
- package/lib/commonjs/ads/InterstitialAd.js +163 -0
- package/lib/commonjs/ads/InterstitialAd.js.map +1 -0
- package/lib/commonjs/ads/MobileAd.js +90 -0
- package/lib/commonjs/ads/MobileAd.js.map +1 -0
- package/lib/commonjs/ads/RewardedAd.js +169 -0
- package/lib/commonjs/ads/RewardedAd.js.map +1 -0
- package/lib/commonjs/common/Base64.js +121 -0
- package/lib/commonjs/common/Base64.js.map +1 -0
- package/lib/commonjs/common/MutatableParams.js +46 -0
- package/lib/commonjs/common/MutatableParams.js.map +1 -0
- package/lib/commonjs/common/ReferenceBase.js +59 -0
- package/lib/commonjs/common/ReferenceBase.js.map +1 -0
- package/lib/commonjs/common/deeps.js +101 -0
- package/lib/commonjs/common/deeps.js.map +1 -0
- package/lib/commonjs/common/id.js +82 -0
- package/lib/commonjs/common/id.js.map +1 -0
- package/lib/commonjs/common/index.js +212 -0
- package/lib/commonjs/common/index.js.map +1 -0
- package/lib/commonjs/common/path.js +144 -0
- package/lib/commonjs/common/path.js.map +1 -0
- package/lib/commonjs/common/promise.js +70 -0
- package/lib/commonjs/common/promise.js.map +1 -0
- package/lib/commonjs/common/serialize.js +52 -0
- package/lib/commonjs/common/serialize.js.map +1 -0
- package/lib/commonjs/common/validate.js +239 -0
- package/lib/commonjs/common/validate.js.map +1 -0
- package/lib/commonjs/declarations.d.js +2 -0
- package/lib/commonjs/declarations.d.js.map +1 -0
- package/lib/commonjs/index.js +143 -0
- package/lib/commonjs/index.js.map +1 -0
- package/lib/commonjs/internal/GoogleMobileAdsNativeEventEmitter.js +76 -0
- package/lib/commonjs/internal/GoogleMobileAdsNativeEventEmitter.js.map +1 -0
- package/lib/commonjs/internal/Module.js +60 -0
- package/lib/commonjs/internal/Module.js.map +1 -0
- package/lib/commonjs/internal/NativeError.js +70 -0
- package/lib/commonjs/internal/NativeError.js.map +1 -0
- package/lib/commonjs/internal/SharedEventEmitter.js +31 -0
- package/lib/commonjs/internal/SharedEventEmitter.js.map +1 -0
- package/lib/commonjs/internal/constants.js +30 -0
- package/lib/commonjs/internal/constants.js.map +1 -0
- package/lib/commonjs/internal/index.js +49 -0
- package/lib/commonjs/internal/index.js.map +1 -0
- package/lib/commonjs/internal/registry/nativeModule.js +231 -0
- package/lib/commonjs/internal/registry/nativeModule.js.map +1 -0
- package/lib/commonjs/types/AdEventListener.js +6 -0
- package/lib/commonjs/types/AdEventListener.js.map +1 -0
- package/lib/commonjs/types/AdShowOptions.js +2 -0
- package/lib/commonjs/types/AdShowOptions.js.map +1 -0
- package/lib/commonjs/types/AdapterStatus.js +18 -0
- package/lib/commonjs/types/AdapterStatus.js.map +1 -0
- package/lib/commonjs/types/AdsConsent.interface.js +6 -0
- package/lib/commonjs/types/AdsConsent.interface.js.map +1 -0
- package/lib/commonjs/types/BannerAdProps.js +6 -0
- package/lib/commonjs/types/BannerAdProps.js.map +1 -0
- package/lib/commonjs/types/GoogleMobileAdsNativeModule.js +6 -0
- package/lib/commonjs/types/GoogleMobileAdsNativeModule.js.map +1 -0
- package/lib/commonjs/types/MobileAd.interface.js +6 -0
- package/lib/commonjs/types/MobileAd.interface.js.map +1 -0
- package/lib/commonjs/types/MobileAdsModule.interface.js +6 -0
- package/lib/commonjs/types/MobileAdsModule.interface.js.map +1 -0
- package/lib/commonjs/types/Module.interface.js +2 -0
- package/lib/commonjs/types/Module.interface.js.map +1 -0
- package/lib/commonjs/types/RequestConfiguration.js +6 -0
- package/lib/commonjs/types/RequestConfiguration.js.map +1 -0
- package/lib/commonjs/types/RequestOptions.js +2 -0
- package/lib/commonjs/types/RequestOptions.js.map +1 -0
- package/lib/commonjs/types/RewardedAdReward.js +2 -0
- package/lib/commonjs/types/RewardedAdReward.js.map +1 -0
- package/lib/commonjs/validateAdRequestConfiguration.js +69 -0
- package/lib/commonjs/validateAdRequestConfiguration.js.map +1 -0
- package/lib/commonjs/validateAdRequestOptions.js +158 -0
- package/lib/commonjs/validateAdRequestOptions.js.map +1 -0
- package/lib/commonjs/validateAdShowOptions.js +47 -0
- package/lib/commonjs/validateAdShowOptions.js.map +1 -0
- package/lib/commonjs/version.js +10 -0
- package/lib/commonjs/version.js.map +1 -0
- package/lib/module/AdEventType.js +26 -0
- package/lib/module/AdEventType.js.map +1 -0
- package/lib/module/AdsConsent.js +148 -0
- package/lib/module/AdsConsent.js.map +1 -0
- package/lib/module/AdsConsentDebugGeography.js +30 -0
- package/lib/module/AdsConsentDebugGeography.js.map +1 -0
- package/lib/module/AdsConsentStatus.js +28 -0
- package/lib/module/AdsConsentStatus.js.map +1 -0
- package/lib/module/BannerAdSize.js +30 -0
- package/lib/module/BannerAdSize.js.map +1 -0
- package/lib/module/MaxAdContentRating.js +25 -0
- package/lib/module/MaxAdContentRating.js.map +1 -0
- package/lib/module/MobileAds.js +53 -0
- package/lib/module/MobileAds.js.map +1 -0
- package/lib/module/RewardedAdEventType.js +23 -0
- package/lib/module/RewardedAdEventType.js.map +1 -0
- package/lib/module/TestIds.js +38 -0
- package/lib/module/TestIds.js.map +1 -0
- package/lib/module/ads/AppOpenAd.js +81 -0
- package/lib/module/ads/AppOpenAd.js.map +1 -0
- package/lib/module/ads/BannerAd.js +108 -0
- package/lib/module/ads/BannerAd.js.map +1 -0
- package/lib/module/ads/InterstitialAd.js +149 -0
- package/lib/module/ads/InterstitialAd.js.map +1 -0
- package/lib/module/ads/MobileAd.js +94 -0
- package/lib/module/ads/MobileAd.js.map +1 -0
- package/lib/module/ads/RewardedAd.js +155 -0
- package/lib/module/ads/RewardedAd.js.map +1 -0
- package/lib/module/common/Base64.js +106 -0
- package/lib/module/common/Base64.js.map +1 -0
- package/lib/module/common/MutatableParams.js +52 -0
- package/lib/module/common/MutatableParams.js.map +1 -0
- package/lib/module/common/ReferenceBase.js +50 -0
- package/lib/module/common/ReferenceBase.js.map +1 -0
- package/lib/module/common/deeps.js +91 -0
- package/lib/module/common/deeps.js.map +1 -0
- package/lib/module/common/id.js +74 -0
- package/lib/module/common/id.js.map +1 -0
- package/lib/module/common/index.js +109 -0
- package/lib/module/common/index.js.map +1 -0
- package/lib/module/common/path.js +120 -0
- package/lib/module/common/path.js.map +1 -0
- package/lib/module/common/promise.js +60 -0
- package/lib/module/common/promise.js.map +1 -0
- package/lib/module/common/serialize.js +41 -0
- package/lib/module/common/serialize.js.map +1 -0
- package/lib/module/common/validate.js +197 -0
- package/lib/module/common/validate.js.map +1 -0
- package/lib/module/declarations.d.js +2 -0
- package/lib/module/declarations.d.js.map +1 -0
- package/lib/module/index.js +33 -0
- package/lib/module/index.js.map +1 -0
- package/lib/module/internal/GoogleMobileAdsNativeEventEmitter.js +83 -0
- package/lib/module/internal/GoogleMobileAdsNativeEventEmitter.js.map +1 -0
- package/lib/module/internal/Module.js +64 -0
- package/lib/module/internal/Module.js.map +1 -0
- package/lib/module/internal/NativeError.js +61 -0
- package/lib/module/internal/NativeError.js.map +1 -0
- package/lib/module/internal/SharedEventEmitter.js +20 -0
- package/lib/module/internal/SharedEventEmitter.js.map +1 -0
- package/lib/module/internal/constants.js +20 -0
- package/lib/module/internal/constants.js.map +1 -0
- package/lib/module/internal/index.js +21 -0
- package/lib/module/internal/index.js.map +1 -0
- package/lib/module/internal/registry/nativeModule.js +215 -0
- package/lib/module/internal/registry/nativeModule.js.map +1 -0
- package/lib/module/types/AdEventListener.js +2 -0
- package/lib/module/types/AdEventListener.js.map +1 -0
- package/lib/module/types/AdShowOptions.js +2 -0
- package/lib/module/types/AdShowOptions.js.map +1 -0
- package/lib/module/types/AdapterStatus.js +10 -0
- package/lib/module/types/AdapterStatus.js.map +1 -0
- package/lib/module/types/AdsConsent.interface.js +2 -0
- package/lib/module/types/AdsConsent.interface.js.map +1 -0
- package/lib/module/types/BannerAdProps.js +2 -0
- package/lib/module/types/BannerAdProps.js.map +1 -0
- package/lib/module/types/GoogleMobileAdsNativeModule.js +2 -0
- package/lib/module/types/GoogleMobileAdsNativeModule.js.map +1 -0
- package/lib/module/types/MobileAd.interface.js +2 -0
- package/lib/module/types/MobileAd.interface.js.map +1 -0
- package/lib/module/types/MobileAdsModule.interface.js +2 -0
- package/lib/module/types/MobileAdsModule.interface.js.map +1 -0
- package/lib/module/types/Module.interface.js +2 -0
- package/lib/module/types/Module.interface.js.map +1 -0
- package/lib/module/types/RequestConfiguration.js +2 -0
- package/lib/module/types/RequestConfiguration.js.map +1 -0
- package/lib/module/types/RequestOptions.js +2 -0
- package/lib/module/types/RequestOptions.js.map +1 -0
- package/lib/module/types/RewardedAdReward.js +2 -0
- package/lib/module/types/RewardedAdReward.js.map +1 -0
- package/lib/module/validateAdRequestConfiguration.js +60 -0
- package/lib/module/validateAdRequestConfiguration.js.map +1 -0
- package/lib/module/validateAdRequestOptions.js +150 -0
- package/lib/module/validateAdRequestOptions.js.map +1 -0
- package/lib/module/validateAdShowOptions.js +39 -0
- package/lib/module/validateAdShowOptions.js.map +1 -0
- package/lib/module/version.js +3 -0
- package/lib/module/version.js.map +1 -0
- package/lib/typescript/AdEventType.d.ts +47 -0
- package/lib/typescript/AdsConsent.d.ts +2 -0
- package/lib/typescript/AdsConsentDebugGeography.d.ts +19 -0
- package/lib/typescript/AdsConsentStatus.d.ts +17 -0
- package/lib/typescript/BannerAdSize.d.ts +34 -0
- package/lib/typescript/MaxAdContentRating.d.ts +18 -0
- package/lib/typescript/MobileAds.d.ts +11 -0
- package/lib/typescript/RewardedAdEventType.d.ts +46 -0
- package/lib/typescript/TestIds.d.ts +6 -0
- package/lib/typescript/ads/AppOpenAd.d.ts +11 -0
- package/lib/typescript/ads/BannerAd.d.ts +3 -0
- package/lib/typescript/ads/InterstitialAd.d.ts +78 -0
- package/lib/typescript/ads/MobileAd.d.ts +32 -0
- package/lib/typescript/ads/RewardedAd.d.ts +84 -0
- package/lib/typescript/common/Base64.d.ts +14 -0
- package/lib/typescript/common/MutatableParams.d.ts +9 -0
- package/lib/typescript/common/ReferenceBase.d.ts +11 -0
- package/lib/typescript/common/deeps.d.ts +18 -0
- package/lib/typescript/common/id.d.ts +11 -0
- package/lib/typescript/common/index.d.ts +28 -0
- package/lib/typescript/common/path.d.ts +43 -0
- package/lib/typescript/common/promise.d.ts +13 -0
- package/lib/typescript/common/serialize.d.ts +5 -0
- package/lib/typescript/common/validate.d.ts +90 -0
- package/lib/typescript/index.d.ts +14 -0
- package/lib/typescript/internal/GoogleMobileAdsNativeEventEmitter.d.ts +12 -0
- package/lib/typescript/internal/Module.d.ts +13 -0
- package/lib/typescript/internal/NativeError.d.ts +26 -0
- package/lib/typescript/internal/SharedEventEmitter.d.ts +2 -0
- package/lib/typescript/internal/constants.d.ts +3 -0
- package/lib/typescript/internal/index.d.ts +4 -0
- package/lib/typescript/internal/registry/nativeModule.d.ts +15 -0
- package/lib/typescript/types/AdEventListener.d.ts +11 -0
- package/lib/typescript/types/AdShowOptions.d.ts +12 -0
- package/lib/typescript/types/AdapterStatus.d.ts +18 -0
- package/lib/typescript/types/AdsConsent.interface.d.ts +286 -0
- package/lib/typescript/types/BannerAdProps.d.ts +66 -0
- package/lib/typescript/types/GoogleMobileAdsNativeModule.d.ts +14 -0
- package/lib/typescript/types/MobileAd.interface.d.ts +64 -0
- package/lib/typescript/types/MobileAdsModule.interface.d.ts +38 -0
- package/lib/typescript/types/Module.interface.d.ts +14 -0
- package/lib/typescript/types/RequestConfiguration.d.ts +36 -0
- package/lib/typescript/types/RequestOptions.d.ts +106 -0
- package/lib/typescript/types/RewardedAdReward.d.ts +13 -0
- package/lib/typescript/validateAdRequestConfiguration.d.ts +2 -0
- package/lib/typescript/validateAdRequestOptions.d.ts +2 -0
- package/lib/typescript/validateAdShowOptions.d.ts +2 -0
- package/lib/typescript/version.d.ts +1 -0
- package/package.json +143 -0
- package/react-native.config.js +19 -0
- package/src/AdEventType.ts +68 -0
- package/src/AdsConsent.ts +191 -0
- package/src/AdsConsentDebugGeography.ts +38 -0
- package/src/AdsConsentStatus.ts +36 -0
- package/src/BannerAdSize.ts +59 -0
- package/src/MaxAdContentRating.ts +38 -0
- package/src/MobileAds.ts +84 -0
- package/src/RewardedAdEventType.ts +64 -0
- package/src/TestIds.ts +39 -0
- package/src/ads/AppOpenAd.ts +85 -0
- package/src/ads/BannerAd.tsx +126 -0
- package/src/ads/InterstitialAd.ts +156 -0
- package/src/ads/MobileAd.ts +101 -0
- package/src/ads/RewardedAd.ts +161 -0
- package/src/common/Base64.ts +114 -0
- package/src/common/MutatableParams.ts +50 -0
- package/src/common/ReferenceBase.ts +45 -0
- package/src/common/deeps.ts +88 -0
- package/src/common/id.ts +74 -0
- package/src/common/index.ts +103 -0
- package/src/common/path.ts +114 -0
- package/src/common/promise.ts +66 -0
- package/src/common/serialize.ts +43 -0
- package/src/common/validate.ts +205 -0
- package/src/declarations.d.ts +3 -0
- package/src/index.ts +35 -0
- package/src/internal/GoogleMobileAdsNativeEventEmitter.ts +81 -0
- package/src/internal/Module.ts +58 -0
- package/src/internal/NativeError.ts +56 -0
- package/src/internal/SharedEventEmitter.ts +22 -0
- package/src/internal/constants.ts +43 -0
- package/src/internal/index.ts +21 -0
- package/src/internal/registry/nativeModule.ts +226 -0
- package/src/types/AdEventListener.ts +16 -0
- package/src/types/AdShowOptions.ts +12 -0
- package/src/types/AdapterStatus.ts +20 -0
- package/src/types/AdsConsent.interface.ts +306 -0
- package/src/types/BannerAdProps.ts +73 -0
- package/src/types/GoogleMobileAdsNativeModule.ts +15 -0
- package/src/types/MobileAd.interface.ts +69 -0
- package/src/types/MobileAdsModule.interface.ts +43 -0
- package/src/types/Module.interface.ts +16 -0
- package/src/types/RequestConfiguration.ts +40 -0
- package/src/types/RequestOptions.ts +113 -0
- package/src/types/RewardedAdReward.ts +14 -0
- package/src/validateAdRequestConfiguration.ts +71 -0
- package/src/validateAdRequestOptions.ts +168 -0
- package/src/validateAdShowOptions.ts +41 -0
- package/src/version.ts +2 -0
|
@@ -0,0 +1,57 @@
|
|
|
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 "RNGoogleMobileAdsFullScreenContentDelegate.h"
|
|
19
|
+
|
|
20
|
+
@implementation RNGoogleMobileAdsFullScreenContentDelegate
|
|
21
|
+
|
|
22
|
+
#pragma mark -
|
|
23
|
+
#pragma mark GADFullScreenContentDelegate Methods
|
|
24
|
+
|
|
25
|
+
/// Tells the delegate that the ad presented full screen content.
|
|
26
|
+
- (void)adDidPresentFullScreenContent:(nonnull id<GADFullScreenPresentingAd>)ad {
|
|
27
|
+
[RNGoogleMobileAdsCommon sendAdEvent:_sendAdEvent
|
|
28
|
+
requestId:_requestId
|
|
29
|
+
type:GOOGLE_MOBILE_ADS_EVENT_OPENED
|
|
30
|
+
adUnitId:_adUnitId
|
|
31
|
+
error:nil
|
|
32
|
+
data:nil];
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
/// Tells the delegate that the ad failed to present full screen content.
|
|
36
|
+
- (void)ad:(nonnull id<GADFullScreenPresentingAd>)ad
|
|
37
|
+
didFailToPresentFullScreenContentWithError:(nonnull NSError *)error {
|
|
38
|
+
NSDictionary *codeAndMessage = [RNGoogleMobileAdsCommon getCodeAndMessageFromAdError:error];
|
|
39
|
+
[RNGoogleMobileAdsCommon sendAdEvent:_sendAdEvent
|
|
40
|
+
requestId:_requestId
|
|
41
|
+
type:GOOGLE_MOBILE_ADS_EVENT_ERROR
|
|
42
|
+
adUnitId:_adUnitId
|
|
43
|
+
error:codeAndMessage
|
|
44
|
+
data:nil];
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
/// Tells the delegate that the ad dismissed full screen content.
|
|
48
|
+
- (void)adDidDismissFullScreenContent:(nonnull id<GADFullScreenPresentingAd>)ad {
|
|
49
|
+
[RNGoogleMobileAdsCommon sendAdEvent:_sendAdEvent
|
|
50
|
+
requestId:_requestId
|
|
51
|
+
type:GOOGLE_MOBILE_ADS_EVENT_CLOSED
|
|
52
|
+
adUnitId:_adUnitId
|
|
53
|
+
error:nil
|
|
54
|
+
data:nil];
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
@end
|
|
@@ -0,0 +1,25 @@
|
|
|
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
|
+
#import <Foundation/Foundation.h>
|
|
20
|
+
|
|
21
|
+
#import <React/RCTBridgeModule.h>
|
|
22
|
+
|
|
23
|
+
@interface RNGoogleMobileAdsInterstitialModule : NSObject <RCTBridgeModule>
|
|
24
|
+
|
|
25
|
+
@end
|
|
@@ -0,0 +1,124 @@
|
|
|
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
|
+
#import <React/RCTUtils.h>
|
|
20
|
+
|
|
21
|
+
#import "RNGoogleMobileAdsCommon.h"
|
|
22
|
+
#import "RNGoogleMobileAdsFullScreenContentDelegate.h"
|
|
23
|
+
#import "RNGoogleMobileAdsInterstitialModule.h"
|
|
24
|
+
#import "common/RNSharedUtils.h"
|
|
25
|
+
|
|
26
|
+
static __strong NSMutableDictionary *interstitialMap;
|
|
27
|
+
static __strong NSMutableDictionary *interstitialDelegateMap;
|
|
28
|
+
|
|
29
|
+
@implementation RNGoogleMobileAdsInterstitialModule
|
|
30
|
+
#pragma mark -
|
|
31
|
+
#pragma mark Module Setup
|
|
32
|
+
|
|
33
|
+
RCT_EXPORT_MODULE();
|
|
34
|
+
|
|
35
|
+
- (dispatch_queue_t)methodQueue {
|
|
36
|
+
return dispatch_get_main_queue();
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
- (id)init {
|
|
40
|
+
self = [super init];
|
|
41
|
+
static dispatch_once_t onceToken;
|
|
42
|
+
dispatch_once(&onceToken, ^{
|
|
43
|
+
interstitialMap = [[NSMutableDictionary alloc] init];
|
|
44
|
+
interstitialDelegateMap = [[NSMutableDictionary alloc] init];
|
|
45
|
+
});
|
|
46
|
+
return self;
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
+ (BOOL)requiresMainQueueSetup {
|
|
50
|
+
return YES;
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
- (void)dealloc {
|
|
54
|
+
[self invalidate];
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
- (void)invalidate {
|
|
58
|
+
for (NSNumber *id in [interstitialMap allKeys]) {
|
|
59
|
+
[interstitialMap removeObjectForKey:id];
|
|
60
|
+
[interstitialDelegateMap removeObjectForKey:id];
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
#pragma mark -
|
|
65
|
+
#pragma mark Google Mobile Ads Methods
|
|
66
|
+
|
|
67
|
+
RCT_EXPORT_METHOD(interstitialLoad
|
|
68
|
+
: (nonnull NSNumber *)requestId
|
|
69
|
+
: (NSString *)adUnitId
|
|
70
|
+
: (NSDictionary *)adRequestOptions) {
|
|
71
|
+
GADRequest *request = [GADRequest request];
|
|
72
|
+
[GADInterstitialAd loadWithAdUnitID:adUnitId
|
|
73
|
+
request:request
|
|
74
|
+
completionHandler:^(GADInterstitialAd *ad, NSError *error) {
|
|
75
|
+
if (error) {
|
|
76
|
+
NSDictionary *codeAndMessage =
|
|
77
|
+
[RNGoogleMobileAdsCommon getCodeAndMessageFromAdError:error];
|
|
78
|
+
[RNGoogleMobileAdsCommon sendAdEvent:GOOGLE_MOBILE_ADS_EVENT_INTERSTITIAL
|
|
79
|
+
requestId:requestId
|
|
80
|
+
type:GOOGLE_MOBILE_ADS_EVENT_ERROR
|
|
81
|
+
adUnitId:adUnitId
|
|
82
|
+
error:codeAndMessage
|
|
83
|
+
data:nil];
|
|
84
|
+
return;
|
|
85
|
+
}
|
|
86
|
+
GADInterstitialAd *interstitial = ad;
|
|
87
|
+
RNGoogleMobileAdsFullScreenContentDelegate *fullScreenContentDelegate =
|
|
88
|
+
[[RNGoogleMobileAdsFullScreenContentDelegate alloc] init];
|
|
89
|
+
fullScreenContentDelegate.sendAdEvent = GOOGLE_MOBILE_ADS_EVENT_INTERSTITIAL;
|
|
90
|
+
fullScreenContentDelegate.requestId = requestId;
|
|
91
|
+
fullScreenContentDelegate.adUnitId = ad.adUnitID;
|
|
92
|
+
interstitial.fullScreenContentDelegate = fullScreenContentDelegate;
|
|
93
|
+
interstitialMap[requestId] = interstitial;
|
|
94
|
+
interstitialDelegateMap[requestId] = fullScreenContentDelegate;
|
|
95
|
+
[RNGoogleMobileAdsCommon sendAdEvent:GOOGLE_MOBILE_ADS_EVENT_INTERSTITIAL
|
|
96
|
+
requestId:requestId
|
|
97
|
+
type:GOOGLE_MOBILE_ADS_EVENT_LOADED
|
|
98
|
+
adUnitId:ad.adUnitID
|
|
99
|
+
error:nil
|
|
100
|
+
data:nil];
|
|
101
|
+
}];
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
RCT_EXPORT_METHOD(interstitialShow
|
|
105
|
+
: (nonnull NSNumber *)requestId
|
|
106
|
+
: (NSDictionary *)showOptions
|
|
107
|
+
: (RCTPromiseResolveBlock)resolve
|
|
108
|
+
: (RCTPromiseRejectBlock)reject) {
|
|
109
|
+
GADInterstitialAd *interstitial = interstitialMap[requestId];
|
|
110
|
+
if (interstitial) {
|
|
111
|
+
[interstitial
|
|
112
|
+
presentFromRootViewController:RCTSharedApplication().delegate.window.rootViewController];
|
|
113
|
+
resolve([NSNull null]);
|
|
114
|
+
} else {
|
|
115
|
+
[RNSharedUtils
|
|
116
|
+
rejectPromiseWithUserInfo:reject
|
|
117
|
+
userInfo:[@{
|
|
118
|
+
@"code" : @"not-ready",
|
|
119
|
+
@"message" : @"Interstitial ad attempted to show but was not ready.",
|
|
120
|
+
} mutableCopy]];
|
|
121
|
+
}
|
|
122
|
+
}
|
|
123
|
+
|
|
124
|
+
@end
|
|
@@ -0,0 +1,24 @@
|
|
|
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 <Foundation/Foundation.h>
|
|
19
|
+
|
|
20
|
+
#import <React/RCTBridgeModule.h>
|
|
21
|
+
|
|
22
|
+
@interface RNGoogleMobileAdsModule : NSObject <RCTBridgeModule>
|
|
23
|
+
|
|
24
|
+
@end
|
|
@@ -0,0 +1,104 @@
|
|
|
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/GoogleMobileAds.h>
|
|
19
|
+
#import <React/RCTUtils.h>
|
|
20
|
+
|
|
21
|
+
#import "RNGoogleMobileAdsModule.h"
|
|
22
|
+
#import "common/RNSharedUtils.h"
|
|
23
|
+
|
|
24
|
+
@implementation RNGoogleMobileAdsModule
|
|
25
|
+
#pragma mark -
|
|
26
|
+
#pragma mark Module Setup
|
|
27
|
+
|
|
28
|
+
RCT_EXPORT_MODULE();
|
|
29
|
+
|
|
30
|
+
- (dispatch_queue_t)methodQueue {
|
|
31
|
+
return dispatch_get_main_queue();
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
#pragma mark -
|
|
35
|
+
#pragma mark Google Mobile Ads Methods
|
|
36
|
+
|
|
37
|
+
RCT_EXPORT_METHOD(initialize : (RCTPromiseResolveBlock)resolve : (RCTPromiseRejectBlock)reject) {
|
|
38
|
+
[[GADMobileAds sharedInstance]
|
|
39
|
+
startWithCompletionHandler:^(GADInitializationStatus *_Nonnull status) {
|
|
40
|
+
NSDictionary *adapterStatuses = [status adapterStatusesByClassName];
|
|
41
|
+
NSMutableArray *result = [[NSMutableArray alloc] init];
|
|
42
|
+
for (NSString *adapter in adapterStatuses) {
|
|
43
|
+
GADAdapterStatus *adapterStatus = adapterStatuses[adapter];
|
|
44
|
+
NSDictionary *dict = @{
|
|
45
|
+
@"name" : adapter,
|
|
46
|
+
@"state" : @(adapterStatus.state),
|
|
47
|
+
@"description" : adapterStatus.description
|
|
48
|
+
};
|
|
49
|
+
[result addObject:dict];
|
|
50
|
+
}
|
|
51
|
+
resolve(result);
|
|
52
|
+
}];
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
RCT_EXPORT_METHOD(setRequestConfiguration
|
|
56
|
+
: (NSDictionary *)requestConfiguration
|
|
57
|
+
: (RCTPromiseResolveBlock)resolve
|
|
58
|
+
: (RCTPromiseRejectBlock)reject) {
|
|
59
|
+
[self setRequestConfiguration:requestConfiguration];
|
|
60
|
+
resolve([NSNull null]);
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
- (void)setRequestConfiguration:(NSDictionary *)requestConfiguration {
|
|
64
|
+
if (requestConfiguration[@"maxAdContentRating"]) {
|
|
65
|
+
NSString *rating = requestConfiguration[@"maxAdContentRating"];
|
|
66
|
+
if ([rating isEqualToString:@"G"]) {
|
|
67
|
+
GADMobileAds.sharedInstance.requestConfiguration.maxAdContentRating =
|
|
68
|
+
GADMaxAdContentRatingGeneral;
|
|
69
|
+
} else if ([rating isEqualToString:@"PG"]) {
|
|
70
|
+
GADMobileAds.sharedInstance.requestConfiguration.maxAdContentRating =
|
|
71
|
+
GADMaxAdContentRatingParentalGuidance;
|
|
72
|
+
} else if ([rating isEqualToString:@"T"]) {
|
|
73
|
+
GADMobileAds.sharedInstance.requestConfiguration.maxAdContentRating =
|
|
74
|
+
GADMaxAdContentRatingTeen;
|
|
75
|
+
} else if ([rating isEqualToString:@"MA"]) {
|
|
76
|
+
GADMobileAds.sharedInstance.requestConfiguration.maxAdContentRating =
|
|
77
|
+
GADMaxAdContentRatingMatureAudience;
|
|
78
|
+
}
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
if (requestConfiguration[@"tagForChildDirectedTreatment"]) {
|
|
82
|
+
BOOL tag = [requestConfiguration[@"tagForChildDirectedTreatment"] boolValue];
|
|
83
|
+
[GADMobileAds.sharedInstance.requestConfiguration tagForChildDirectedTreatment:tag];
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
if (requestConfiguration[@"tagForUnderAgeOfConsent"]) {
|
|
87
|
+
BOOL tag = [requestConfiguration[@"tagForUnderAgeOfConsent"] boolValue];
|
|
88
|
+
[GADMobileAds.sharedInstance.requestConfiguration tagForUnderAgeOfConsent:tag];
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
if (requestConfiguration[@"testDeviceIdentifiers"]) {
|
|
92
|
+
NSMutableArray *devices = [@[] mutableCopy];
|
|
93
|
+
for (NSString *key in requestConfiguration[@"testDeviceIdentifiers"]) {
|
|
94
|
+
if ([key isEqualToString:@"EMULATOR"]) {
|
|
95
|
+
[devices addObject:GADSimulatorID];
|
|
96
|
+
} else {
|
|
97
|
+
[devices addObject:key];
|
|
98
|
+
}
|
|
99
|
+
}
|
|
100
|
+
GADMobileAds.sharedInstance.requestConfiguration.testDeviceIdentifiers = devices;
|
|
101
|
+
}
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
@end
|
|
@@ -0,0 +1,25 @@
|
|
|
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
|
+
#import <Foundation/Foundation.h>
|
|
20
|
+
|
|
21
|
+
#import <React/RCTBridgeModule.h>
|
|
22
|
+
|
|
23
|
+
@interface RNGoogleMobileAdsRewardedModule : NSObject <RCTBridgeModule>
|
|
24
|
+
|
|
25
|
+
@end
|
|
@@ -0,0 +1,173 @@
|
|
|
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
|
+
#import <React/RCTUtils.h>
|
|
20
|
+
|
|
21
|
+
#import "RNGoogleMobileAdsCommon.h"
|
|
22
|
+
#import "RNGoogleMobileAdsFullScreenContentDelegate.h"
|
|
23
|
+
#import "RNGoogleMobileAdsRewardedModule.h"
|
|
24
|
+
#import "common/RNSharedUtils.h"
|
|
25
|
+
|
|
26
|
+
static __strong NSMutableDictionary *rewardedMap;
|
|
27
|
+
static __strong NSMutableDictionary *rewardedDelegateMap;
|
|
28
|
+
|
|
29
|
+
@implementation RNGoogleMobileAdsRewardedModule
|
|
30
|
+
#pragma mark -
|
|
31
|
+
#pragma mark Module Setup
|
|
32
|
+
|
|
33
|
+
RCT_EXPORT_MODULE();
|
|
34
|
+
|
|
35
|
+
- (dispatch_queue_t)methodQueue {
|
|
36
|
+
return dispatch_get_main_queue();
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
- (id)init {
|
|
40
|
+
self = [super init];
|
|
41
|
+
static dispatch_once_t onceToken;
|
|
42
|
+
dispatch_once(&onceToken, ^{
|
|
43
|
+
rewardedMap = [[NSMutableDictionary alloc] init];
|
|
44
|
+
rewardedDelegateMap = [[NSMutableDictionary alloc] init];
|
|
45
|
+
});
|
|
46
|
+
return self;
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
+ (BOOL)requiresMainQueueSetup {
|
|
50
|
+
return YES;
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
- (void)dealloc {
|
|
54
|
+
[self invalidate];
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
- (void)invalidate {
|
|
58
|
+
for (NSNumber *id in [rewardedMap allKeys]) {
|
|
59
|
+
[rewardedMap removeObjectForKey:id];
|
|
60
|
+
[rewardedDelegateMap removeObjectForKey:id];
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
#pragma mark -
|
|
65
|
+
#pragma mark Google Mobile Ads Methods
|
|
66
|
+
|
|
67
|
+
RCT_EXPORT_METHOD(rewardedLoad
|
|
68
|
+
: (nonnull NSNumber *)requestId
|
|
69
|
+
: (NSString *)adUnitId
|
|
70
|
+
: (NSDictionary *)adRequestOptions) {
|
|
71
|
+
GADRequest *request = [GADRequest request];
|
|
72
|
+
[GADRewardedAd loadWithAdUnitID:adUnitId
|
|
73
|
+
request:request
|
|
74
|
+
completionHandler:^(GADRewardedAd *ad, NSError *error) {
|
|
75
|
+
if (error) {
|
|
76
|
+
NSDictionary *codeAndMessage =
|
|
77
|
+
[RNGoogleMobileAdsCommon getCodeAndMessageFromAdError:error];
|
|
78
|
+
[RNGoogleMobileAdsCommon sendAdEvent:GOOGLE_MOBILE_ADS_EVENT_REWARDED
|
|
79
|
+
requestId:requestId
|
|
80
|
+
type:GOOGLE_MOBILE_ADS_EVENT_ERROR
|
|
81
|
+
adUnitId:adUnitId
|
|
82
|
+
error:codeAndMessage
|
|
83
|
+
data:nil];
|
|
84
|
+
return;
|
|
85
|
+
}
|
|
86
|
+
GADRewardedAd *rewardedAd = ad;
|
|
87
|
+
|
|
88
|
+
NSDictionary *serverSideVerificationOptions =
|
|
89
|
+
[adRequestOptions objectForKey:@"serverSideVerificationOptions"];
|
|
90
|
+
|
|
91
|
+
if (serverSideVerificationOptions != nil) {
|
|
92
|
+
GADServerSideVerificationOptions *options =
|
|
93
|
+
[[GADServerSideVerificationOptions alloc] init];
|
|
94
|
+
|
|
95
|
+
NSString *userId = [serverSideVerificationOptions valueForKey:@"userId"];
|
|
96
|
+
|
|
97
|
+
if (userId != nil) {
|
|
98
|
+
options.userIdentifier = userId;
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
NSString *customData =
|
|
102
|
+
[serverSideVerificationOptions valueForKey:@"customData"];
|
|
103
|
+
|
|
104
|
+
if (customData != nil) {
|
|
105
|
+
options.customRewardString = customData;
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
[rewardedAd setServerSideVerificationOptions:options];
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
RNGoogleMobileAdsFullScreenContentDelegate *fullScreenContentDelegate =
|
|
112
|
+
[[RNGoogleMobileAdsFullScreenContentDelegate alloc] init];
|
|
113
|
+
fullScreenContentDelegate.sendAdEvent = GOOGLE_MOBILE_ADS_EVENT_REWARDED;
|
|
114
|
+
fullScreenContentDelegate.requestId = requestId;
|
|
115
|
+
fullScreenContentDelegate.adUnitId = ad.adUnitID;
|
|
116
|
+
rewardedAd.fullScreenContentDelegate = fullScreenContentDelegate;
|
|
117
|
+
rewardedMap[requestId] = rewardedAd;
|
|
118
|
+
rewardedDelegateMap[requestId] = fullScreenContentDelegate;
|
|
119
|
+
GADAdReward *reward = rewardedAd.adReward;
|
|
120
|
+
NSMutableDictionary *data = [NSMutableDictionary dictionary];
|
|
121
|
+
if (reward.type != nil) {
|
|
122
|
+
[data setValue:reward.type forKey:@"type"];
|
|
123
|
+
}
|
|
124
|
+
if (reward.amount != nil) {
|
|
125
|
+
[data setValue:reward.amount forKey:@"amount"];
|
|
126
|
+
}
|
|
127
|
+
[RNGoogleMobileAdsCommon sendAdEvent:GOOGLE_MOBILE_ADS_EVENT_REWARDED
|
|
128
|
+
requestId:requestId
|
|
129
|
+
type:GOOGLE_MOBILE_ADS_EVENT_REWARDED_LOADED
|
|
130
|
+
adUnitId:ad.adUnitID
|
|
131
|
+
error:nil
|
|
132
|
+
data:data];
|
|
133
|
+
}];
|
|
134
|
+
}
|
|
135
|
+
|
|
136
|
+
RCT_EXPORT_METHOD(rewardedShow
|
|
137
|
+
: (nonnull NSNumber *)requestId
|
|
138
|
+
: (NSString *)adUnitId
|
|
139
|
+
: (NSDictionary *)showOptions
|
|
140
|
+
: (RCTPromiseResolveBlock)resolve
|
|
141
|
+
: (RCTPromiseRejectBlock)reject) {
|
|
142
|
+
GADRewardedAd *rewardedAd = rewardedMap[requestId];
|
|
143
|
+
|
|
144
|
+
if (rewardedAd) {
|
|
145
|
+
[rewardedAd
|
|
146
|
+
presentFromRootViewController:RCTSharedApplication().delegate.window.rootViewController
|
|
147
|
+
userDidEarnRewardHandler:^{
|
|
148
|
+
GADAdReward *reward = rewardedAd.adReward;
|
|
149
|
+
NSMutableDictionary *data = [NSMutableDictionary dictionary];
|
|
150
|
+
if (reward.type != nil) {
|
|
151
|
+
[data setValue:reward.type forKey:@"type"];
|
|
152
|
+
}
|
|
153
|
+
if (reward.amount != nil) {
|
|
154
|
+
[data setValue:reward.amount forKey:@"amount"];
|
|
155
|
+
}
|
|
156
|
+
[RNGoogleMobileAdsCommon sendAdEvent:GOOGLE_MOBILE_ADS_EVENT_REWARDED
|
|
157
|
+
requestId:requestId
|
|
158
|
+
type:GOOGLE_MOBILE_ADS_EVENT_REWARDED_EARNED_REWARD
|
|
159
|
+
adUnitId:rewardedAd.adUnitID
|
|
160
|
+
error:nil
|
|
161
|
+
data:data];
|
|
162
|
+
}];
|
|
163
|
+
} else {
|
|
164
|
+
[RNSharedUtils
|
|
165
|
+
rejectPromiseWithUserInfo:reject
|
|
166
|
+
userInfo:[@{
|
|
167
|
+
@"code" : @"not-ready",
|
|
168
|
+
@"message" : @"Rewarded ad attempted to show but was not ready.",
|
|
169
|
+
} mutableCopy]];
|
|
170
|
+
}
|
|
171
|
+
}
|
|
172
|
+
|
|
173
|
+
@end
|
|
@@ -0,0 +1,24 @@
|
|
|
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 <Foundation/Foundation.h>
|
|
19
|
+
|
|
20
|
+
#import <React/RCTBridgeModule.h>
|
|
21
|
+
|
|
22
|
+
@interface RNAppModule : NSObject <RCTBridgeModule>
|
|
23
|
+
|
|
24
|
+
@end
|