UNPKG

1.88 kBTypeScriptView Raw
1import { EventEmitter, EventSubscription } from 'fbemitter';
2declare type AdManagerCachePolicy = 'none' | 'icon' | 'image' | 'all';
3declare class NativeAdsManager {
4 /** {@string} with placement id of ads **/
5 placementId: string;
6 /** {@number} of ads to request at once **/
7 adsToRequest: number;
8 /** {@boolean} indicating whether AdsManager is ready to serve ads **/
9 isValid: boolean;
10 /** {@EventEmitter} used for sending out updates **/
11 eventEmitter: EventEmitter;
12 static registerViewsForInteractionAsync(nativeAdViewTag: number, mediaViewTag: number, adIconViewTag: number, clickable: number[]): Promise<any>;
13 static triggerEvent(nativeAdViewTag: number): any;
14 /**
15 * Creates an instance of AdsManager with a given placementId and adsToRequest.
16 * Default number of ads to request is `10`.
17 *
18 * AdsManager will become loading ads immediately
19 */
20 constructor(placementId: string, adsToRequest?: number);
21 /**
22 * Listens for AdManager state changes and updates internal state. When it changes,
23 * callers will be notified of a change
24 */
25 _listenForStateChanges(): void;
26 /**
27 * Used to listening for state changes
28 *
29 * If manager already became valid, it will call the function w/o registering
30 * handler for events
31 */
32 onAdsLoaded(listener: () => void): EventSubscription;
33 onAdsErrored(listener: (error: Error) => void): EventSubscription;
34 /**
35 * Disables auto refreshing for this native ad manager
36 */
37 disableAutoRefresh(): void;
38 /**
39 * Set the native ads manager caching policy. This controls which media from
40 * the native ads are cached before the onAdsLoaded is called.
41 * The default is to not block on caching.
42 */
43 setMediaCachePolicy(cachePolicy: AdManagerCachePolicy): void;
44}
45export default NativeAdsManager;