import { EmitterSubscription, NativeEventEmitter, NativeModules, Platform } from 'react-native'; const LINKING_ERROR = `The package 'react-native-unityads' 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 managed workflow\n'; const Unityads = NativeModules.Unityads ? NativeModules.Unityads : new Proxy( {}, { get() { throw new Error(LINKING_ERROR); }, } ); const eventEmitter = new NativeEventEmitter(Unityads); type EventType = 'onInitializationComplete' | 'onInitializationFailed' | 'onUnityAdsShowFailure' | "onUnityAdsShowStart" | "onUnityAdsShowClick" | "onUnityAdsShowComplete" | "onUnityAdsAdLoaded" | "onUnityAdsFailedToLoad"; export const addListener = (type: EventType, handler: (value: any) => void): EmitterSubscription => { return eventEmitter.addListener(type, handler); }; export function initialize({ gameId, testMode }: { gameId: string, testMode: boolean }): Promise { return Unityads.initialize(gameId, testMode); } export function load(placementId: string): Promise { return Unityads.load(placementId); } export function show(placementId: string): Promise { return Unityads.show(placementId); }