apps-sdk 1.1.53 → 1.1.54
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/package.json +1 -1
- package/src/libraries/Adapty.js +100 -1
- package/types/index.d.ts +17 -0
package/package.json
CHANGED
package/src/libraries/Adapty.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { adapty } from 'react-native-adapty';
|
|
2
2
|
import * as config from '../../config';
|
|
3
3
|
import {Session} from "./index";
|
|
4
|
-
import {createPaywallView} from "react-native-adapty/dist/ui";
|
|
4
|
+
import {createPaywallView, createOnboardingView} from "react-native-adapty/dist/ui";
|
|
5
5
|
|
|
6
6
|
class Adapty {
|
|
7
7
|
async initialize(apiKey = null) {
|
|
@@ -179,6 +179,105 @@ class Adapty {
|
|
|
179
179
|
console.error('Error setting integration identifier:', error);
|
|
180
180
|
}
|
|
181
181
|
}
|
|
182
|
+
|
|
183
|
+
async getOnboardingForPlacement(placementID, lang) {
|
|
184
|
+
try {
|
|
185
|
+
return await adapty.getOnboarding(placementID, lang);
|
|
186
|
+
} catch (error) {
|
|
187
|
+
return null;
|
|
188
|
+
}
|
|
189
|
+
}
|
|
190
|
+
|
|
191
|
+
async createOnboardingView(onboarding) {
|
|
192
|
+
try {
|
|
193
|
+
return await createOnboardingView(onboarding);
|
|
194
|
+
} catch (error) {
|
|
195
|
+
console.error('Error creating onboarding view:', error);
|
|
196
|
+
return null;
|
|
197
|
+
}
|
|
198
|
+
}
|
|
199
|
+
|
|
200
|
+
async showOnboarding(placementID, lang, eventHandlers = {}) {
|
|
201
|
+
try {
|
|
202
|
+
const onboarding = await this.getOnboardingForPlacement(placementID, lang);
|
|
203
|
+
config.DEBUG_MODE && console.log('Getting onboarding for placement:', placementID, 'and language:', lang, 'onboarding:', onboarding);
|
|
204
|
+
if (onboarding) {
|
|
205
|
+
const onboardingView = await this.createOnboardingView(onboarding);
|
|
206
|
+
onboardingView.registerEventHandlers({
|
|
207
|
+
onAnalytics: eventHandlers.onAnalytics || (() => { }),
|
|
208
|
+
onClose: eventHandlers.onClose || (async (actionId, meta) => { await onboardingView.dismiss(); return true; }),
|
|
209
|
+
onCustom: eventHandlers.onCustom || (() => { }),
|
|
210
|
+
onPaywall: eventHandlers.onPaywall || (() => { }),
|
|
211
|
+
onStateUpdated: eventHandlers.onStateUpdated || (() => { }),
|
|
212
|
+
onFinishedLoading: eventHandlers.onFinishedLoading || (() => { }),
|
|
213
|
+
onError: eventHandlers.onError || (() => { }),
|
|
214
|
+
});
|
|
215
|
+
await onboardingView.present();
|
|
216
|
+
} else {
|
|
217
|
+
console.warn('Error showing onboarding: onboarding not found for placement', placementID, 'and language', lang);
|
|
218
|
+
}
|
|
219
|
+
} catch (error) {
|
|
220
|
+
console.error('Error showing onboarding:', error);
|
|
221
|
+
}
|
|
222
|
+
}
|
|
223
|
+
|
|
224
|
+
async checkOnboardingExists(placementID, lang) {
|
|
225
|
+
const onboarding = await this.getOnboardingForPlacement(placementID, lang);
|
|
226
|
+
return onboarding !== null;
|
|
227
|
+
}
|
|
228
|
+
|
|
229
|
+
async preloadOnboarding(placementID, lang) {
|
|
230
|
+
try {
|
|
231
|
+
const onboarding = await this.getOnboardingForPlacement(placementID, lang);
|
|
232
|
+
if (onboarding) {
|
|
233
|
+
const onboardingView = await this.createOnboardingView(onboarding);
|
|
234
|
+
if (onboardingView) {
|
|
235
|
+
return onboardingView;
|
|
236
|
+
} else {
|
|
237
|
+
console.warn('Error preloading onboarding: onboarding view not created for placement', placementID, 'and language', lang);
|
|
238
|
+
return null;
|
|
239
|
+
}
|
|
240
|
+
} else {
|
|
241
|
+
console.warn('Error preloading onboarding: onboarding not found for placement', placementID, 'and language', lang);
|
|
242
|
+
}
|
|
243
|
+
} catch (error) {
|
|
244
|
+
console.error('Error preloading onboarding:', error);
|
|
245
|
+
}
|
|
246
|
+
}
|
|
247
|
+
|
|
248
|
+
async closeOnboarding() {
|
|
249
|
+
const onboardingView = await adapty.getCurrentOnboardingView();
|
|
250
|
+
try {
|
|
251
|
+
if (onboardingView) {
|
|
252
|
+
onboardingView.dismiss();
|
|
253
|
+
} else {
|
|
254
|
+
console.warn('Error closing onboarding: onboarding view is null');
|
|
255
|
+
}
|
|
256
|
+
} catch (error) {
|
|
257
|
+
console.error('Error closing onboarding:', error);
|
|
258
|
+
}
|
|
259
|
+
}
|
|
260
|
+
|
|
261
|
+
async showOnboardingPreloaded(onboardingView, eventHandlers = {}) {
|
|
262
|
+
try {
|
|
263
|
+
if (onboardingView) {
|
|
264
|
+
onboardingView.registerEventHandlers({
|
|
265
|
+
onAnalytics: eventHandlers.onAnalytics || (() => { }),
|
|
266
|
+
onClose: eventHandlers.onClose || (async (actionId, meta) => { await onboardingView.dismiss(); return true; }),
|
|
267
|
+
onCustom: eventHandlers.onCustom || (() => { }),
|
|
268
|
+
onPaywall: eventHandlers.onPaywall || (() => { }),
|
|
269
|
+
onStateUpdated: eventHandlers.onStateUpdated || (() => { }),
|
|
270
|
+
onFinishedLoading: eventHandlers.onFinishedLoading || (() => { }),
|
|
271
|
+
onError: eventHandlers.onError || (() => { }),
|
|
272
|
+
});
|
|
273
|
+
await onboardingView.present();
|
|
274
|
+
} else {
|
|
275
|
+
console.warn('Error showing preloaded onboarding: onboarding view is null');
|
|
276
|
+
}
|
|
277
|
+
} catch (error) {
|
|
278
|
+
console.error('Error showing preloaded onboarding:', error);
|
|
279
|
+
}
|
|
280
|
+
}
|
|
182
281
|
}
|
|
183
282
|
|
|
184
283
|
export default new Adapty();
|
package/types/index.d.ts
CHANGED
|
@@ -211,6 +211,16 @@ declare module 'apps-sdk' {
|
|
|
211
211
|
onCustomAction?: (action: string, data: any) => void;
|
|
212
212
|
};
|
|
213
213
|
|
|
214
|
+
type OnboardingEventHandlers = {
|
|
215
|
+
onAnalytics?: (event: any, meta: any) => void;
|
|
216
|
+
onClose?: (actionId: string, meta: any) => Promise<boolean> | boolean;
|
|
217
|
+
onCustom?: (actionId: string, meta: any) => void;
|
|
218
|
+
onPaywall?: (actionId: string, meta: any) => void;
|
|
219
|
+
onStateUpdated?: (action: any, meta: any) => void;
|
|
220
|
+
onFinishedLoading?: (meta: any) => void;
|
|
221
|
+
onError?: (error: any) => void;
|
|
222
|
+
};
|
|
223
|
+
|
|
214
224
|
export class Adapty {
|
|
215
225
|
initialize(apiKey: string): Promise<void>;
|
|
216
226
|
getPaywallForPlacement(placementID: string, lang: string): Promise<any>;
|
|
@@ -225,6 +235,13 @@ declare module 'apps-sdk' {
|
|
|
225
235
|
setAdjustIntegrationIdentifier(adjustIntegrationIdentifier: string): Promise<void>;
|
|
226
236
|
setMixpanelIntegrationIdentifier(mixpanelIntegrationIdentifier: string): Promise<void>;
|
|
227
237
|
closePaywall(): Promise<void>;
|
|
238
|
+
getOnboardingForPlacement(placementID: string, lang: string): Promise<any>;
|
|
239
|
+
createOnboardingView(onboarding: any): Promise<any>;
|
|
240
|
+
showOnboarding(placementID: string, lang: string, eventHandlers?: OnboardingEventHandlers): Promise<void>;
|
|
241
|
+
checkOnboardingExists(placementID: string, lang: string): Promise<boolean>;
|
|
242
|
+
preloadOnboarding(placementID: string, lang: string): Promise<any>;
|
|
243
|
+
closeOnboarding(): Promise<void>;
|
|
244
|
+
showOnboardingPreloaded(onboardingView: any, eventHandlers?: OnboardingEventHandlers): Promise<void>;
|
|
228
245
|
}
|
|
229
246
|
|
|
230
247
|
export class TrackingTransparency {
|