@adapty/capacitor 3.17.1 → 4.0.0-beta.2
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.swift +1 -1
- package/README.md +8 -0
- package/android/build.gradle +2 -2
- package/dist/esm/adapty-instance.d.ts +7 -0
- package/dist/esm/adapty-instance.js +8 -0
- package/dist/esm/adapty-instance.js.map +1 -0
- package/dist/esm/adapty.d.ts +112 -59
- package/dist/esm/adapty.js +132 -69
- package/dist/esm/adapty.js.map +1 -1
- package/dist/esm/coders/parse-flow.d.ts +3 -0
- package/dist/esm/coders/parse-flow.js +4 -0
- package/dist/esm/coders/parse-flow.js.map +1 -0
- package/dist/esm/default-configs.js +2 -2
- package/dist/esm/default-configs.js.map +1 -1
- package/dist/esm/index.d.ts +4 -4
- package/dist/esm/index.js +3 -3
- package/dist/esm/index.js.map +1 -1
- package/dist/esm/types/adapty-plugin.d.ts +31 -17
- package/dist/esm/types/adapty-plugin.js.map +1 -1
- package/dist/esm/types/configs.d.ts +12 -14
- package/dist/esm/types/configs.js.map +1 -1
- package/dist/esm/types/flow-events.d.ts +1 -0
- package/dist/esm/types/flow-events.js +2 -0
- package/dist/esm/types/flow-events.js.map +1 -0
- package/dist/esm/types/index.d.ts +2 -2
- package/dist/esm/types/index.js +1 -1
- package/dist/esm/types/index.js.map +1 -1
- package/dist/esm/types/inputs.d.ts +1 -1
- package/dist/esm/types/inputs.js.map +1 -1
- package/dist/esm/ui-builder/base-view-emitter.d.ts +6 -0
- package/dist/esm/ui-builder/base-view-emitter.js +12 -0
- package/dist/esm/ui-builder/base-view-emitter.js.map +1 -1
- package/dist/esm/ui-builder/create-flow-view.d.ts +14 -0
- package/dist/esm/ui-builder/create-flow-view.js +16 -0
- package/dist/esm/ui-builder/create-flow-view.js.map +1 -0
- package/dist/esm/ui-builder/create-onboarding-view.d.ts +2 -0
- package/dist/esm/ui-builder/create-onboarding-view.js +2 -0
- package/dist/esm/ui-builder/create-onboarding-view.js.map +1 -1
- package/dist/esm/ui-builder/{paywall-view-controller.d.ts → flow-view-controller.d.ts} +37 -37
- package/dist/esm/ui-builder/{paywall-view-controller.js → flow-view-controller.js} +54 -51
- package/dist/esm/ui-builder/flow-view-controller.js.map +1 -0
- package/dist/esm/ui-builder/flow-view-emitter.d.ts +38 -0
- package/dist/esm/ui-builder/flow-view-emitter.js +151 -0
- package/dist/esm/ui-builder/flow-view-emitter.js.map +1 -0
- package/dist/esm/ui-builder/index.d.ts +5 -5
- package/dist/esm/ui-builder/index.js +3 -2
- package/dist/esm/ui-builder/index.js.map +1 -1
- package/dist/esm/ui-builder/onboarding-view-controller.d.ts +7 -5
- package/dist/esm/ui-builder/onboarding-view-controller.js +7 -5
- package/dist/esm/ui-builder/onboarding-view-controller.js.map +1 -1
- package/dist/esm/ui-builder/types.d.ts +11 -358
- package/dist/esm/ui-builder/types.js +52 -22
- package/dist/esm/ui-builder/types.js.map +1 -1
- package/dist/esm/version.d.ts +1 -1
- package/dist/esm/version.js +1 -1
- package/dist/esm/version.js.map +1 -1
- package/dist/plugin.cjs.js +903 -679
- package/dist/plugin.cjs.js.map +1 -1
- package/dist/plugin.js +903 -679
- package/dist/plugin.js.map +1 -1
- package/package.json +3 -5
- package/AdaptyCapacitor.podspec +0 -20
- package/dist/esm/coders/parse-paywall.d.ts +0 -3
- package/dist/esm/coders/parse-paywall.js +0 -4
- package/dist/esm/coders/parse-paywall.js.map +0 -1
- package/dist/esm/types/paywall-events.d.ts +0 -1
- package/dist/esm/types/paywall-events.js +0 -2
- package/dist/esm/types/paywall-events.js.map +0 -1
- package/dist/esm/ui-builder/create-paywall-view.d.ts +0 -25
- package/dist/esm/ui-builder/create-paywall-view.js +0 -29
- package/dist/esm/ui-builder/create-paywall-view.js.map +0 -1
- package/dist/esm/ui-builder/paywall-view-controller.js.map +0 -1
- package/dist/esm/ui-builder/paywall-view-emitter.d.ts +0 -16
- package/dist/esm/ui-builder/paywall-view-emitter.js +0 -114
- package/dist/esm/ui-builder/paywall-view-emitter.js.map +0 -1
package/dist/esm/adapty.js
CHANGED
|
@@ -25,7 +25,7 @@ export class Adapty {
|
|
|
25
25
|
this.nonWaitingMethods = [
|
|
26
26
|
'activate',
|
|
27
27
|
'is_activated',
|
|
28
|
-
'
|
|
28
|
+
'get_flow_for_default_audience',
|
|
29
29
|
'get_onboarding_for_default_audience',
|
|
30
30
|
'set_log_level',
|
|
31
31
|
'set_fallback',
|
|
@@ -143,8 +143,6 @@ export class Adapty {
|
|
|
143
143
|
* so background activities can be performed and cache can be updated.
|
|
144
144
|
*
|
|
145
145
|
* @example
|
|
146
|
-
*
|
|
147
|
-
* @example
|
|
148
146
|
* Usage with your user identifier from your system
|
|
149
147
|
* ```typescript
|
|
150
148
|
* await adapty.activate({
|
|
@@ -277,39 +275,37 @@ export class Adapty {
|
|
|
277
275
|
return await this.handleMethodCall(method, JSON.stringify(args), ctx, log, 'AdaptyInstallationStatus');
|
|
278
276
|
}
|
|
279
277
|
/**
|
|
280
|
-
* Fetches the
|
|
278
|
+
* Fetches the flow by the specified placement.
|
|
281
279
|
*
|
|
282
280
|
* @remarks
|
|
283
281
|
* With Adapty, you can remotely configure the products and offers in your app
|
|
284
|
-
* by simply adding them to
|
|
282
|
+
* by simply adding them to flows – no need for hardcoding them.
|
|
285
283
|
* The only thing you hardcode is the placement ID.
|
|
286
|
-
* This flexibility allows you to easily update
|
|
284
|
+
* This flexibility allows you to easily update flows, products, and offers,
|
|
287
285
|
* or run A/B tests, all without the need for a new app release.
|
|
288
286
|
*
|
|
289
|
-
* @param options - The options for fetching the
|
|
287
|
+
* @param options - The options for fetching the flow
|
|
290
288
|
* @param options.placementId - The identifier of the desired placement. This is the value you specified when creating a placement in the Adapty Dashboard.
|
|
291
|
-
* @param options.
|
|
292
|
-
* @
|
|
293
|
-
* @
|
|
294
|
-
* @throws Error if the paywall with the specified ID is not found or if your bundle ID does not match with your Adapty Dashboard setup.
|
|
289
|
+
* @param options.params - Optional. Additional parameters for fetching the flow, including fetch policy and load timeout.
|
|
290
|
+
* @returns A promise that resolves with the requested {@link AdaptyFlow}.
|
|
291
|
+
* @throws Error if the flow with the specified ID is not found or if your bundle ID does not match with your Adapty Dashboard setup.
|
|
295
292
|
*
|
|
296
293
|
* @example
|
|
297
294
|
* ```typescript
|
|
298
295
|
* import { adapty } from '@adapty/capacitor';
|
|
299
296
|
*
|
|
300
297
|
* try {
|
|
301
|
-
* const
|
|
298
|
+
* const flow = await adapty.getFlow({
|
|
302
299
|
* placementId: 'YOUR_PLACEMENT_ID',
|
|
303
|
-
* locale: 'en',
|
|
304
300
|
* });
|
|
305
|
-
* console.log('
|
|
301
|
+
* console.log('Flow fetched successfully');
|
|
306
302
|
* } catch (error) {
|
|
307
|
-
* console.error('Failed to fetch
|
|
303
|
+
* console.error('Failed to fetch flow:', error);
|
|
308
304
|
* }
|
|
309
305
|
* ```
|
|
310
306
|
*/
|
|
311
|
-
async
|
|
312
|
-
const method = '
|
|
307
|
+
async getFlow(options) {
|
|
308
|
+
const method = 'get_flow';
|
|
313
309
|
const optionsWithDefault = mergeOptions(options, this.options[method]);
|
|
314
310
|
const params = optionsWithDefault.params;
|
|
315
311
|
const ctx = new LogContext();
|
|
@@ -319,54 +315,51 @@ export class Adapty {
|
|
|
319
315
|
method,
|
|
320
316
|
placement_id: optionsWithDefault.placementId,
|
|
321
317
|
load_timeout: params.loadTimeoutMs / 1000,
|
|
322
|
-
locale: optionsWithDefault.locale,
|
|
323
318
|
fetch_policy: params.fetchPolicy === 'return_cache_data_if_not_expired_else_load'
|
|
324
319
|
? { type: params.fetchPolicy, max_age: params.maxAgeSeconds }
|
|
325
320
|
: { type: params.fetchPolicy },
|
|
326
321
|
};
|
|
327
322
|
const args = filterUndefined(argsWithUndefined);
|
|
328
|
-
return await this.handleMethodCall(method, JSON.stringify(args), ctx, log, '
|
|
323
|
+
return await this.handleMethodCall(method, JSON.stringify(args), ctx, log, 'AdaptyFlow');
|
|
329
324
|
}
|
|
330
325
|
/**
|
|
331
|
-
* Fetches the
|
|
326
|
+
* Fetches the flow of the specified placement for the **All Users** audience.
|
|
332
327
|
*
|
|
333
328
|
* @remarks
|
|
334
329
|
* With Adapty, you can remotely configure the products and offers in your app
|
|
335
|
-
* by simply adding them to
|
|
330
|
+
* by simply adding them to flows – no need for hardcoding them.
|
|
336
331
|
* The only thing you hardcode is the placement ID.
|
|
337
332
|
*
|
|
338
|
-
* However, it's crucial to understand that the recommended approach is to fetch the
|
|
339
|
-
* through the placement ID by the {@link
|
|
340
|
-
* The `
|
|
333
|
+
* However, it's crucial to understand that the recommended approach is to fetch the flow
|
|
334
|
+
* through the placement ID by the {@link getFlow} method.
|
|
335
|
+
* The `getFlowForDefaultAudience` method should be a last resort due to its significant drawbacks:
|
|
341
336
|
* - Potential backward compatibility issues
|
|
342
|
-
* - Loss of targeting (all users see the same
|
|
337
|
+
* - Loss of targeting (all users see the same flow)
|
|
343
338
|
*
|
|
344
339
|
* See {@link https://docs.adapty.io/docs/capacitor-get-pb-paywalls#get-a-paywall-for-a-default-audience-to-fetch-it-faster | documentation} for more details.
|
|
345
340
|
*
|
|
346
|
-
* @param options - The options for fetching the
|
|
341
|
+
* @param options - The options for fetching the flow
|
|
347
342
|
* @param options.placementId - The identifier of the desired placement.
|
|
348
|
-
* @param options.
|
|
349
|
-
* @
|
|
350
|
-
* @
|
|
351
|
-
* @throws Error if the paywall with the specified ID is not found.
|
|
343
|
+
* @param options.params - Optional. Additional parameters for fetching the flow.
|
|
344
|
+
* @returns A promise that resolves with the requested {@link AdaptyFlow}.
|
|
345
|
+
* @throws Error if the flow with the specified ID is not found.
|
|
352
346
|
*
|
|
353
347
|
* @example
|
|
354
348
|
* ```typescript
|
|
355
349
|
* import { adapty } from '@adapty/capacitor';
|
|
356
350
|
*
|
|
357
351
|
* try {
|
|
358
|
-
* const
|
|
352
|
+
* const flow = await adapty.getFlowForDefaultAudience({
|
|
359
353
|
* placementId: 'YOUR_PLACEMENT_ID',
|
|
360
|
-
* locale: 'en',
|
|
361
354
|
* });
|
|
362
355
|
* } catch (error) {
|
|
363
|
-
* console.error('Failed to fetch
|
|
356
|
+
* console.error('Failed to fetch flow:', error);
|
|
364
357
|
* }
|
|
365
358
|
* ```
|
|
366
359
|
*/
|
|
367
|
-
async
|
|
360
|
+
async getFlowForDefaultAudience(options) {
|
|
368
361
|
var _a;
|
|
369
|
-
const method = '
|
|
362
|
+
const method = 'get_flow_for_default_audience';
|
|
370
363
|
const optionsWithDefault = mergeOptions(options, this.options[method]);
|
|
371
364
|
const params = optionsWithDefault.params;
|
|
372
365
|
const ctx = new LogContext();
|
|
@@ -375,20 +368,19 @@ export class Adapty {
|
|
|
375
368
|
const argsWithUndefined = {
|
|
376
369
|
method,
|
|
377
370
|
placement_id: optionsWithDefault.placementId,
|
|
378
|
-
locale: optionsWithDefault.locale,
|
|
379
371
|
fetch_policy: params.fetchPolicy === 'return_cache_data_if_not_expired_else_load'
|
|
380
372
|
? { type: params.fetchPolicy, max_age: params.maxAgeSeconds }
|
|
381
373
|
: { type: (_a = params.fetchPolicy) !== null && _a !== void 0 ? _a : 'reload_revalidating_cache_data' },
|
|
382
374
|
};
|
|
383
375
|
const args = filterUndefined(argsWithUndefined);
|
|
384
|
-
return await this.handleMethodCall(method, JSON.stringify(args), ctx, log, '
|
|
376
|
+
return await this.handleMethodCall(method, JSON.stringify(args), ctx, log, 'AdaptyFlow');
|
|
385
377
|
}
|
|
386
378
|
/**
|
|
387
|
-
* Fetches a list of products associated with a provided
|
|
379
|
+
* Fetches a list of products associated with a provided flow.
|
|
388
380
|
*
|
|
389
381
|
* @param options - The options object
|
|
390
|
-
* @param options.
|
|
391
|
-
* @returns A promise that resolves with a list of {@link AdaptyPaywallProduct} associated with a provided
|
|
382
|
+
* @param options.flow - A flow to fetch products for. You can get it using {@link getFlow} method.
|
|
383
|
+
* @returns A promise that resolves with a list of {@link AdaptyPaywallProduct} associated with a provided flow.
|
|
392
384
|
* @throws Error if an error occurs while fetching products.
|
|
393
385
|
*
|
|
394
386
|
* @example
|
|
@@ -396,8 +388,8 @@ export class Adapty {
|
|
|
396
388
|
* import { adapty } from '@adapty/capacitor';
|
|
397
389
|
*
|
|
398
390
|
* try {
|
|
399
|
-
* const
|
|
400
|
-
* const products = await adapty.getPaywallProducts({
|
|
391
|
+
* const flow = await adapty.getFlow({ placementId: 'YOUR_PLACEMENT_ID' });
|
|
392
|
+
* const products = await adapty.getPaywallProducts({ flow });
|
|
401
393
|
* console.log('Products:', products);
|
|
402
394
|
* } catch (error) {
|
|
403
395
|
* console.error('Failed to fetch products:', error);
|
|
@@ -409,10 +401,10 @@ export class Adapty {
|
|
|
409
401
|
const ctx = new LogContext();
|
|
410
402
|
const log = ctx.call({ methodName: method });
|
|
411
403
|
log.start(() => ({ options }));
|
|
412
|
-
const
|
|
404
|
+
const coder = coderFactory.createFlowCoder();
|
|
413
405
|
const argsWithUndefined = {
|
|
414
406
|
method,
|
|
415
|
-
|
|
407
|
+
flow: this.encodeWithLogging(coder, options.flow, 'AdaptyFlow', ctx),
|
|
416
408
|
};
|
|
417
409
|
const args = filterUndefined(argsWithUndefined);
|
|
418
410
|
return await this.handleMethodCall(method, JSON.stringify(args), ctx, log, 'Array<AdaptyPaywallProduct>');
|
|
@@ -420,6 +412,8 @@ export class Adapty {
|
|
|
420
412
|
/**
|
|
421
413
|
* Fetches the onboarding by the specified placement.
|
|
422
414
|
*
|
|
415
|
+
* @deprecated Since 4.0.0. Migrate onboardings to the Flow Builder API.
|
|
416
|
+
*
|
|
423
417
|
* @remarks
|
|
424
418
|
* When you create an onboarding with the no-code builder, it's stored as a container with configuration
|
|
425
419
|
* that your app needs to fetch and display. This container manages the entire experience - what content appears,
|
|
@@ -473,6 +467,8 @@ export class Adapty {
|
|
|
473
467
|
/**
|
|
474
468
|
* Fetches the onboarding of the specified placement for the **All Users** audience.
|
|
475
469
|
*
|
|
470
|
+
* @deprecated Since 4.0.0. Migrate onboardings to the Flow Builder API.
|
|
471
|
+
*
|
|
476
472
|
* @remarks
|
|
477
473
|
* It's crucial to understand that the recommended approach is to fetch the onboarding
|
|
478
474
|
* by the {@link getOnboarding} method. The `getOnboardingForDefaultAudience` method
|
|
@@ -606,19 +602,19 @@ export class Adapty {
|
|
|
606
602
|
await this.handleMethodCall(method, JSON.stringify(args), ctx, log);
|
|
607
603
|
}
|
|
608
604
|
/**
|
|
609
|
-
* Logs a
|
|
605
|
+
* Logs a flow view event.
|
|
610
606
|
*
|
|
611
607
|
* @remarks
|
|
612
|
-
* Adapty helps you to measure the performance of the
|
|
613
|
-
* We automatically collect all the metrics related to purchases except for custom
|
|
614
|
-
* This is because only you know when the
|
|
608
|
+
* Adapty helps you to measure the performance of the flows.
|
|
609
|
+
* We automatically collect all the metrics related to purchases except for custom flow views.
|
|
610
|
+
* This is because only you know when the flow was shown to a customer.
|
|
615
611
|
*
|
|
616
|
-
* Whenever you show a
|
|
612
|
+
* Whenever you show a flow to your user,
|
|
617
613
|
* call this function to log the event,
|
|
618
|
-
* and it will be accumulated in the
|
|
614
|
+
* and it will be accumulated in the flow metrics.
|
|
619
615
|
*
|
|
620
616
|
* @param options - The options object
|
|
621
|
-
* @param options.
|
|
617
|
+
* @param options.flow - The flow object that was shown to the user.
|
|
622
618
|
* @returns A promise that resolves when the event is logged.
|
|
623
619
|
* @throws Error if an error occurs while logging the event.
|
|
624
620
|
*
|
|
@@ -626,20 +622,20 @@ export class Adapty {
|
|
|
626
622
|
* ```typescript
|
|
627
623
|
* import { adapty } from '@adapty/capacitor';
|
|
628
624
|
*
|
|
629
|
-
* const
|
|
630
|
-
* // ...after opening the
|
|
631
|
-
* await adapty.
|
|
625
|
+
* const flow = await adapty.getFlow({ placementId: 'YOUR_PLACEMENT_ID' });
|
|
626
|
+
* // ...after opening the flow
|
|
627
|
+
* await adapty.logShowFlow({ flow });
|
|
632
628
|
* ```
|
|
633
629
|
*/
|
|
634
|
-
async
|
|
635
|
-
const method = '
|
|
630
|
+
async logShowFlow(options) {
|
|
631
|
+
const method = 'log_show_flow';
|
|
636
632
|
const ctx = new LogContext();
|
|
637
633
|
const log = ctx.call({ methodName: method });
|
|
638
634
|
log.start(() => ({ options }));
|
|
639
|
-
const
|
|
635
|
+
const coder = coderFactory.createFlowCoder();
|
|
640
636
|
const argsWithUndefined = {
|
|
641
637
|
method,
|
|
642
|
-
|
|
638
|
+
flow: this.encodeWithLogging(coder, options.flow, 'AdaptyFlow', ctx),
|
|
643
639
|
};
|
|
644
640
|
const args = filterUndefined(argsWithUndefined);
|
|
645
641
|
await this.handleMethodCall(method, JSON.stringify(args), ctx, log);
|
|
@@ -648,7 +644,8 @@ export class Adapty {
|
|
|
648
644
|
* Opens a web paywall in the default browser.
|
|
649
645
|
*
|
|
650
646
|
* @param options - The options object
|
|
651
|
-
* @param options.paywallOrProduct - The paywall or product to open as a web paywall.
|
|
647
|
+
* @param options.paywallOrProduct - The flow paywall or product to open as a web paywall.
|
|
648
|
+
* @param options.openIn - Optional. Where to open the web paywall ({@link WebPresentation}).
|
|
652
649
|
* @returns A promise that resolves when the web paywall is opened.
|
|
653
650
|
* @throws Error if an error occurs while opening the web paywall.
|
|
654
651
|
*
|
|
@@ -657,8 +654,8 @@ export class Adapty {
|
|
|
657
654
|
* import { adapty } from '@adapty/capacitor';
|
|
658
655
|
*
|
|
659
656
|
* try {
|
|
660
|
-
* const
|
|
661
|
-
* await adapty.openWebPaywall({ paywallOrProduct:
|
|
657
|
+
* const flow = await adapty.getFlow({ placementId: 'YOUR_PLACEMENT_ID' });
|
|
658
|
+
* await adapty.openWebPaywall({ paywallOrProduct: flow.paywalls[0] });
|
|
662
659
|
* } catch (error) {
|
|
663
660
|
* console.error('Failed to open web paywall:', error);
|
|
664
661
|
* }
|
|
@@ -669,11 +666,11 @@ export class Adapty {
|
|
|
669
666
|
const ctx = new LogContext();
|
|
670
667
|
const log = ctx.call({ methodName: method });
|
|
671
668
|
log.start(() => ({ options }));
|
|
672
|
-
const
|
|
669
|
+
const flowPaywallCoder = coderFactory.createFlowPaywallCoder();
|
|
673
670
|
const productCoder = coderFactory.createPaywallProductCoder();
|
|
674
671
|
const argsWithUndefined = Object.assign(Object.assign({ method }, (this.isPaywallProduct(options.paywallOrProduct)
|
|
675
672
|
? { product: this.encodeWithLogging(productCoder, options.paywallOrProduct, 'AdaptyPaywallProduct', ctx) }
|
|
676
|
-
: { paywall: this.encodeWithLogging(
|
|
673
|
+
: { paywall: this.encodeWithLogging(flowPaywallCoder, options.paywallOrProduct, 'AdaptyFlowPaywall', ctx) })), (options.openIn ? { open_in: options.openIn } : {}));
|
|
677
674
|
const args = filterUndefined(argsWithUndefined);
|
|
678
675
|
await this.handleMethodCall(method, JSON.stringify(args), ctx, log);
|
|
679
676
|
}
|
|
@@ -685,7 +682,7 @@ export class Adapty {
|
|
|
685
682
|
* You can use this URL in a custom web view or a browser.
|
|
686
683
|
*
|
|
687
684
|
* @param options - The options object
|
|
688
|
-
* @param options.paywallOrProduct - The paywall or product to create a URL for.
|
|
685
|
+
* @param options.paywallOrProduct - The flow paywall or product to create a URL for.
|
|
689
686
|
* @returns A promise that resolves with the web paywall URL.
|
|
690
687
|
* @throws Error if an error occurs while creating the URL.
|
|
691
688
|
*
|
|
@@ -694,8 +691,8 @@ export class Adapty {
|
|
|
694
691
|
* import { adapty } from '@adapty/capacitor';
|
|
695
692
|
*
|
|
696
693
|
* try {
|
|
697
|
-
* const
|
|
698
|
-
* const url = await adapty.createWebPaywallUrl({ paywallOrProduct:
|
|
694
|
+
* const flow = await adapty.getFlow({ placementId: 'YOUR_PLACEMENT_ID' });
|
|
695
|
+
* const url = await adapty.createWebPaywallUrl({ paywallOrProduct: flow.paywalls[0] });
|
|
699
696
|
* console.log('Web paywall URL:', url);
|
|
700
697
|
* } catch (error) {
|
|
701
698
|
* console.error('Failed to create web paywall URL:', error);
|
|
@@ -707,14 +704,80 @@ export class Adapty {
|
|
|
707
704
|
const ctx = new LogContext();
|
|
708
705
|
const log = ctx.call({ methodName: method });
|
|
709
706
|
log.start(() => ({ options }));
|
|
710
|
-
const
|
|
707
|
+
const flowPaywallCoder = coderFactory.createFlowPaywallCoder();
|
|
711
708
|
const productCoder = coderFactory.createPaywallProductCoder();
|
|
712
709
|
const argsWithUndefined = Object.assign({ method }, (this.isPaywallProduct(options.paywallOrProduct)
|
|
713
710
|
? { product: this.encodeWithLogging(productCoder, options.paywallOrProduct, 'AdaptyPaywallProduct', ctx) }
|
|
714
|
-
: { paywall: this.encodeWithLogging(
|
|
711
|
+
: { paywall: this.encodeWithLogging(flowPaywallCoder, options.paywallOrProduct, 'AdaptyFlowPaywall', ctx) }));
|
|
715
712
|
const args = filterUndefined(argsWithUndefined);
|
|
716
713
|
return await this.handleMethodCall(method, JSON.stringify(args), ctx, log, 'String');
|
|
717
714
|
}
|
|
715
|
+
/**
|
|
716
|
+
* Opens a URL using the native browser.
|
|
717
|
+
*
|
|
718
|
+
* @remarks
|
|
719
|
+
* Backs the default `onUrlPress` flow handler. Call it directly from a custom
|
|
720
|
+
* `onUrlPress` handler when you want to run your own logic but keep the native
|
|
721
|
+
* open-URL behavior. `openIn`: `browser_out_app` → external browser,
|
|
722
|
+
* `browser_in_app` → in-app browser.
|
|
723
|
+
*
|
|
724
|
+
* @param options - The options object
|
|
725
|
+
* @param options.url - The URL to open.
|
|
726
|
+
* @param options.openIn - Optional. How to present the URL ({@link WebPresentation}). When omitted, the native SDK decides.
|
|
727
|
+
* @returns A promise that resolves when the URL is opened.
|
|
728
|
+
* @throws Error if an error occurs while opening the URL.
|
|
729
|
+
*
|
|
730
|
+
* @example
|
|
731
|
+
* ```typescript
|
|
732
|
+
* import { adapty } from '@adapty/capacitor';
|
|
733
|
+
*
|
|
734
|
+
* try {
|
|
735
|
+
* await adapty.openWebUrl({ url: 'https://example.com' });
|
|
736
|
+
* } catch (error) {
|
|
737
|
+
* console.error('Failed to open URL:', error);
|
|
738
|
+
* }
|
|
739
|
+
* ```
|
|
740
|
+
*/
|
|
741
|
+
async openWebUrl(options) {
|
|
742
|
+
const method = 'adapty_ui_open_url';
|
|
743
|
+
const ctx = new LogContext();
|
|
744
|
+
const log = ctx.call({ methodName: method });
|
|
745
|
+
log.start(() => ({ options }));
|
|
746
|
+
const argsWithUndefined = Object.assign({ method, url: options.url }, (options.openIn ? { open_in: options.openIn } : {}));
|
|
747
|
+
const args = filterUndefined(argsWithUndefined);
|
|
748
|
+
await this.handleMethodCall(method, JSON.stringify(args), ctx, log);
|
|
749
|
+
}
|
|
750
|
+
/**
|
|
751
|
+
* Requests the native app-review prompt.
|
|
752
|
+
*
|
|
753
|
+
* @remarks
|
|
754
|
+
* Uses `SKStoreReviewController` on iOS and In-App Review on Android. Backs the
|
|
755
|
+
* default `onRequestAppReview` flow handler. Call it directly from a custom
|
|
756
|
+
* `onRequestAppReview` handler when you want to run your own logic but keep the
|
|
757
|
+
* native prompt.
|
|
758
|
+
*
|
|
759
|
+
* @returns A promise that resolves when the native call completes.
|
|
760
|
+
* @throws Error if an error occurs while requesting the app review.
|
|
761
|
+
*
|
|
762
|
+
* @example
|
|
763
|
+
* ```typescript
|
|
764
|
+
* import { adapty } from '@adapty/capacitor';
|
|
765
|
+
*
|
|
766
|
+
* try {
|
|
767
|
+
* await adapty.requestAppReview();
|
|
768
|
+
* } catch (error) {
|
|
769
|
+
* console.error('Failed to request app review:', error);
|
|
770
|
+
* }
|
|
771
|
+
* ```
|
|
772
|
+
*/
|
|
773
|
+
async requestAppReview() {
|
|
774
|
+
const method = 'adapty_ui_request_app_review';
|
|
775
|
+
const ctx = new LogContext();
|
|
776
|
+
const log = ctx.call({ methodName: method });
|
|
777
|
+
log.start(() => ({}));
|
|
778
|
+
const args = { method };
|
|
779
|
+
await this.handleMethodCall(method, JSON.stringify(args), ctx, log);
|
|
780
|
+
}
|
|
718
781
|
/**
|
|
719
782
|
* Logs out the current user.
|
|
720
783
|
*
|
|
@@ -841,7 +904,7 @@ export class Adapty {
|
|
|
841
904
|
*
|
|
842
905
|
* @param options - The options object
|
|
843
906
|
* @param options.transactionId - The transaction ID of the purchase.
|
|
844
|
-
* @param options.variationId - Optional. The variation ID from the {@link
|
|
907
|
+
* @param options.variationId - Optional. The variation ID from the {@link AdaptyFlow}.
|
|
845
908
|
* @returns A promise that resolves when the transaction is reported.
|
|
846
909
|
* @throws Error if an error occurs while reporting the transaction.
|
|
847
910
|
*
|