react-native-liftoffads 0.0.1
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 +20 -0
- package/NitroLiftoffAds.podspec +26 -0
- package/README.md +61 -0
- package/android/CMakeLists.txt +20 -0
- package/android/build.gradle +132 -0
- package/android/consumer-rules.pro +2 -0
- package/android/fix-prefab.gradle +46 -0
- package/android/gradle.properties +5 -0
- package/android/src/main/AndroidManifest.xml +1 -0
- package/android/src/main/cpp/cpp-adapter.cpp +7 -0
- package/android/src/main/java/com/margelo/nitro/liftoffads/HybridLiftoffAds.kt +121 -0
- package/android/src/main/java/com/margelo/nitro/liftoffads/HybridLiftoffInterstitialAd.kt +96 -0
- package/android/src/main/java/com/margelo/nitro/liftoffads/HybridLiftoffRewardedAd.kt +104 -0
- package/android/src/main/java/com/margelo/nitro/liftoffads/LiftoffAdEventEmitter.kt +51 -0
- package/android/src/main/java/com/margelo/nitro/liftoffads/LiftoffAndroidUtils.kt +54 -0
- package/android/src/main/java/com/margelo/nitro/liftoffads/NitroLiftoffAdsPackage.java +27 -0
- package/ios/HybridLiftoffAds.swift +113 -0
- package/ios/HybridLiftoffInterstitialAd.swift +98 -0
- package/ios/HybridLiftoffRewardedAd.swift +100 -0
- package/ios/LiftoffSupport.swift +106 -0
- package/lib/module/index.js +169 -0
- package/lib/module/index.js.map +1 -0
- package/lib/module/index.test.js +205 -0
- package/lib/module/index.test.js.map +1 -0
- package/lib/module/package.json +1 -0
- package/lib/module/specs/LiftoffAds.nitro.js +4 -0
- package/lib/module/specs/LiftoffAds.nitro.js.map +1 -0
- package/lib/typescript/package.json +1 -0
- package/lib/typescript/src/index.d.ts +72 -0
- package/lib/typescript/src/index.d.ts.map +1 -0
- package/lib/typescript/src/index.test.d.ts +2 -0
- package/lib/typescript/src/index.test.d.ts.map +1 -0
- package/lib/typescript/src/specs/LiftoffAds.nitro.d.ts +46 -0
- package/lib/typescript/src/specs/LiftoffAds.nitro.d.ts.map +1 -0
- package/nitro.json +18 -0
- package/nitrogen/generated/android/NitroLiftoffAds+autolinking.cmake +85 -0
- package/nitrogen/generated/android/NitroLiftoffAds+autolinking.gradle +27 -0
- package/nitrogen/generated/android/NitroLiftoffAdsOnLoad.cpp +50 -0
- package/nitrogen/generated/android/NitroLiftoffAdsOnLoad.hpp +25 -0
- package/nitrogen/generated/android/c++/JFunc_void_std__optional_LiftoffAdEventPayload_.hpp +78 -0
- package/nitrogen/generated/android/c++/JHybridLiftoffAdsSpec.cpp +88 -0
- package/nitrogen/generated/android/c++/JHybridLiftoffAdsSpec.hpp +69 -0
- package/nitrogen/generated/android/c++/JHybridLiftoffInterstitialAdSpec.cpp +89 -0
- package/nitrogen/generated/android/c++/JHybridLiftoffInterstitialAdSpec.hpp +68 -0
- package/nitrogen/generated/android/c++/JHybridLiftoffRewardedAdSpec.cpp +93 -0
- package/nitrogen/generated/android/c++/JHybridLiftoffRewardedAdSpec.hpp +69 -0
- package/nitrogen/generated/android/c++/JLiftoffAdEventPayload.hpp +58 -0
- package/nitrogen/generated/android/c++/JLiftoffAdEventType.hpp +77 -0
- package/nitrogen/generated/android/c++/JLiftoffAdShowOptions.hpp +53 -0
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/liftoffads/Func_void_std__optional_LiftoffAdEventPayload_.kt +81 -0
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/liftoffads/HybridLiftoffAdsSpec.kt +72 -0
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/liftoffads/HybridLiftoffInterstitialAdSpec.kt +73 -0
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/liftoffads/HybridLiftoffRewardedAdSpec.kt +77 -0
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/liftoffads/LiftoffAdEventPayload.kt +32 -0
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/liftoffads/LiftoffAdEventType.kt +27 -0
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/liftoffads/LiftoffAdShowOptions.kt +29 -0
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/liftoffads/NitroLiftoffAdsOnLoad.kt +35 -0
- package/nitrogen/generated/ios/NitroLiftoffAds+autolinking.rb +60 -0
- package/nitrogen/generated/ios/NitroLiftoffAds-Swift-Cxx-Bridge.cpp +90 -0
- package/nitrogen/generated/ios/NitroLiftoffAds-Swift-Cxx-Bridge.hpp +285 -0
- package/nitrogen/generated/ios/NitroLiftoffAds-Swift-Cxx-Umbrella.hpp +66 -0
- package/nitrogen/generated/ios/NitroLiftoffAdsAutolinking.mm +33 -0
- package/nitrogen/generated/ios/NitroLiftoffAdsAutolinking.swift +25 -0
- package/nitrogen/generated/ios/c++/HybridLiftoffAdsSpecSwift.cpp +11 -0
- package/nitrogen/generated/ios/c++/HybridLiftoffAdsSpecSwift.hpp +114 -0
- package/nitrogen/generated/ios/c++/HybridLiftoffInterstitialAdSpecSwift.cpp +11 -0
- package/nitrogen/generated/ios/c++/HybridLiftoffInterstitialAdSpecSwift.hpp +110 -0
- package/nitrogen/generated/ios/c++/HybridLiftoffRewardedAdSpecSwift.cpp +11 -0
- package/nitrogen/generated/ios/c++/HybridLiftoffRewardedAdSpecSwift.hpp +116 -0
- package/nitrogen/generated/ios/swift/Func_void.swift +47 -0
- package/nitrogen/generated/ios/swift/Func_void_std__exception_ptr.swift +47 -0
- package/nitrogen/generated/ios/swift/Func_void_std__optional_LiftoffAdEventPayload_.swift +54 -0
- package/nitrogen/generated/ios/swift/HybridLiftoffAdsSpec.swift +54 -0
- package/nitrogen/generated/ios/swift/HybridLiftoffAdsSpec_cxx.swift +193 -0
- package/nitrogen/generated/ios/swift/HybridLiftoffInterstitialAdSpec.swift +53 -0
- package/nitrogen/generated/ios/swift/HybridLiftoffInterstitialAdSpec_cxx.swift +193 -0
- package/nitrogen/generated/ios/swift/HybridLiftoffRewardedAdSpec.swift +54 -0
- package/nitrogen/generated/ios/swift/HybridLiftoffRewardedAdSpec_cxx.swift +204 -0
- package/nitrogen/generated/ios/swift/LiftoffAdEventPayload.swift +77 -0
- package/nitrogen/generated/ios/swift/LiftoffAdEventType.swift +64 -0
- package/nitrogen/generated/ios/swift/LiftoffAdShowOptions.swift +47 -0
- package/nitrogen/generated/shared/c++/HybridLiftoffAdsSpec.cpp +26 -0
- package/nitrogen/generated/shared/c++/HybridLiftoffAdsSpec.hpp +74 -0
- package/nitrogen/generated/shared/c++/HybridLiftoffInterstitialAdSpec.cpp +25 -0
- package/nitrogen/generated/shared/c++/HybridLiftoffInterstitialAdSpec.hpp +76 -0
- package/nitrogen/generated/shared/c++/HybridLiftoffRewardedAdSpec.cpp +26 -0
- package/nitrogen/generated/shared/c++/HybridLiftoffRewardedAdSpec.hpp +78 -0
- package/nitrogen/generated/shared/c++/LiftoffAdEventPayload.hpp +72 -0
- package/nitrogen/generated/shared/c++/LiftoffAdEventType.hpp +100 -0
- package/nitrogen/generated/shared/c++/LiftoffAdShowOptions.hpp +67 -0
- package/package.json +173 -0
- package/react-native.config.js +8 -0
- package/src/index.test.ts +257 -0
- package/src/index.ts +307 -0
- package/src/specs/LiftoffAds.nitro.ts +67 -0
package/src/index.ts
ADDED
|
@@ -0,0 +1,307 @@
|
|
|
1
|
+
import { NitroModules } from 'react-native-nitro-modules';
|
|
2
|
+
|
|
3
|
+
import type {
|
|
4
|
+
LiftoffAdEventPayload,
|
|
5
|
+
LiftoffAds,
|
|
6
|
+
LiftoffInterstitialAd,
|
|
7
|
+
LiftoffRewardedAd,
|
|
8
|
+
} from './specs/LiftoffAds.nitro';
|
|
9
|
+
|
|
10
|
+
export enum AdEventType {
|
|
11
|
+
LOADED = 'loaded',
|
|
12
|
+
ERROR = 'error',
|
|
13
|
+
OPENED = 'opened',
|
|
14
|
+
PAID = 'paid',
|
|
15
|
+
CLICKED = 'clicked',
|
|
16
|
+
CLOSED = 'closed',
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
export enum RewardedAdEventType {
|
|
20
|
+
LOADED = 'rewarded_loaded',
|
|
21
|
+
EARNED_REWARD = 'rewarded_earned_reward',
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
export type AdShowOptions = {
|
|
25
|
+
immersiveModeEnabled?: boolean;
|
|
26
|
+
};
|
|
27
|
+
|
|
28
|
+
export type AdapterStatus = {
|
|
29
|
+
name: string;
|
|
30
|
+
description: string;
|
|
31
|
+
state: InitializationState;
|
|
32
|
+
};
|
|
33
|
+
|
|
34
|
+
export enum InitializationState {
|
|
35
|
+
AdapterInitializationStateNotReady = 0,
|
|
36
|
+
AdapterInitializationStateReady = 1,
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
type PublicAdEventType = AdEventType | RewardedAdEventType;
|
|
40
|
+
|
|
41
|
+
export type AdEventPayload<T extends PublicAdEventType> =
|
|
42
|
+
T extends AdEventType.ERROR ? Error : undefined;
|
|
43
|
+
|
|
44
|
+
export type AdEventListener<T extends PublicAdEventType> = (
|
|
45
|
+
payload: AdEventPayload<T>
|
|
46
|
+
) => void;
|
|
47
|
+
|
|
48
|
+
export type AdEventsListener<T extends PublicAdEventType> = (event: {
|
|
49
|
+
type: T;
|
|
50
|
+
payload: AdEventPayload<T>;
|
|
51
|
+
}) => void;
|
|
52
|
+
|
|
53
|
+
const nativeAds = NitroModules.createHybridObject<LiftoffAds>('LiftoffAds');
|
|
54
|
+
|
|
55
|
+
function toPublicPayload(
|
|
56
|
+
eventType: PublicAdEventType,
|
|
57
|
+
payload?: LiftoffAdEventPayload
|
|
58
|
+
): Error | undefined {
|
|
59
|
+
if (eventType === AdEventType.ERROR) {
|
|
60
|
+
const error = new Error(
|
|
61
|
+
payload?.errorMessage ?? 'Unknown Liftoff Ads error'
|
|
62
|
+
);
|
|
63
|
+
error.name = 'LiftoffAdsError';
|
|
64
|
+
Object.assign(error, { code: String(payload?.errorCode ?? 'unknown') });
|
|
65
|
+
return error;
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
return undefined;
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
abstract class MobileAd<
|
|
72
|
+
TNative extends LiftoffInterstitialAd | LiftoffRewardedAd,
|
|
73
|
+
TEvent extends PublicAdEventType,
|
|
74
|
+
> {
|
|
75
|
+
private readonly listeners = new Map<TEvent, Set<AdEventListener<TEvent>>>();
|
|
76
|
+
private readonly nativeSubscriptions = new Set<TEvent>();
|
|
77
|
+
|
|
78
|
+
private loadedValue = false;
|
|
79
|
+
private loadCalled = false;
|
|
80
|
+
|
|
81
|
+
protected constructor(
|
|
82
|
+
readonly adUnitId: string,
|
|
83
|
+
protected readonly nativeAd: TNative,
|
|
84
|
+
eventTypes: readonly TEvent[]
|
|
85
|
+
) {
|
|
86
|
+
for (const eventType of eventTypes) {
|
|
87
|
+
this.listeners.set(eventType, new Set());
|
|
88
|
+
this.subscribeNative(eventType);
|
|
89
|
+
}
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
private subscribeNative(eventType: TEvent): void {
|
|
93
|
+
if (this.nativeSubscriptions.has(eventType)) {
|
|
94
|
+
return;
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
this.nativeAd.addAdEventListener(eventType, (payload) => {
|
|
98
|
+
if (
|
|
99
|
+
eventType === AdEventType.LOADED ||
|
|
100
|
+
eventType === RewardedAdEventType.LOADED
|
|
101
|
+
) {
|
|
102
|
+
this.loadedValue = true;
|
|
103
|
+
} else if (
|
|
104
|
+
eventType === AdEventType.CLOSED ||
|
|
105
|
+
eventType === AdEventType.ERROR
|
|
106
|
+
) {
|
|
107
|
+
this.loadedValue = false;
|
|
108
|
+
this.loadCalled = false;
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
const publicPayload = toPublicPayload(eventType, payload);
|
|
112
|
+
for (const listener of this.listeners.get(eventType) ?? []) {
|
|
113
|
+
listener(publicPayload as AdEventPayload<TEvent>);
|
|
114
|
+
}
|
|
115
|
+
});
|
|
116
|
+
this.nativeSubscriptions.add(eventType);
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
get loaded(): boolean {
|
|
120
|
+
return this.loadedValue;
|
|
121
|
+
}
|
|
122
|
+
|
|
123
|
+
load(): void {
|
|
124
|
+
if (this.loadedValue || this.loadCalled) {
|
|
125
|
+
return;
|
|
126
|
+
}
|
|
127
|
+
this.loadCalled = true;
|
|
128
|
+
this.nativeAd.load();
|
|
129
|
+
}
|
|
130
|
+
|
|
131
|
+
show(options?: AdShowOptions): Promise<void> {
|
|
132
|
+
if (!this.loadedValue) {
|
|
133
|
+
throw new Error(
|
|
134
|
+
`${this.constructor.name}.show() The requested ad has not loaded and could not be shown.`
|
|
135
|
+
);
|
|
136
|
+
}
|
|
137
|
+
return this.nativeAd.show(options);
|
|
138
|
+
}
|
|
139
|
+
|
|
140
|
+
protected addListener<T extends TEvent>(
|
|
141
|
+
type: T,
|
|
142
|
+
listener: AdEventListener<T>
|
|
143
|
+
): () => void {
|
|
144
|
+
if (typeof listener !== 'function') {
|
|
145
|
+
throw new Error(
|
|
146
|
+
`${this.constructor.name}.addAdEventListener(_, *) 'listener' expected a function.`
|
|
147
|
+
);
|
|
148
|
+
}
|
|
149
|
+
|
|
150
|
+
const listeners = this.listeners.get(type);
|
|
151
|
+
if (!listeners) {
|
|
152
|
+
throw new Error(
|
|
153
|
+
`${this.constructor.name}.addAdEventListener(*) 'type' expected a valid event type value.`
|
|
154
|
+
);
|
|
155
|
+
}
|
|
156
|
+
|
|
157
|
+
this.subscribeNative(type);
|
|
158
|
+
listeners.add(listener as AdEventListener<TEvent>);
|
|
159
|
+
return () => listeners.delete(listener as AdEventListener<TEvent>);
|
|
160
|
+
}
|
|
161
|
+
|
|
162
|
+
protected addEventsListener<T extends TEvent>(
|
|
163
|
+
listener: AdEventsListener<T>
|
|
164
|
+
): () => void {
|
|
165
|
+
if (typeof listener !== 'function') {
|
|
166
|
+
throw new Error(
|
|
167
|
+
`${this.constructor.name}.addAdEventsListener(*) 'listener' expected a function.`
|
|
168
|
+
);
|
|
169
|
+
}
|
|
170
|
+
|
|
171
|
+
const unsubscribers = [...this.listeners.keys()].map((type) =>
|
|
172
|
+
this.addListener(type, (payload) =>
|
|
173
|
+
listener({ type: type as T, payload: payload as AdEventPayload<T> })
|
|
174
|
+
)
|
|
175
|
+
);
|
|
176
|
+
return () => unsubscribers.forEach((unsubscribe) => unsubscribe());
|
|
177
|
+
}
|
|
178
|
+
|
|
179
|
+
removeAllListeners(): void {
|
|
180
|
+
for (const listeners of this.listeners.values()) {
|
|
181
|
+
listeners.clear();
|
|
182
|
+
}
|
|
183
|
+
this.nativeAd.removeAllListeners();
|
|
184
|
+
this.nativeSubscriptions.clear();
|
|
185
|
+
}
|
|
186
|
+
}
|
|
187
|
+
|
|
188
|
+
const INTERSTITIAL_EVENTS = Object.values(AdEventType) as AdEventType[];
|
|
189
|
+
const REWARDED_EVENTS = [
|
|
190
|
+
AdEventType.ERROR,
|
|
191
|
+
AdEventType.OPENED,
|
|
192
|
+
AdEventType.PAID,
|
|
193
|
+
AdEventType.CLICKED,
|
|
194
|
+
AdEventType.CLOSED,
|
|
195
|
+
RewardedAdEventType.LOADED,
|
|
196
|
+
RewardedAdEventType.EARNED_REWARD,
|
|
197
|
+
] as const;
|
|
198
|
+
|
|
199
|
+
export class InterstitialAd extends MobileAd<
|
|
200
|
+
LiftoffInterstitialAd,
|
|
201
|
+
AdEventType
|
|
202
|
+
> {
|
|
203
|
+
static createForAdRequest(adUnitId: string): InterstitialAd {
|
|
204
|
+
if (typeof adUnitId !== 'string' || adUnitId.length === 0) {
|
|
205
|
+
throw new Error(
|
|
206
|
+
"InterstitialAd.createForAdRequest(*) 'adUnitId' expected a non-empty string value."
|
|
207
|
+
);
|
|
208
|
+
}
|
|
209
|
+
return new InterstitialAd(
|
|
210
|
+
adUnitId,
|
|
211
|
+
nativeAds.createInterstitialAd(adUnitId)
|
|
212
|
+
);
|
|
213
|
+
}
|
|
214
|
+
|
|
215
|
+
private constructor(adUnitId: string, nativeAd: LiftoffInterstitialAd) {
|
|
216
|
+
super(adUnitId, nativeAd, INTERSTITIAL_EVENTS);
|
|
217
|
+
}
|
|
218
|
+
|
|
219
|
+
addAdEventsListener<T extends AdEventType>(
|
|
220
|
+
listener: AdEventsListener<T>
|
|
221
|
+
): () => void {
|
|
222
|
+
return this.addEventsListener(listener);
|
|
223
|
+
}
|
|
224
|
+
|
|
225
|
+
addAdEventListener<T extends AdEventType>(
|
|
226
|
+
type: T,
|
|
227
|
+
listener: AdEventListener<T>
|
|
228
|
+
): () => void {
|
|
229
|
+
return this.addListener(type, listener);
|
|
230
|
+
}
|
|
231
|
+
}
|
|
232
|
+
|
|
233
|
+
type RewardedEventType = AdEventType | RewardedAdEventType;
|
|
234
|
+
|
|
235
|
+
export class RewardedAd extends MobileAd<LiftoffRewardedAd, RewardedEventType> {
|
|
236
|
+
static createForAdRequest(adUnitId: string): RewardedAd {
|
|
237
|
+
if (typeof adUnitId !== 'string' || adUnitId.length === 0) {
|
|
238
|
+
throw new Error(
|
|
239
|
+
"RewardedAd.createForAdRequest(*) 'adUnitId' expected a non-empty string value."
|
|
240
|
+
);
|
|
241
|
+
}
|
|
242
|
+
return new RewardedAd(adUnitId, nativeAds.createRewardedAd(adUnitId));
|
|
243
|
+
}
|
|
244
|
+
|
|
245
|
+
private constructor(adUnitId: string, nativeAd: LiftoffRewardedAd) {
|
|
246
|
+
super(adUnitId, nativeAd, REWARDED_EVENTS);
|
|
247
|
+
}
|
|
248
|
+
|
|
249
|
+
setUserId(userId: string): void {
|
|
250
|
+
this.nativeAd.setUserId(userId);
|
|
251
|
+
}
|
|
252
|
+
|
|
253
|
+
addAdEventsListener<T extends RewardedEventType>(
|
|
254
|
+
listener: AdEventsListener<T>
|
|
255
|
+
): () => void {
|
|
256
|
+
return this.addEventsListener(listener);
|
|
257
|
+
}
|
|
258
|
+
|
|
259
|
+
addAdEventListener<T extends RewardedEventType>(
|
|
260
|
+
type: T,
|
|
261
|
+
listener: AdEventListener<T>
|
|
262
|
+
): () => void {
|
|
263
|
+
if (type === AdEventType.LOADED) {
|
|
264
|
+
throw new Error(
|
|
265
|
+
'RewardedAd.addAdEventListener(*) use RewardedAdEventType.LOADED instead of AdEventType.LOADED.'
|
|
266
|
+
);
|
|
267
|
+
}
|
|
268
|
+
return this.addListener(type, listener);
|
|
269
|
+
}
|
|
270
|
+
}
|
|
271
|
+
|
|
272
|
+
export type MobileAdsModuleInterface = {
|
|
273
|
+
initialize(appId: string): Promise<AdapterStatus[]>;
|
|
274
|
+
setGDPRConsent(optIn: boolean, consentMessageVersion: string): void;
|
|
275
|
+
setCCPAConsent(optIn: boolean): void;
|
|
276
|
+
setCOPPA(isUserCoppa: boolean): void;
|
|
277
|
+
};
|
|
278
|
+
|
|
279
|
+
const mobileAdsInstance: MobileAdsModuleInterface = {
|
|
280
|
+
async initialize(appId: string) {
|
|
281
|
+
await nativeAds.initialize(appId);
|
|
282
|
+
return [
|
|
283
|
+
{
|
|
284
|
+
name: 'LiftoffMonetize',
|
|
285
|
+
description: 'Liftoff Monetize SDK is ready',
|
|
286
|
+
state: InitializationState.AdapterInitializationStateReady,
|
|
287
|
+
},
|
|
288
|
+
];
|
|
289
|
+
},
|
|
290
|
+
setGDPRConsent: (optIn, consentMessageVersion) =>
|
|
291
|
+
nativeAds.setGDPRConsent(optIn, consentMessageVersion),
|
|
292
|
+
setCCPAConsent: (optIn) => nativeAds.setCCPAConsent(optIn),
|
|
293
|
+
setCOPPA: (isUserCoppa) => nativeAds.setCOPPA(isUserCoppa),
|
|
294
|
+
};
|
|
295
|
+
|
|
296
|
+
export const MobileAds = (): MobileAdsModuleInterface => mobileAdsInstance;
|
|
297
|
+
|
|
298
|
+
export default MobileAds;
|
|
299
|
+
|
|
300
|
+
export type {
|
|
301
|
+
LiftoffAdEventPayload,
|
|
302
|
+
LiftoffAdEventType,
|
|
303
|
+
LiftoffAdShowOptions,
|
|
304
|
+
LiftoffAds,
|
|
305
|
+
LiftoffInterstitialAd,
|
|
306
|
+
LiftoffRewardedAd,
|
|
307
|
+
} from './specs/LiftoffAds.nitro';
|
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
import type { HybridObject } from 'react-native-nitro-modules';
|
|
2
|
+
|
|
3
|
+
export type LiftoffAdEventType =
|
|
4
|
+
| 'loaded'
|
|
5
|
+
| 'error'
|
|
6
|
+
| 'opened'
|
|
7
|
+
| 'paid'
|
|
8
|
+
| 'clicked'
|
|
9
|
+
| 'closed'
|
|
10
|
+
| 'rewarded_loaded'
|
|
11
|
+
| 'rewarded_earned_reward';
|
|
12
|
+
|
|
13
|
+
export interface LiftoffAdShowOptions {
|
|
14
|
+
immersiveModeEnabled?: boolean;
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
export interface LiftoffAdEventPayload {
|
|
18
|
+
errorCode?: number;
|
|
19
|
+
errorMessage?: string;
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
export interface LiftoffInterstitialAd extends HybridObject<{
|
|
23
|
+
ios: 'swift';
|
|
24
|
+
android: 'kotlin';
|
|
25
|
+
}> {
|
|
26
|
+
load(): void;
|
|
27
|
+
show(options?: LiftoffAdShowOptions): Promise<void>;
|
|
28
|
+
addAdEventListener(
|
|
29
|
+
eventType: LiftoffAdEventType,
|
|
30
|
+
listener: (payload?: LiftoffAdEventPayload) => void
|
|
31
|
+
): number;
|
|
32
|
+
removeAdEventListener(subscriptionId: number): void;
|
|
33
|
+
removeAllListeners(): void;
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
export interface LiftoffRewardedAd extends HybridObject<{
|
|
37
|
+
ios: 'swift';
|
|
38
|
+
android: 'kotlin';
|
|
39
|
+
}> {
|
|
40
|
+
load(): void;
|
|
41
|
+
/**
|
|
42
|
+
* Tags this ad with a user identifier for server-side verification (SSV)
|
|
43
|
+
* of the reward. Must be called before `show()`.
|
|
44
|
+
*/
|
|
45
|
+
setUserId(userId: string): void;
|
|
46
|
+
show(options?: LiftoffAdShowOptions): Promise<void>;
|
|
47
|
+
addAdEventListener(
|
|
48
|
+
eventType: LiftoffAdEventType,
|
|
49
|
+
listener: (payload?: LiftoffAdEventPayload) => void
|
|
50
|
+
): number;
|
|
51
|
+
removeAdEventListener(subscriptionId: number): void;
|
|
52
|
+
removeAllListeners(): void;
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
export interface LiftoffAds extends HybridObject<{
|
|
56
|
+
ios: 'swift';
|
|
57
|
+
android: 'kotlin';
|
|
58
|
+
}> {
|
|
59
|
+
initialize(appId: string): Promise<void>;
|
|
60
|
+
|
|
61
|
+
setGDPRConsent(optIn: boolean, consentMessageVersion: string): void;
|
|
62
|
+
setCCPAConsent(optIn: boolean): void;
|
|
63
|
+
setCOPPA(isUserCoppa: boolean): void;
|
|
64
|
+
|
|
65
|
+
createInterstitialAd(placementId: string): LiftoffInterstitialAd;
|
|
66
|
+
createRewardedAd(placementId: string): LiftoffRewardedAd;
|
|
67
|
+
}
|