UNPKG

768 BPlain TextView Raw
1import { UnavailabilityError } from '@unimodules/core';
2
3import ExpoAdsAdMob from './ExpoAdsAdMob';
4
5/**
6 * Returns whether the AdMob API is enabled on the current device. This does not check the native configuration.
7 *
8 * @returns Async `boolean`, indicating whether the AdMob API is available on the current device. Currently this resolves `true` on iOS and Android only.
9 */
10export async function isAvailableAsync(): Promise<boolean> {
11 return !!ExpoAdsAdMob.setTestDeviceIDAsync;
12}
13
14export async function setTestDeviceIDAsync(testDeviceID: string | null): Promise<void> {
15 if (!ExpoAdsAdMob.setTestDeviceIDAsync) {
16 throw new UnavailabilityError('expo-ads-admob', 'setTestDeviceIDAsync');
17 }
18 await ExpoAdsAdMob.setTestDeviceIDAsync(testDeviceID || '');
19}