Add custom callbacks message and interface #347
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Changes in this pull request
PaywallPresentationHandlercalledonCustomCallbackthat allows user to handle custom callback requestsChecklist
CHANGELOG.mdfor any breaking changes, enhancements, or bug fixes.ktlintin the main directory and fixed any issues.Greptile Summary
Adds custom callback support enabling bidirectional communication between paywalls and app code.
CustomCallback,CustomCallbackBehavior, andCustomCallbackResultdata classes to represent callback requests and responsesCustomCallbackRegistryusingConcurrentHashMapfor thread-safe handler storage with proper lifecycle management (registration on present, cleanup on dismiss)onCustomCallbackmethod toPaywallPresentationHandleras the public API for apps to handle custom callback requestsrequest_callback) and response sending (callback_result) inPaywallMessageHandlerConfidence Score: 5/5
Important Files Changed
Sequence Diagram
sequenceDiagram participant App as App Code participant Handler as PaywallPresentationHandler participant Registry as CustomCallbackRegistry participant Superwall as Superwall participant WebView as PaywallView/WebView participant MsgHandler as PaywallMessageHandler Note over App,Handler: Registration Phase App->>Handler: register(event, handler) App->>Handler: handler.onCustomCallback { callback -> ... } Handler->>Handler: Store onCustomCallbackHandler Note over Superwall,Registry: Presentation Phase Superwall->>Registry: register(paywallId, handler) Superwall->>WebView: Present Paywall Note over WebView,MsgHandler: Callback Request WebView->>MsgHandler: postMessage("request_callback") MsgHandler->>MsgHandler: Parse PaywallMessage.RequestCallback MsgHandler->>Superwall: eventDidOccur(RequestCallback) Note over MsgHandler,Registry: Handler Execution MsgHandler->>Registry: getHandler(paywallId) Registry-->>MsgHandler: Return handler or null alt Handler exists MsgHandler->>App: Invoke handler(CustomCallback) App-->>MsgHandler: Return CustomCallbackResult MsgHandler->>WebView: sendCallbackResult(success/failure) else No handler MsgHandler->>WebView: sendCallbackResult(failure) end Note over Superwall,Registry: Dismissal Phase WebView->>Superwall: Paywall Dismissed Superwall->>Registry: unregister(paywallId) Registry->>Registry: Remove handler