import { NativeModules, Platform } from 'react-native'; import { BannerSize } from './banner/BannerSize'; import type { ReactNativeTapsell } from '../ReactNativeTapsell'; const LINKING_ERROR = `The package '@react-native-tapsell-mediation/tapsell' doesn't seem to be linked. Make sure: \n\n` + Platform.select({ ios: "- You have run 'pod install'\n", default: '' }) + '- You rebuilt the app after installing the package\n' + '- You are not using Expo Go\n'; const TapsellMediatorModule = NativeModules.RNTapsellMediation ? NativeModules.RNTapsellMediation : new Proxy( {}, { get() { throw new Error(LINKING_ERROR); }, } ); /** @internal */ class RequestCourier implements ReactNativeTapsell.RequestCourier { private static _instance: RequestCourier; public static getInstance(): RequestCourier { if (!RequestCourier._instance) { RequestCourier._instance = new RequestCourier(); } return RequestCourier._instance; } setUserConsent(consent: boolean): Promise { return TapsellMediatorModule.setUserConsent(consent); } requestRewardedAd(zoneId: string): Promise { return TapsellMediatorModule.requestRewardedAd(zoneId); } requestInterstitialAd(zoneId: string): Promise { return TapsellMediatorModule.requestInterstitialAd(zoneId); } requestBannerAd(zoneId: string, bannerSize: BannerSize): Promise { return TapsellMediatorModule.requestBannerAd(zoneId, bannerSize); } requestNativeAd(zoneId: string): Promise { return TapsellMediatorModule.requestNativeAd(zoneId); } requestMultipleNativeAd( zoneId: string, maximumCount: number ): Promise { return TapsellMediatorModule.requestMultipleNativeAd(zoneId, maximumCount); } } /** @internal */ export const RequestCourierInstance = RequestCourier.getInstance();