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
19 changes: 19 additions & 0 deletions content/docs/expo/changelog.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,25 @@ description: "Release notes for the Superwall Expo SDK"

# Changelog

## 1.0.11

### Patch Changes

- 975de31: Add android 'consume' method
- 2204ee8: Bump Android version

## 1.0.10

### Patch Changes

- 9d23138: Replace any in getPresentation result, improve chaining on delegate

## 1.0.9

### Patch Changes

- 836249d: Fix `useSuperwallEvents` so non-interactive Superwall callbacks are not dropped on first app launch before React listeners mount.

## 1.0.8

### 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 @@ -47,4 +47,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.8" repoUrl="https://github.com/superwall/expo-superwall" />
<SdkLatestVersion version="v1.0.11" repoUrl="https://github.com/superwall/expo-superwall" />
Comment thread
dcrawbuck marked this conversation as resolved.
3 changes: 1 addition & 2 deletions content/docs/expo/meta.json
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@

"---SDK Reference---",
"sdk-reference/index",
"sdk-reference/getPresentationResult",
"sdk-reference/components",
"sdk-reference/hooks",

Expand All @@ -42,4 +41,4 @@
"[Troubleshooting](https://support.superwall.com/articles/4780985851-troubleshooting-expo-sdk)",
"[Example App](https://github.com/superwall/expo-superwall/tree/main/example)"
]
}
}
53 changes: 53 additions & 0 deletions content/docs/expo/sdk-reference/hooks/consume.mdx
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
---
title: "consume()"
description: "Consume a Google Play purchase token from the Expo compat API."
---

## Purpose
Consumes a Google Play purchase token so the item can be purchased again. This is mainly for consumable Android purchases. The method is exposed on the Expo compat `Superwall` API and is Android-only; it is not supported on iOS.

## Signature
```ts
import Superwall from "expo-superwall/compat"

await Superwall.consume(
purchaseToken: string
): Promise<string>
```

## Parameters
<TypeTable
type={{
purchaseToken: {
type: "string",
description: "Google Play purchase token for the consumable item you want to consume.",
required: true,
},
}}
/>


## Returns / State
Returns a `Promise<string>` that resolves to the consumed purchase token.

The promise rejects if:
- you call it before `Superwall.configure()` completes,
- or the native Android consume operation fails.

## Usage
```tsx
import Superwall from "expo-superwall/compat"

async function consumePurchase(purchaseToken: string) {
try {
const token = await Superwall.consume(purchaseToken)
console.log("Purchase consumed:", token)
} catch (error) {
console.error("Failed to consume purchase:", error)
}
}
```

## Related
- [`useSuperwall`](/expo/sdk-reference/hooks/useSuperwall) - Hook access to the main Expo SDK store.
- [`getPresentationResult()`](/expo/sdk-reference/hooks/getPresentationResult) - Another Expo compat API surface with dedicated reference docs.
4 changes: 3 additions & 1 deletion content/docs/expo/sdk-reference/hooks/meta.json
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
{
"defaultOpen": true,
"pages": [
"getPresentationResult",
"consume",
"usePlacement",
"useUser",
"useSuperwall",
"..."
]
}
}
5 changes: 3 additions & 2 deletions content/docs/expo/sdk-reference/hooks/usePlacement.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ function usePlacement(
},
feature: {
type: "() => void",
description: "Optional function executed **only** if no paywall is shown (the user is allowed through).",
description: "Optional function queued when you register the placement. It runs if presentation is skipped, or after the paywall dismisses with `purchased` or `restored`. It does not run on paywall errors or other dismiss results.",
},
}}
/>
Expand Down Expand Up @@ -131,7 +131,8 @@ export default function PremiumButton() {
await registerPlacement({
placement: "MyFeaturePlacement",
feature: () => {
// User was allowed through without a paywall
// Runs when the user is allowed through immediately,
// or after a purchased/restored paywall dismissal.
navigateToPremiumFeature()
},
})
Expand Down
41 changes: 40 additions & 1 deletion content/docs/expo/sdk-reference/hooks/useSuperwall.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,10 @@ The hook returns an object representing the Superwall store. If a `selector` fun
type: "(placement: string, params?: Record<string, any>) => Promise<PresentationResult>",
description: "Gets the presentation result for a placement without presenting.",
},
restorePurchases: {
type: "() => Promise<RestorationResultResponse>",
description: "Programmatically restores purchases and returns whether the restore succeeded or failed.",
},
dismiss: {
type: "() => Promise<void>",
description: "Dismisses any currently presented paywall.",
Expand Down Expand Up @@ -104,7 +108,7 @@ The hook returns an object representing the Superwall store. If a `selector` fun
},
getEntitlements: {
type: "() => Promise<EntitlementsInfo>",
description: "Fetches active and inactive entitlements for the user.",
description: "Fetches the user's entitlement snapshot, including active and inactive entitlements, plus all known entitlements when exposed by the native bridge.",
},
}}
/>
Expand Down Expand Up @@ -160,6 +164,41 @@ The hook returns an object representing the Superwall store. If a `selector` fun
}}
/>

### EntitlementsInfo
<TypeTable
type={{
all: {
type: "Entitlement[]?",
description: "All entitlements known for the user. Present when the native bridge exposes the full entitlement set.",
},
active: {
type: "Entitlement[]",
description: "Entitlements that are currently active.",
required: true,
},
inactive: {
type: "Entitlement[]",
description: "Entitlements that are known but not currently active.",
required: true,
},
}}
/>

### RestorationResultResponse
<TypeTable
type={{
result: {
type: '"restored" | "failed"',
description: "Outcome of the restore attempt.",
required: true,
},
errorMessage: {
type: "string | null",
description: "Error message when `result` is `failed`.",
},
}}
/>

## Example
(Direct Usage - Advanced)

Expand Down
22 changes: 21 additions & 1 deletion content/docs/expo/sdk-reference/hooks/useUser.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ The `useUser` hook provides a convenient way to manage user identity and attribu
},
getEntitlements: {
type: "() => Promise<EntitlementsInfo>",
description: "Fetches active and inactive entitlements for the user.",
description: "Fetches the user's entitlement snapshot, including active and inactive entitlements, plus all known entitlements when exposed by the native bridge.",
},
setSubscriptionStatus: {
type: "(status: SubscriptionStatus) => Promise<void>",
Expand Down Expand Up @@ -78,6 +78,26 @@ The `useUser` hook provides a convenient way to manage user identity and attribu
}}
/>

### EntitlementsInfo
<TypeTable
type={{
all: {
type: "Entitlement[]?",
description: "All entitlements known for the user. Present when the native bridge exposes the full entitlement set.",
},
active: {
type: "Entitlement[]",
description: "Entitlements that are currently active.",
required: true,
},
inactive: {
type: "Entitlement[]",
description: "Entitlements that are known but not currently active.",
required: true,
},
}}
/>

### UserAttributes
<TypeTable
type={{
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.8" repoUrl="https://github.com/superwall/expo-superwall" />
<SdkLatestVersion version="v1.0.11" repoUrl="https://github.com/superwall/expo-superwall" />
Loading