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,158 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Copyright (c) 2016-present Invertase Limited & Contributors
|
|
3
|
+
*
|
|
4
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
5
|
+
* you may not use this library except in compliance with the License.
|
|
6
|
+
* You may obtain a copy of the License at
|
|
7
|
+
*
|
|
8
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
9
|
+
*
|
|
10
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
11
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
12
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
13
|
+
* See the License for the specific language governing permissions and
|
|
14
|
+
* limitations under the License.
|
|
15
|
+
*
|
|
16
|
+
*/
|
|
17
|
+
|
|
18
|
+
#import <React/RCTUtils.h>
|
|
19
|
+
|
|
20
|
+
#import "RNAppModule.h"
|
|
21
|
+
#import "RNJSON.h"
|
|
22
|
+
#import "RNMeta.h"
|
|
23
|
+
#import "RNPreferences.h"
|
|
24
|
+
#import "RNRCTEventEmitter.h"
|
|
25
|
+
#import "RNSharedUtils.h"
|
|
26
|
+
|
|
27
|
+
@implementation RNAppModule
|
|
28
|
+
|
|
29
|
+
#pragma mark -
|
|
30
|
+
#pragma mark Module Setup
|
|
31
|
+
|
|
32
|
+
RCT_EXPORT_MODULE();
|
|
33
|
+
|
|
34
|
+
- (dispatch_queue_t)methodQueue {
|
|
35
|
+
return dispatch_get_main_queue();
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
- (void)setBridge:(RCTBridge *)bridge {
|
|
39
|
+
[RNRCTEventEmitter shared].bridge = bridge;
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
- (RCTBridge *)bridge {
|
|
43
|
+
return [RNRCTEventEmitter shared].bridge;
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
- (id)init {
|
|
47
|
+
return self;
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
- (void)invalidate {
|
|
51
|
+
[[RNRCTEventEmitter shared] invalidate];
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
#pragma mark -
|
|
55
|
+
#pragma mark META Methods
|
|
56
|
+
|
|
57
|
+
RCT_EXPORT_METHOD(metaGetAll
|
|
58
|
+
: (RCTPromiseResolveBlock)resolve rejecter
|
|
59
|
+
: (RCTPromiseRejectBlock)reject) {
|
|
60
|
+
resolve([RNMeta getAll]);
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
#pragma mark -
|
|
64
|
+
#pragma mark JSON Methods
|
|
65
|
+
|
|
66
|
+
RCT_EXPORT_METHOD(jsonGetAll
|
|
67
|
+
: (RCTPromiseResolveBlock)resolve rejecter
|
|
68
|
+
: (RCTPromiseRejectBlock)reject) {
|
|
69
|
+
resolve([[RNJSON shared] getAll]);
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
#pragma mark -
|
|
73
|
+
#pragma mark Preference Methods
|
|
74
|
+
|
|
75
|
+
RCT_EXPORT_METHOD(preferencesSetBool
|
|
76
|
+
: (NSString *)key boolValue
|
|
77
|
+
: (BOOL)boolValue resolver
|
|
78
|
+
: (RCTPromiseResolveBlock)resolve rejecter
|
|
79
|
+
: (RCTPromiseRejectBlock)reject) {
|
|
80
|
+
[[RNPreferences shared] setBooleanValue:key boolValue:boolValue];
|
|
81
|
+
resolve([NSNull null]);
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
RCT_EXPORT_METHOD(preferencesSetString
|
|
85
|
+
: (NSString *)key stringValue
|
|
86
|
+
: (NSString *)stringValue resolver
|
|
87
|
+
: (RCTPromiseResolveBlock)resolve rejecter
|
|
88
|
+
: (RCTPromiseRejectBlock)reject) {
|
|
89
|
+
[[RNPreferences shared] setStringValue:key stringValue:stringValue];
|
|
90
|
+
resolve([NSNull null]);
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
RCT_EXPORT_METHOD(preferencesGetAll
|
|
94
|
+
: (RCTPromiseResolveBlock)resolve rejecter
|
|
95
|
+
: (RCTPromiseRejectBlock)reject) {
|
|
96
|
+
resolve([[RNPreferences shared] getAll]);
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
RCT_EXPORT_METHOD(preferencesClearAll
|
|
100
|
+
: (RCTPromiseResolveBlock)resolve rejecter
|
|
101
|
+
: (RCTPromiseRejectBlock)reject) {
|
|
102
|
+
[[RNPreferences shared] clearAll];
|
|
103
|
+
resolve([NSNull null]);
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
#pragma mark -
|
|
107
|
+
#pragma mark Event Methods
|
|
108
|
+
|
|
109
|
+
RCT_EXPORT_METHOD(eventsNotifyReady : (BOOL)ready) {
|
|
110
|
+
[[RNRCTEventEmitter shared] notifyJsReady:ready];
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
RCT_EXPORT_METHOD(eventsGetListeners
|
|
114
|
+
: (RCTPromiseResolveBlock)resolve rejecter
|
|
115
|
+
: (RCTPromiseRejectBlock)reject) {
|
|
116
|
+
resolve([[RNRCTEventEmitter shared] getListenersDictionary]);
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
RCT_EXPORT_METHOD(eventsPing
|
|
120
|
+
: (NSString *)eventName eventBody
|
|
121
|
+
: (NSDictionary *)eventBody resolver
|
|
122
|
+
: (RCTPromiseResolveBlock)resolve rejecter
|
|
123
|
+
: (RCTPromiseRejectBlock)reject) {
|
|
124
|
+
[[RNRCTEventEmitter shared] sendEventWithName:eventName body:eventBody];
|
|
125
|
+
resolve(eventBody);
|
|
126
|
+
}
|
|
127
|
+
|
|
128
|
+
RCT_EXPORT_METHOD(eventsAddListener : (NSString *)eventName) {
|
|
129
|
+
[[RNRCTEventEmitter shared] addListener:eventName];
|
|
130
|
+
}
|
|
131
|
+
|
|
132
|
+
RCT_EXPORT_METHOD(eventsRemoveListener : (NSString *)eventName all : (BOOL)all) {
|
|
133
|
+
[[RNRCTEventEmitter shared] removeListeners:eventName all:all];
|
|
134
|
+
}
|
|
135
|
+
|
|
136
|
+
#pragma mark -
|
|
137
|
+
#pragma mark Events Unused
|
|
138
|
+
|
|
139
|
+
RCT_EXPORT_METHOD(addListener : (NSString *)eventName) {
|
|
140
|
+
// Keep: Required for RN built in Event Emitter Calls.
|
|
141
|
+
}
|
|
142
|
+
|
|
143
|
+
RCT_EXPORT_METHOD(removeListeners : (NSInteger)count) {
|
|
144
|
+
// Keep: Required for RN built in Event Emitter Calls.
|
|
145
|
+
}
|
|
146
|
+
|
|
147
|
+
- (NSDictionary *)constantsToExport {
|
|
148
|
+
NSMutableDictionary *constants = [NSMutableDictionary new];
|
|
149
|
+
|
|
150
|
+
constants[@"ADMOB_RAW_JSON"] = [[RNJSON shared] getRawJSON];
|
|
151
|
+
|
|
152
|
+
return constants;
|
|
153
|
+
}
|
|
154
|
+
|
|
155
|
+
+ (BOOL)requiresMainQueueSetup {
|
|
156
|
+
return YES;
|
|
157
|
+
}
|
|
158
|
+
@end
|
|
@@ -0,0 +1,34 @@
|
|
|
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
|
+
@interface RNJSON : NSObject
|
|
21
|
+
|
|
22
|
+
- (BOOL)contains:(NSString *)key;
|
|
23
|
+
|
|
24
|
+
- (BOOL)getBooleanValue:(NSString *)key defaultValue:(BOOL)defaultValue;
|
|
25
|
+
|
|
26
|
+
- (NSString *)getStringValue:(NSString *)key defaultValue:(NSString *)defaultValue;
|
|
27
|
+
|
|
28
|
+
- (NSDictionary *)getAll;
|
|
29
|
+
|
|
30
|
+
- (NSString *)getRawJSON;
|
|
31
|
+
|
|
32
|
+
+ (RNJSON *)shared;
|
|
33
|
+
|
|
34
|
+
@end
|
|
@@ -0,0 +1,93 @@
|
|
|
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 "RNJSON.h"
|
|
19
|
+
|
|
20
|
+
@interface RNJSON ()
|
|
21
|
+
@property(nonatomic, strong) NSDictionary *googleMobileAdsJson;
|
|
22
|
+
@end
|
|
23
|
+
|
|
24
|
+
@implementation RNJSON
|
|
25
|
+
|
|
26
|
+
+ (instancetype)shared {
|
|
27
|
+
static dispatch_once_t once;
|
|
28
|
+
static RNJSON *sharedInstance;
|
|
29
|
+
|
|
30
|
+
dispatch_once(&once, ^{
|
|
31
|
+
sharedInstance = [[RNJSON alloc] init];
|
|
32
|
+
NSString *__nullable googleMobileAdsJsonRaw =
|
|
33
|
+
[[NSBundle mainBundle].infoDictionary valueForKey:@"googleMobileAds_json_raw"];
|
|
34
|
+
|
|
35
|
+
if (googleMobileAdsJsonRaw == nil) {
|
|
36
|
+
sharedInstance.googleMobileAdsJson = [NSDictionary dictionary];
|
|
37
|
+
return;
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
NSData *data = [[NSData alloc] initWithBase64EncodedString:googleMobileAdsJsonRaw options:0];
|
|
41
|
+
|
|
42
|
+
if (data == nil) {
|
|
43
|
+
sharedInstance.googleMobileAdsJson = [NSDictionary dictionary];
|
|
44
|
+
return;
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
NSError *jsonError = nil;
|
|
48
|
+
NSDictionary *dictionary = [NSJSONSerialization JSONObjectWithData:data
|
|
49
|
+
options:0
|
|
50
|
+
error:&jsonError];
|
|
51
|
+
if (jsonError != nil) {
|
|
52
|
+
sharedInstance.googleMobileAdsJson = [NSDictionary dictionary];
|
|
53
|
+
return;
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
sharedInstance.googleMobileAdsJson = dictionary;
|
|
57
|
+
});
|
|
58
|
+
|
|
59
|
+
return sharedInstance;
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
- (BOOL)contains:(NSString *)key {
|
|
63
|
+
return [_googleMobileAdsJson valueForKey:key] != nil;
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
- (BOOL)getBooleanValue:(NSString *)key defaultValue:(BOOL)defaultValue {
|
|
67
|
+
if ([_googleMobileAdsJson valueForKey:key] == nil) return defaultValue;
|
|
68
|
+
NSNumber *boolean = [_googleMobileAdsJson valueForKey:key];
|
|
69
|
+
return [boolean boolValue];
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
- (NSString *)getStringValue:(NSString *)key defaultValue:(NSString *)defaultValue {
|
|
73
|
+
if ([_googleMobileAdsJson valueForKey:key] == nil) return defaultValue;
|
|
74
|
+
NSString *string = [_googleMobileAdsJson valueForKey:key];
|
|
75
|
+
return string;
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
- (NSDictionary *)getAll {
|
|
79
|
+
return [[NSDictionary alloc] initWithDictionary:_googleMobileAdsJson copyItems:YES];
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
- (NSString *)getRawJSON {
|
|
83
|
+
NSString *__nullable googleMobileAdsJsonRaw =
|
|
84
|
+
[[NSBundle mainBundle].infoDictionary valueForKey:@"googleMobileAds_json_raw"];
|
|
85
|
+
if (googleMobileAdsJsonRaw == nil) {
|
|
86
|
+
return @"{}";
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
NSData *data = [[NSData alloc] initWithBase64EncodedString:googleMobileAdsJsonRaw options:0];
|
|
90
|
+
return [[NSString alloc] initWithData:data encoding:NSUTF8StringEncoding];
|
|
91
|
+
;
|
|
92
|
+
}
|
|
93
|
+
@end
|
|
@@ -0,0 +1,30 @@
|
|
|
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
|
+
@interface RNMeta : NSObject
|
|
21
|
+
|
|
22
|
+
+ (BOOL)contains:(NSString *)key;
|
|
23
|
+
|
|
24
|
+
+ (BOOL)getBooleanValue:(NSString *)key defaultValue:(BOOL)defaultValue;
|
|
25
|
+
|
|
26
|
+
+ (NSString *)getStringValue:(NSString *)key defaultValue:(NSString *)defaultValue;
|
|
27
|
+
|
|
28
|
+
+ (NSDictionary *)getAll;
|
|
29
|
+
|
|
30
|
+
@end
|
|
@@ -0,0 +1,61 @@
|
|
|
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 "RNMeta.h"
|
|
19
|
+
|
|
20
|
+
@interface RNMeta ()
|
|
21
|
+
@property(nonatomic, strong) NSDictionary *firebaseJson;
|
|
22
|
+
@end
|
|
23
|
+
|
|
24
|
+
NSString *const RNMetaPrefix = @"rn_";
|
|
25
|
+
|
|
26
|
+
@implementation RNMeta
|
|
27
|
+
|
|
28
|
+
+ (BOOL)contains:(NSString *)key {
|
|
29
|
+
id keyValue =
|
|
30
|
+
[[NSBundle mainBundle].infoDictionary valueForKey:[RNMetaPrefix stringByAppendingString:key]];
|
|
31
|
+
return keyValue != nil;
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
+ (BOOL)getBooleanValue:(NSString *)key defaultValue:(BOOL)defaultValue {
|
|
35
|
+
NSNumber *keyValue =
|
|
36
|
+
[[NSBundle mainBundle].infoDictionary valueForKey:[RNMetaPrefix stringByAppendingString:key]];
|
|
37
|
+
if (keyValue == nil) return defaultValue;
|
|
38
|
+
return [keyValue boolValue];
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
+ (NSString *)getStringValue:(NSString *)key defaultValue:(NSString *)defaultValue {
|
|
42
|
+
NSString *keyValue =
|
|
43
|
+
[[NSBundle mainBundle].infoDictionary valueForKey:[RNMetaPrefix stringByAppendingString:key]];
|
|
44
|
+
if (keyValue == nil) return defaultValue;
|
|
45
|
+
return keyValue;
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
+ (NSDictionary *)getAll {
|
|
49
|
+
NSMutableDictionary *allMetaValues = [NSMutableDictionary dictionary];
|
|
50
|
+
|
|
51
|
+
NSArray *keys = [[NSBundle mainBundle].infoDictionary allKeys];
|
|
52
|
+
for (NSString *key in keys) {
|
|
53
|
+
if ([key hasPrefix:RNMetaPrefix]) {
|
|
54
|
+
allMetaValues[key] = [NSBundle mainBundle].infoDictionary[key];
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
return allMetaValues;
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
@end
|
|
@@ -0,0 +1,44 @@
|
|
|
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
|
+
@interface RNPreferences : NSObject
|
|
21
|
+
|
|
22
|
+
- (BOOL)contains:(NSString *)key;
|
|
23
|
+
|
|
24
|
+
- (BOOL)getBooleanValue:(NSString *)key defaultValue:(BOOL)defaultValue;
|
|
25
|
+
|
|
26
|
+
- (void)setBooleanValue:(NSString *)key boolValue:(BOOL)boolValue;
|
|
27
|
+
|
|
28
|
+
- (void)setIntegerValue:(NSString *)key integerValue:(NSInteger *)integerValue;
|
|
29
|
+
|
|
30
|
+
- (void)setStringValue:(NSString *)key stringValue:(NSString *)stringValue;
|
|
31
|
+
|
|
32
|
+
- (NSString *)getStringValue:(NSString *)key defaultValue:(NSString *)defaultValue;
|
|
33
|
+
|
|
34
|
+
- (NSInteger *)getIntegerValue:(NSString *)key defaultValue:(NSInteger *)defaultValue;
|
|
35
|
+
|
|
36
|
+
- (NSDictionary *)getAll;
|
|
37
|
+
|
|
38
|
+
- (void)clearAll;
|
|
39
|
+
|
|
40
|
+
- (void)remove:(NSString *)key;
|
|
41
|
+
|
|
42
|
+
+ (RNPreferences *)shared;
|
|
43
|
+
|
|
44
|
+
@end
|
|
@@ -0,0 +1,94 @@
|
|
|
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 "RNPreferences.h"
|
|
19
|
+
|
|
20
|
+
@interface RNPreferences ()
|
|
21
|
+
@property(nonatomic, strong) NSUserDefaults *userDefaults;
|
|
22
|
+
@end
|
|
23
|
+
|
|
24
|
+
static NSString *const RNDomainIdentifier = @"io.invertase.common";
|
|
25
|
+
|
|
26
|
+
@implementation RNPreferences
|
|
27
|
+
|
|
28
|
+
static RNPreferences *sharedInstance;
|
|
29
|
+
|
|
30
|
+
+ (void)load {
|
|
31
|
+
sharedInstance = [[RNPreferences alloc] init];
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
- (instancetype)init {
|
|
35
|
+
self = [super init];
|
|
36
|
+
|
|
37
|
+
if (self) {
|
|
38
|
+
_userDefaults = [[NSUserDefaults alloc] initWithSuiteName:RNDomainIdentifier];
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
return self;
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
- (BOOL)contains:(NSString *)key {
|
|
45
|
+
return [_userDefaults objectForKey:key] != nil;
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
- (BOOL)getBooleanValue:(NSString *)key defaultValue:(BOOL)defaultValue {
|
|
49
|
+
if ([_userDefaults objectForKey:key] == nil) return defaultValue;
|
|
50
|
+
return [_userDefaults boolForKey:key];
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
- (void)setBooleanValue:(NSString *)key boolValue:(BOOL)boolValue {
|
|
54
|
+
[_userDefaults setBool:boolValue forKey:key];
|
|
55
|
+
[_userDefaults synchronize];
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
- (void)setIntegerValue:(NSString *)key integerValue:(NSInteger *)integerValue {
|
|
59
|
+
[_userDefaults setInteger:(NSInteger)integerValue forKey:key];
|
|
60
|
+
[_userDefaults synchronize];
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
- (NSInteger *)getIntegerValue:(NSString *)key defaultValue:(NSInteger *)defaultValue {
|
|
64
|
+
if ([_userDefaults objectForKey:key] == nil) return defaultValue;
|
|
65
|
+
return (NSInteger *)[_userDefaults integerForKey:key];
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
- (NSString *)getStringValue:(NSString *)key defaultValue:(NSString *)defaultValue {
|
|
69
|
+
if ([_userDefaults objectForKey:key] == nil) return defaultValue;
|
|
70
|
+
return [_userDefaults stringForKey:key];
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
- (void)setStringValue:(NSString *)key stringValue:(NSString *)stringValue {
|
|
74
|
+
[_userDefaults setValue:stringValue forKey:key];
|
|
75
|
+
[_userDefaults synchronize];
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
- (NSDictionary *)getAll {
|
|
79
|
+
return [_userDefaults dictionaryRepresentation];
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
- (void)clearAll {
|
|
83
|
+
[_userDefaults removePersistentDomainForName:RNDomainIdentifier];
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
- (void)remove:(NSString *)key {
|
|
87
|
+
[_userDefaults removeObjectForKey:key];
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
+ (RNPreferences *)shared {
|
|
91
|
+
return sharedInstance;
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
@end
|
|
@@ -0,0 +1,73 @@
|
|
|
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
|
+
#import <React/RCTEventEmitter.h>
|
|
20
|
+
|
|
21
|
+
/**
|
|
22
|
+
* Listena for events and emits them to the JS layer
|
|
23
|
+
*/
|
|
24
|
+
@interface RNRCTEventEmitter : NSObject
|
|
25
|
+
|
|
26
|
+
/**
|
|
27
|
+
* The RCTBridge. Assigned by `RNAppModule`
|
|
28
|
+
*/
|
|
29
|
+
@property(nonatomic, weak) RCTBridge *bridge;
|
|
30
|
+
|
|
31
|
+
/**
|
|
32
|
+
* Returns the shared instance
|
|
33
|
+
*
|
|
34
|
+
* @returns RNRCTEventEmitter.
|
|
35
|
+
*/
|
|
36
|
+
+ (RNRCTEventEmitter *)shared;
|
|
37
|
+
|
|
38
|
+
/**
|
|
39
|
+
* Invalidate
|
|
40
|
+
*/
|
|
41
|
+
- (void)invalidate;
|
|
42
|
+
|
|
43
|
+
/**
|
|
44
|
+
* Add an event listener
|
|
45
|
+
*
|
|
46
|
+
* @param eventName NSString event name.
|
|
47
|
+
*/
|
|
48
|
+
- (void)addListener:(NSString *)eventName;
|
|
49
|
+
|
|
50
|
+
/**
|
|
51
|
+
* Removes event listeners
|
|
52
|
+
*/
|
|
53
|
+
- (void)removeListeners:(NSString *)eventName all:(BOOL)all;
|
|
54
|
+
|
|
55
|
+
/**
|
|
56
|
+
* Send an event to JS with the specified name and body
|
|
57
|
+
*
|
|
58
|
+
*/
|
|
59
|
+
- (void)sendEventWithName:(NSString *)eventName body:(id)body;
|
|
60
|
+
|
|
61
|
+
/**
|
|
62
|
+
* Notify the event emitter that JS has loaded and is ready to receive events.
|
|
63
|
+
*
|
|
64
|
+
*/
|
|
65
|
+
- (void)notifyJsReady:(BOOL)ready;
|
|
66
|
+
|
|
67
|
+
/**
|
|
68
|
+
* Returns a dictionary of all registered events & counts. Mainly for testing.
|
|
69
|
+
*
|
|
70
|
+
* @return NSDictionary
|
|
71
|
+
*/
|
|
72
|
+
- (NSDictionary *)getListenersDictionary;
|
|
73
|
+
@end
|