@adapty/capacitor 3.11.1-beta.0 → 3.15.0
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/AdaptyCapacitor.podspec +3 -3
- package/Package.swift +1 -1
- package/README.md +45 -29
- package/android/build.gradle +4 -3
- package/android/src/main/kotlin/com/adapty/plugin/capacitor/AdaptyCapacitorImplementation.kt +2 -0
- package/dist/esm/adapty.d.ts +752 -6
- package/dist/esm/adapty.js +755 -8
- package/dist/esm/adapty.js.map +1 -1
- package/dist/esm/index.d.ts +2 -1
- package/dist/esm/index.js.map +1 -1
- package/dist/esm/shared/coders/adapty-configuration.js +25 -14
- package/dist/esm/shared/coders/adapty-configuration.js.map +1 -1
- package/dist/esm/shared/coders/adapty-identify-params.d.ts +11 -0
- package/dist/esm/shared/coders/adapty-identify-params.js +19 -0
- package/dist/esm/shared/coders/adapty-identify-params.js.map +1 -0
- package/dist/esm/shared/coders/adapty-paywall-product.d.ts +1 -1
- package/dist/esm/shared/coders/adapty-paywall-product.js +12 -0
- package/dist/esm/shared/coders/adapty-paywall-product.js.map +1 -1
- package/dist/esm/shared/coders/adapty-purchase-params.js +0 -8
- package/dist/esm/shared/coders/adapty-purchase-params.js.map +1 -1
- package/dist/esm/shared/coders/adapty-purchase-result.js +18 -2
- package/dist/esm/shared/coders/adapty-purchase-result.js.map +1 -1
- package/dist/esm/shared/coders/adapty-ui-create-onboarding-view-params.d.ts +8 -0
- package/dist/esm/shared/coders/adapty-ui-create-onboarding-view-params.js +10 -0
- package/dist/esm/shared/coders/adapty-ui-create-onboarding-view-params.js.map +1 -0
- package/dist/esm/shared/coders/adapty-ui-create-paywall-view-params.d.ts +18 -0
- package/dist/esm/shared/coders/adapty-ui-create-paywall-view-params.js +142 -0
- package/dist/esm/shared/coders/adapty-ui-create-paywall-view-params.js.map +1 -0
- package/dist/esm/shared/coders/parse-onboarding.d.ts +3 -0
- package/dist/esm/shared/coders/parse-onboarding.js +86 -0
- package/dist/esm/shared/coders/parse-onboarding.js.map +1 -0
- package/dist/esm/shared/coders/parse-paywall.d.ts +4 -0
- package/dist/esm/shared/coders/parse-paywall.js +141 -0
- package/dist/esm/shared/coders/parse-paywall.js.map +1 -0
- package/dist/esm/shared/coders/parse.d.ts +0 -2
- package/dist/esm/shared/coders/parse.js +0 -75
- package/dist/esm/shared/coders/parse.js.map +1 -1
- package/dist/esm/shared/coders/product-reference.js +10 -0
- package/dist/esm/shared/coders/product-reference.js.map +1 -1
- package/dist/esm/shared/coders/utils.d.ts +18 -0
- package/dist/esm/shared/coders/utils.js +50 -0
- package/dist/esm/shared/coders/utils.js.map +1 -0
- package/dist/esm/shared/types/index.d.ts +16 -0
- package/dist/esm/shared/types/index.js +5 -0
- package/dist/esm/shared/types/index.js.map +1 -1
- package/dist/esm/shared/types/inputs.d.ts +47 -14
- package/dist/esm/shared/types/inputs.js.map +1 -1
- package/dist/esm/shared/types/onboarding-events.d.ts +60 -0
- package/dist/esm/shared/types/onboarding-events.js +11 -0
- package/dist/esm/shared/types/onboarding-events.js.map +1 -0
- package/dist/esm/shared/types/paywall-events.d.ts +84 -0
- package/dist/esm/shared/types/paywall-events.js +16 -0
- package/dist/esm/shared/types/paywall-events.js.map +1 -0
- package/dist/esm/shared/utils/platform.d.ts +2 -0
- package/dist/esm/shared/utils/platform.js +5 -0
- package/dist/esm/shared/utils/platform.js.map +1 -0
- package/dist/esm/types/adapty-plugin.d.ts +2 -1
- package/dist/esm/types/adapty-plugin.js.map +1 -1
- package/dist/esm/ui-builder/base-view-emitter.d.ts +14 -20
- package/dist/esm/ui-builder/base-view-emitter.js +95 -73
- package/dist/esm/ui-builder/base-view-emitter.js.map +1 -1
- package/dist/esm/ui-builder/create-onboarding-view.d.ts +32 -0
- package/dist/esm/ui-builder/create-onboarding-view.js +36 -0
- package/dist/esm/ui-builder/create-onboarding-view.js.map +1 -0
- package/dist/esm/ui-builder/create-paywall-view.d.ts +25 -0
- package/dist/esm/ui-builder/create-paywall-view.js +29 -0
- package/dist/esm/ui-builder/create-paywall-view.js.map +1 -0
- package/dist/esm/ui-builder/index.d.ts +6 -37
- package/dist/esm/ui-builder/index.js +4 -41
- package/dist/esm/ui-builder/index.js.map +1 -1
- package/dist/esm/ui-builder/onboarding-view-controller.d.ts +103 -17
- package/dist/esm/ui-builder/onboarding-view-controller.js +112 -22
- package/dist/esm/ui-builder/onboarding-view-controller.js.map +1 -1
- package/dist/esm/ui-builder/onboarding-view-emitter.d.ts +10 -24
- package/dist/esm/ui-builder/onboarding-view-emitter.js +49 -56
- package/dist/esm/ui-builder/onboarding-view-emitter.js.map +1 -1
- package/dist/esm/ui-builder/paywall-view-controller.d.ts +130 -30
- package/dist/esm/ui-builder/paywall-view-controller.js +141 -71
- package/dist/esm/ui-builder/paywall-view-controller.js.map +1 -1
- package/dist/esm/ui-builder/paywall-view-emitter.d.ts +8 -28
- package/dist/esm/ui-builder/paywall-view-emitter.js +86 -118
- package/dist/esm/ui-builder/paywall-view-emitter.js.map +1 -1
- package/dist/esm/ui-builder/types.d.ts +89 -4
- package/dist/esm/ui-builder/types.js +3 -3
- 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 +1896 -556
- package/dist/plugin.cjs.js.map +1 -1
- package/dist/plugin.js +1896 -556
- package/dist/plugin.js.map +1 -1
- package/package.json +2 -2
|
@@ -1,18 +1,24 @@
|
|
|
1
|
-
import { parseOnboardingEvent } from '../shared/coders/parse';
|
|
1
|
+
import { parseOnboardingEvent } from '../shared/coders/parse-onboarding';
|
|
2
|
+
import { OnboardingEventId } from '../shared/types/onboarding-events';
|
|
2
3
|
import { BaseViewEmitter } from './base-view-emitter';
|
|
3
4
|
/**
|
|
4
5
|
* OnboardingViewEmitter manages event handlers for onboarding view events.
|
|
5
6
|
* Each event type can have only one handler - new handlers replace existing ones.
|
|
6
7
|
*/
|
|
7
8
|
export class OnboardingViewEmitter extends BaseViewEmitter {
|
|
8
|
-
getEventConfig(event) {
|
|
9
|
-
return HANDLER_TO_EVENT_CONFIG[event];
|
|
10
|
-
}
|
|
11
9
|
parseEventData(rawEventData, ctx) {
|
|
12
|
-
|
|
10
|
+
const result = parseOnboardingEvent(rawEventData, ctx);
|
|
11
|
+
if (!result) {
|
|
12
|
+
throw new Error('Failed to parse onboarding event');
|
|
13
|
+
}
|
|
14
|
+
return result;
|
|
15
|
+
}
|
|
16
|
+
getNativeEventForHandler(event) {
|
|
17
|
+
return HANDLER_TO_NATIVE_EVENT[event];
|
|
13
18
|
}
|
|
14
|
-
|
|
15
|
-
|
|
19
|
+
getHandlerForNativeEvent(nativeEvent) {
|
|
20
|
+
var _a;
|
|
21
|
+
return (_a = NATIVE_EVENT_RESOLVER[nativeEvent]) !== null && _a !== void 0 ? _a : null;
|
|
16
22
|
}
|
|
17
23
|
extractCallbackArgs(handlerName, eventData) {
|
|
18
24
|
return extractCallbackArgs(handlerName, eventData);
|
|
@@ -21,60 +27,47 @@ export class OnboardingViewEmitter extends BaseViewEmitter {
|
|
|
21
27
|
var _a, _b;
|
|
22
28
|
return (_b = (_a = eventData === null || eventData === void 0 ? void 0 : eventData.view) === null || _a === void 0 ? void 0 : _a.id) !== null && _b !== void 0 ? _b : null;
|
|
23
29
|
}
|
|
24
|
-
shouldCallHandler() {
|
|
25
|
-
// Onboarding events don't use propertyMap filtering
|
|
26
|
-
return true;
|
|
27
|
-
}
|
|
28
30
|
getEmitterName() {
|
|
29
31
|
return 'OnboardingViewEmitter';
|
|
30
32
|
}
|
|
31
33
|
}
|
|
32
|
-
const
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
34
|
+
const HANDLER_TO_NATIVE_EVENT = {
|
|
35
|
+
onError: 'onboarding_did_fail_with_error',
|
|
36
|
+
onAnalytics: 'onboarding_on_analytics_action',
|
|
37
|
+
onFinishedLoading: 'onboarding_did_finish_loading',
|
|
38
|
+
onClose: 'onboarding_on_close_action',
|
|
39
|
+
onCustom: 'onboarding_on_custom_action',
|
|
40
|
+
onPaywall: 'onboarding_on_paywall_action',
|
|
41
|
+
onStateUpdated: 'onboarding_on_state_updated_action',
|
|
40
42
|
};
|
|
41
|
-
const
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
}
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
return [action, meta];
|
|
70
|
-
case 'onFinishedLoading':
|
|
71
|
-
return [meta];
|
|
72
|
-
case 'onAnalytics':
|
|
73
|
-
return [event, meta];
|
|
74
|
-
case 'onError':
|
|
75
|
-
return [eventArg.error];
|
|
76
|
-
default:
|
|
77
|
-
return [];
|
|
43
|
+
const NATIVE_EVENT_RESOLVER = {
|
|
44
|
+
onboarding_did_fail_with_error: 'onError',
|
|
45
|
+
onboarding_on_analytics_action: 'onAnalytics',
|
|
46
|
+
onboarding_did_finish_loading: 'onFinishedLoading',
|
|
47
|
+
onboarding_on_close_action: 'onClose',
|
|
48
|
+
onboarding_on_custom_action: 'onCustom',
|
|
49
|
+
onboarding_on_paywall_action: 'onPaywall',
|
|
50
|
+
onboarding_on_state_updated_action: 'onStateUpdated',
|
|
51
|
+
};
|
|
52
|
+
function extractCallbackArgs(_handlerName, event) {
|
|
53
|
+
switch (event.id) {
|
|
54
|
+
case OnboardingEventId.Close:
|
|
55
|
+
case OnboardingEventId.Custom:
|
|
56
|
+
case OnboardingEventId.Paywall:
|
|
57
|
+
return [event.actionId, event.meta];
|
|
58
|
+
case OnboardingEventId.StateUpdated:
|
|
59
|
+
return [event.action, event.meta];
|
|
60
|
+
case OnboardingEventId.FinishedLoading:
|
|
61
|
+
return [event.meta];
|
|
62
|
+
case OnboardingEventId.Analytics:
|
|
63
|
+
return [
|
|
64
|
+
Object.assign(Object.assign({}, event.event), {
|
|
65
|
+
// Add backward compatibility: populate element_id from elementId
|
|
66
|
+
element_id: event.event.elementId }),
|
|
67
|
+
event.meta,
|
|
68
|
+
];
|
|
69
|
+
case OnboardingEventId.Error:
|
|
70
|
+
return [event.error];
|
|
78
71
|
}
|
|
79
72
|
}
|
|
80
73
|
//# sourceMappingURL=onboarding-view-emitter.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"onboarding-view-emitter.js","sourceRoot":"","sources":["../../../src/ui-builder/onboarding-view-emitter.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,oBAAoB,EAAE,MAAM,
|
|
1
|
+
{"version":3,"file":"onboarding-view-emitter.js","sourceRoot":"","sources":["../../../src/ui-builder/onboarding-view-emitter.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,oBAAoB,EAAE,MAAM,mCAAmC,CAAC;AAEzE,OAAO,EAAE,iBAAiB,EAAE,MAAM,mCAAmC,CAAC;AAGtE,OAAO,EAAE,eAAe,EAAE,MAAM,qBAAqB,CAAC;AAMtD;;;GAGG;AACH,MAAM,OAAO,qBAAsB,SAAQ,eAI1C;IACW,cAAc,CAAC,YAAoB,EAAE,GAAe;QAC5D,MAAM,MAAM,GAAG,oBAAoB,CAAC,YAAY,EAAE,GAAG,CAAC,CAAC;QACvD,IAAI,CAAC,MAAM,EAAE;YACX,MAAM,IAAI,KAAK,CAAC,kCAAkC,CAAC,CAAC;SACrD;QACD,OAAO,MAAM,CAAC;IAChB,CAAC;IAES,wBAAwB,CAAC,KAAoC;QACrE,OAAO,uBAAuB,CAAC,KAAkB,CAAC,CAAC;IACrD,CAAC;IAES,wBAAwB,CAAC,WAAkC;;QACnE,OAAO,MAAA,qBAAqB,CAAC,WAAW,CAAC,mCAAI,IAAI,CAAC;IACpD,CAAC;IAES,mBAAmB,CAC3B,WAA0C,EAC1C,SAAgC;QAEhC,OAAO,mBAAmB,CAAC,WAAwB,EAAE,SAAS,CAAC,CAAC;IAClE,CAAC;IAES,cAAc,CAAC,SAAgC;;QACvD,OAAO,MAAA,MAAA,SAAS,aAAT,SAAS,uBAAT,SAAS,CAAE,IAAI,0CAAE,EAAE,mCAAI,IAAI,CAAC;IACrC,CAAC;IAES,cAAc;QACtB,OAAO,uBAAuB,CAAC;IACjC,CAAC;CACF;AAED,MAAM,uBAAuB,GAA6C;IACxE,OAAO,EAAE,gCAAgC;IACzC,WAAW,EAAE,gCAAgC;IAC7C,iBAAiB,EAAE,+BAA+B;IAClD,OAAO,EAAE,4BAA4B;IACrC,QAAQ,EAAE,6BAA6B;IACvC,SAAS,EAAE,8BAA8B;IACzC,cAAc,EAAE,oCAAoC;CACrD,CAAC;AAEF,MAAM,qBAAqB,GAA6C;IACtE,8BAA8B,EAAE,SAAS;IACzC,8BAA8B,EAAE,aAAa;IAC7C,6BAA6B,EAAE,mBAAmB;IAClD,0BAA0B,EAAE,SAAS;IACrC,2BAA2B,EAAE,UAAU;IACvC,4BAA4B,EAAE,WAAW;IACzC,kCAAkC,EAAE,gBAAgB;CACrD,CAAC;AAIF,SAAS,mBAAmB,CAC1B,YAAe,EACf,KAA4B;IAE5B,QAAQ,KAAK,CAAC,EAAE,EAAE;QAChB,KAAK,iBAAiB,CAAC,KAAK,CAAC;QAC7B,KAAK,iBAAiB,CAAC,MAAM,CAAC;QAC9B,KAAK,iBAAiB,CAAC,OAAO;YAC5B,OAAO,CAAC,KAAK,CAAC,QAAQ,EAAE,KAAK,CAAC,IAAI,CAAqB,CAAC;QAE1D,KAAK,iBAAiB,CAAC,YAAY;YACjC,OAAO,CAAC,KAAK,CAAC,MAAM,EAAE,KAAK,CAAC,IAAI,CAAqB,CAAC;QAExD,KAAK,iBAAiB,CAAC,eAAe;YACpC,OAAO,CAAC,KAAK,CAAC,IAAI,CAAqB,CAAC;QAE1C,KAAK,iBAAiB,CAAC,SAAS;YAC9B,OAAO;gDAEA,KAAK,CAAC,KAAK;oBACd,iEAAiE;oBACjE,UAAU,EAAE,KAAK,CAAC,KAAK,CAAC,SAAS;gBAEnC,KAAK,CAAC,IAAI;aACS,CAAC;QAExB,KAAK,iBAAiB,CAAC,KAAK;YAC1B,OAAO,CAAC,KAAK,CAAC,KAAK,CAAqB,CAAC;KAC5C;AACH,CAAC","sourcesContent":["import { parseOnboardingEvent } from '../shared/coders/parse-onboarding';\nimport type { LogContext } from '../shared/logger';\nimport { OnboardingEventId } from '../shared/types/onboarding-events';\nimport type { OnboardingEventIdType, ParsedOnboardingEvent } from '../shared/types/onboarding-events';\n\nimport { BaseViewEmitter } from './base-view-emitter';\nimport type { OnboardingEventHandlers } from './types';\n\ntype EventName = keyof OnboardingEventHandlers;\ntype OnboardingNativeEvent = OnboardingEventIdType;\n\n/**\n * OnboardingViewEmitter manages event handlers for onboarding view events.\n * Each event type can have only one handler - new handlers replace existing ones.\n */\nexport class OnboardingViewEmitter extends BaseViewEmitter<\n OnboardingEventHandlers,\n ParsedOnboardingEvent,\n OnboardingNativeEvent\n> {\n protected parseEventData(rawEventData: string, ctx: LogContext): ParsedOnboardingEvent {\n const result = parseOnboardingEvent(rawEventData, ctx);\n if (!result) {\n throw new Error('Failed to parse onboarding event');\n }\n return result;\n }\n\n protected getNativeEventForHandler(event: keyof OnboardingEventHandlers): OnboardingNativeEvent | null {\n return HANDLER_TO_NATIVE_EVENT[event as EventName];\n }\n\n protected getHandlerForNativeEvent(nativeEvent: OnboardingNativeEvent): keyof OnboardingEventHandlers | null {\n return NATIVE_EVENT_RESOLVER[nativeEvent] ?? null;\n }\n\n protected extractCallbackArgs(\n handlerName: keyof OnboardingEventHandlers,\n eventData: ParsedOnboardingEvent,\n ): unknown[] {\n return extractCallbackArgs(handlerName as EventName, eventData);\n }\n\n protected getEventViewId(eventData: ParsedOnboardingEvent): string | null {\n return eventData?.view?.id ?? null;\n }\n\n protected getEmitterName(): string {\n return 'OnboardingViewEmitter';\n }\n}\n\nconst HANDLER_TO_NATIVE_EVENT: Record<EventName, OnboardingNativeEvent> = {\n onError: 'onboarding_did_fail_with_error',\n onAnalytics: 'onboarding_on_analytics_action',\n onFinishedLoading: 'onboarding_did_finish_loading',\n onClose: 'onboarding_on_close_action',\n onCustom: 'onboarding_on_custom_action',\n onPaywall: 'onboarding_on_paywall_action',\n onStateUpdated: 'onboarding_on_state_updated_action',\n};\n\nconst NATIVE_EVENT_RESOLVER: Record<OnboardingNativeEvent, EventName> = {\n onboarding_did_fail_with_error: 'onError',\n onboarding_on_analytics_action: 'onAnalytics',\n onboarding_did_finish_loading: 'onFinishedLoading',\n onboarding_on_close_action: 'onClose',\n onboarding_on_custom_action: 'onCustom',\n onboarding_on_paywall_action: 'onPaywall',\n onboarding_on_state_updated_action: 'onStateUpdated',\n};\n\ntype ExtractedArgs<T extends keyof OnboardingEventHandlers> = Parameters<OnboardingEventHandlers[T]>;\n\nfunction extractCallbackArgs<T extends keyof OnboardingEventHandlers>(\n _handlerName: T,\n event: ParsedOnboardingEvent,\n): ExtractedArgs<T> {\n switch (event.id) {\n case OnboardingEventId.Close:\n case OnboardingEventId.Custom:\n case OnboardingEventId.Paywall:\n return [event.actionId, event.meta] as ExtractedArgs<T>;\n\n case OnboardingEventId.StateUpdated:\n return [event.action, event.meta] as ExtractedArgs<T>;\n\n case OnboardingEventId.FinishedLoading:\n return [event.meta] as ExtractedArgs<T>;\n\n case OnboardingEventId.Analytics:\n return [\n {\n ...event.event,\n // Add backward compatibility: populate element_id from elementId\n element_id: event.event.elementId,\n },\n event.meta,\n ] as ExtractedArgs<T>;\n\n case OnboardingEventId.Error:\n return [event.error] as ExtractedArgs<T>;\n }\n}\n"]}
|
|
@@ -1,8 +1,14 @@
|
|
|
1
1
|
import type { Adapty } from '../adapty';
|
|
2
2
|
import type { AdaptyPaywall } from '../shared/types';
|
|
3
|
-
import type { CreatePaywallViewParamsInput, AdaptyUiDialogConfig, AdaptyUiDialogActionType, EventHandlers } from './types';
|
|
3
|
+
import type { CreatePaywallViewParamsInput, AdaptyUiDialogConfig, AdaptyUiDialogActionType, EventHandlers, AdaptyIOSPresentationStyle } from './types';
|
|
4
4
|
/**
|
|
5
|
-
*
|
|
5
|
+
* Controller for managing paywall views.
|
|
6
|
+
*
|
|
7
|
+
* @remarks
|
|
8
|
+
* This class provides methods to present, dismiss, and handle events for paywall views
|
|
9
|
+
* created with the Paywall Builder. Create instances using the {@link createPaywallView} function
|
|
10
|
+
* rather than directly constructing this class.
|
|
11
|
+
*
|
|
6
12
|
* @public
|
|
7
13
|
*/
|
|
8
14
|
export declare class PaywallViewController {
|
|
@@ -25,66 +31,160 @@ export declare class PaywallViewController {
|
|
|
25
31
|
*/
|
|
26
32
|
private constructor();
|
|
27
33
|
/**
|
|
28
|
-
* Presents
|
|
34
|
+
* Presents the paywall view as a modal screen.
|
|
29
35
|
*
|
|
30
36
|
* @remarks
|
|
31
|
-
* Calling `present`
|
|
32
|
-
*
|
|
37
|
+
* Calling `present` on an already visible paywall view will result in an error.
|
|
38
|
+
* The paywall will be displayed with the configured presentation style on iOS.
|
|
39
|
+
* On Android, the paywall is always presented as a full-screen activity.
|
|
33
40
|
*
|
|
34
|
-
* @
|
|
41
|
+
* @param options - Optional presentation options
|
|
42
|
+
* @param options.iosPresentationStyle - iOS presentation style. Available options: `'full_screen'` (default) or `'page_sheet'`. Only affects iOS platform.
|
|
43
|
+
* @returns A promise that resolves when the paywall is presented.
|
|
44
|
+
* @throws {@link AdaptyError} if the view reference is invalid or the view is already presented.
|
|
45
|
+
*
|
|
46
|
+
* @example
|
|
47
|
+
* Present with default full-screen style
|
|
48
|
+
* ```typescript
|
|
49
|
+
* import { adapty, createPaywallView } from '@adapty/capacitor';
|
|
50
|
+
*
|
|
51
|
+
* const paywall = await adapty.getPaywall({ placementId: 'YOUR_PLACEMENT_ID' });
|
|
52
|
+
* const view = await createPaywallView(paywall);
|
|
53
|
+
* await view.present();
|
|
54
|
+
* ```
|
|
55
|
+
*
|
|
56
|
+
* @example
|
|
57
|
+
* Present with page sheet style on iOS
|
|
58
|
+
* ```typescript
|
|
59
|
+
* await view.present({ iosPresentationStyle: 'page_sheet' });
|
|
60
|
+
* ```
|
|
35
61
|
*/
|
|
36
|
-
present(
|
|
62
|
+
present(options?: {
|
|
63
|
+
iosPresentationStyle?: AdaptyIOSPresentationStyle;
|
|
64
|
+
}): Promise<void>;
|
|
37
65
|
/**
|
|
38
|
-
* Dismisses
|
|
66
|
+
* Dismisses the paywall view.
|
|
67
|
+
*
|
|
68
|
+
* @remarks
|
|
69
|
+
* This method closes the paywall and cleans up associated resources.
|
|
70
|
+
* After dismissing, the view controller instance cannot be reused.
|
|
39
71
|
*
|
|
40
|
-
* @
|
|
72
|
+
* @returns A promise that resolves when the paywall is dismissed.
|
|
73
|
+
* @throws {@link AdaptyError} if the view reference is invalid.
|
|
74
|
+
*
|
|
75
|
+
* @example
|
|
76
|
+
* ```typescript
|
|
77
|
+
* import { createPaywallView } from '@adapty/capacitor';
|
|
78
|
+
*
|
|
79
|
+
* const view = await createPaywallView(paywall);
|
|
80
|
+
* await view.present();
|
|
81
|
+
* // ... later
|
|
82
|
+
* await view.dismiss();
|
|
83
|
+
* ```
|
|
41
84
|
*/
|
|
42
85
|
dismiss(): Promise<void>;
|
|
43
86
|
/**
|
|
44
|
-
*
|
|
45
|
-
*
|
|
46
|
-
* @param {AdaptyUiDialogConfig} config - A config for showing the dialog.
|
|
87
|
+
* Displays a dialog to the user.
|
|
47
88
|
*
|
|
48
89
|
* @remarks
|
|
49
|
-
*
|
|
50
|
-
*
|
|
90
|
+
* Use this method to show custom dialogs within the paywall flow.
|
|
91
|
+
* If you provide two actions in the config, the primary action should cancel the operation
|
|
92
|
+
* and leave things unchanged, while the secondary action should confirm the operation.
|
|
51
93
|
*
|
|
52
|
-
* @
|
|
94
|
+
* @param config - Configuration for the dialog.
|
|
95
|
+
* @param config.title - The dialog title.
|
|
96
|
+
* @param config.content - The dialog message content.
|
|
97
|
+
* @param config.primaryActionTitle - The title for the primary (default) action button.
|
|
98
|
+
* @param config.secondaryActionTitle - Optional. The title for the secondary action button.
|
|
99
|
+
* @returns A promise that resolves to the action type that the user selected: `'primary'` or `'secondary'`.
|
|
100
|
+
* @throws {@link AdaptyError} if the view reference is invalid.
|
|
53
101
|
*
|
|
54
|
-
* @
|
|
102
|
+
* @example
|
|
103
|
+
* Show confirmation dialog
|
|
104
|
+
* ```typescript
|
|
105
|
+
* const action = await view.showDialog({
|
|
106
|
+
* title: 'Confirm Purchase',
|
|
107
|
+
* content: 'Are you sure you want to proceed with this purchase?',
|
|
108
|
+
* primaryActionTitle: 'Cancel',
|
|
109
|
+
* secondaryActionTitle: 'Continue'
|
|
110
|
+
* });
|
|
111
|
+
*
|
|
112
|
+
* if (action === 'secondary') {
|
|
113
|
+
* console.log('User confirmed');
|
|
114
|
+
* }
|
|
115
|
+
* ```
|
|
55
116
|
*/
|
|
56
117
|
showDialog(config: AdaptyUiDialogConfig): Promise<AdaptyUiDialogActionType>;
|
|
57
118
|
private onRequestClose;
|
|
58
119
|
/**
|
|
59
|
-
*
|
|
60
|
-
*
|
|
61
|
-
* @see {@link https://adapty.io/docs/capacitor-handling-events | [DOC] Handling View Events}
|
|
120
|
+
* Registers event handlers for paywall UI events.
|
|
62
121
|
*
|
|
63
122
|
* @remarks
|
|
64
123
|
* Each event type can have only one handler — new handlers replace existing ones.
|
|
65
|
-
* Default handlers are registered in {@link
|
|
66
|
-
* - `onCloseButtonPress`
|
|
67
|
-
* - `onAndroidSystemBack`
|
|
68
|
-
* - `onRestoreCompleted`
|
|
69
|
-
* - `
|
|
124
|
+
* Default handlers are registered automatically in {@link createPaywallView} and provide standard closing behavior:
|
|
125
|
+
* - `onCloseButtonPress` - closes the paywall
|
|
126
|
+
* - `onAndroidSystemBack` - closes the paywall (Android only)
|
|
127
|
+
* - `onRestoreCompleted` - closes the paywall after successful restore
|
|
128
|
+
* - `onRenderingFailed` - closes the paywall when rendering fails
|
|
129
|
+
* - `onPurchaseCompleted` - closes the paywall after successful purchase
|
|
70
130
|
*
|
|
71
|
-
*
|
|
72
|
-
*
|
|
131
|
+
* If you want to override these listeners, we strongly recommend returning `true`
|
|
132
|
+
* (or `purchaseResult.type !== 'user_cancelled'` in case of `onPurchaseCompleted`)
|
|
73
133
|
* from your custom listener to retain default closing behavior.
|
|
74
134
|
*
|
|
75
135
|
* Calling this method multiple times will replace previously registered handlers for provided events.
|
|
76
136
|
*
|
|
77
|
-
* @
|
|
78
|
-
*
|
|
137
|
+
* @see {@link https://adapty.io/docs/capacitor-handling-events | Handling View Events}
|
|
138
|
+
*
|
|
139
|
+
* @param eventHandlers - Set of event handling callbacks. Only provided handlers will be registered or updated.
|
|
140
|
+
* @returns A promise that resolves to an unsubscribe function that removes all registered listeners.
|
|
141
|
+
*
|
|
142
|
+
* @example
|
|
143
|
+
* Register custom event handlers
|
|
144
|
+
* ```typescript
|
|
145
|
+
* import { createPaywallView } from '@adapty/capacitor';
|
|
146
|
+
*
|
|
147
|
+
* const view = await createPaywallView(paywall);
|
|
148
|
+
*
|
|
149
|
+
* const unsubscribe = await view.setEventHandlers({
|
|
150
|
+
* onPurchaseStarted: (product) => {
|
|
151
|
+
* console.log('Purchase started:', product.vendorProductId);
|
|
152
|
+
* },
|
|
153
|
+
* onPurchaseCompleted: (result) => {
|
|
154
|
+
* console.log('Purchase completed:', result.type);
|
|
155
|
+
* // Return true to keep default closing behavior
|
|
156
|
+
* return result.type !== 'user_cancelled';
|
|
157
|
+
* },
|
|
158
|
+
* onPurchaseFailed: (error) => {
|
|
159
|
+
* console.error('Purchase failed:', error);
|
|
160
|
+
* }
|
|
161
|
+
* });
|
|
162
|
+
*
|
|
163
|
+
* await view.present();
|
|
164
|
+
*
|
|
165
|
+
* // Later, unsubscribe all handlers
|
|
166
|
+
* unsubscribe();
|
|
167
|
+
* ```
|
|
79
168
|
*/
|
|
80
169
|
setEventHandlers(eventHandlers?: Partial<EventHandlers>): Promise<() => void>;
|
|
81
170
|
/**
|
|
82
|
-
* Clears all registered event handlers
|
|
171
|
+
* Clears all registered event handlers.
|
|
83
172
|
*
|
|
84
173
|
* @remarks
|
|
85
174
|
* This method removes all previously registered event handlers.
|
|
86
175
|
* After calling this method, no event handlers will be active
|
|
87
|
-
* until you call
|
|
176
|
+
* until you call {@link setEventHandlers} again.
|
|
177
|
+
*
|
|
178
|
+
* Use this after dismiss to remove all event handlers
|
|
179
|
+
*
|
|
180
|
+
* @example
|
|
181
|
+
* ```typescript
|
|
182
|
+
* const view = await createPaywallView(paywall);
|
|
183
|
+
* await view.setEventHandlers({ onPurchaseCompleted: handlePurchase });
|
|
184
|
+
*
|
|
185
|
+
* // Later, clear all handlers
|
|
186
|
+
* view.clearEventHandlers();
|
|
187
|
+
* ```
|
|
88
188
|
*/
|
|
89
189
|
clearEventHandlers(): void;
|
|
90
190
|
}
|