Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions content/docs/expo/changelog.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,13 @@ description: "Release notes for the Superwall Expo SDK"

# Changelog

## 1.0.3

### Patch Changes

- Update Android & iOS SDKs, add Custom callbacks
- Update Android to 2.7.2, fixing experimental properties option

## 1.0.2

### Patch Changes
Expand Down
2 changes: 1 addition & 1 deletion content/docs/expo/index.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -39,4 +39,4 @@ If you have feedback on any of our docs, please leave a rating and message at th

If you have any issues please [open an issue on GitHub](https://github.com/superwall/expo-superwall/issues).

<SdkLatestVersion version="v1.0.2" repoUrl="https://github.com/superwall/expo-superwall" />
<SdkLatestVersion version="v1.0.3" repoUrl="https://github.com/superwall/expo-superwall" />
39 changes: 39 additions & 0 deletions content/docs/expo/sdk-reference/hooks/usePlacement.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,10 @@ function usePlacement(
type: "(error: string) => void",
description: "Called when the paywall fails to present or another SDK error occurs.",
},
onCustomCallback: {
type: "(callback: CustomCallback) => Promise<CustomCallbackResult> | CustomCallbackResult",
description: "Called when a custom callback is invoked from a paywall. Return a result to send back to the paywall.",
},
}}
/>

Expand Down Expand Up @@ -112,6 +116,36 @@ function usePlacement(
}}
/>

### CustomCallback
<TypeTable
type={{
name: {
type: "string",
description: "The name of the callback as defined in the paywall.",
required: true,
},
variables: {
type: "Record<string, any>?",
description: "Optional variables passed from the paywall.",
},
}}
/>

### CustomCallbackResult
<TypeTable
type={{
status: {
type: "\"success\" | \"failure\"",
description: "Whether the callback succeeded or failed. Determines which branch (onSuccess/onFailure) executes in the paywall.",
required: true,
},
data: {
type: "Record<string, any>?",
description: "Optional key-value pairs to return to the paywall.",
},
}}
/>

## Usage
```tsx
import { Button, Text } from "react-native"
Expand All @@ -125,6 +159,11 @@ export default function PremiumButton() {
onSkip: (reason) =>
console.log("Paywall skipped:", reason.type),
onError: (error) => console.error("Paywall error:", error),
onCustomCallback: async (callback) => {
// Handle custom callbacks from the paywall
console.log("Custom callback:", callback.name, callback.variables)
return { status: "success", data: { validated: true } }
},
})

const unlockFeature = async () => {
Expand Down
4 changes: 4 additions & 0 deletions content/docs/expo/sdk-reference/hooks/useSuperwallEvents.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,10 @@ The `useSuperwallEvents` hook provides a low-level way to subscribe to *any* nat
type: "(paywallInfo: PaywallInfo) => boolean",
description: "Android only. Triggered when a rerouted paywall back button is pressed. Return true to consume the event.",
},
onCustomCallback: {
type: "(callback: CustomCallback) => Promise<CustomCallbackResult> | CustomCallbackResult",
description: "Called when a custom callback is invoked from a paywall. Custom callbacks allow paywalls to communicate with the app to perform operations like validation or data fetching. Return a result to send back to the paywall.",
},
handlerId: {
type: "string?",
description: "Optional scope for paywall events from a specific registerPlacement handler.",
Expand Down
2 changes: 1 addition & 1 deletion content/docs/expo/sdk-reference/index.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -15,4 +15,4 @@ If you have feedback on any of our docs, please leave a rating and message at th

If you have any issues with the SDK, please [open an issue on GitHub](https://github.com/superwall/expo-superwall/issues).

<SdkLatestVersion version="v1.0.2" repoUrl="https://github.com/superwall/expo-superwall" />
<SdkLatestVersion version="v1.0.3" repoUrl="https://github.com/superwall/expo-superwall" />