@superwall/cli 2.0.0 → 2.1.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/dist/{apple-CkKlHBZ9.js → apple-CSzNTGHM.js} +13 -13
- package/dist/auth.d.ts +1 -1
- package/dist/auth.js +3 -3
- package/dist/{billing-XCZU_T46.js → billing-C3Q8DBU2.js} +3 -3
- package/dist/{bind-drne__Ys.js → bind-BumHTi9O.js} +4 -4
- package/dist/{build-Gpdq5QXP.js → build-Bpviiclc.js} +6 -6
- package/dist/{client-DP6Rc0t_.js → client-BL0f_yGf.js} +2 -2
- package/dist/create-BSfvpWoD.js +19 -0
- package/dist/{create-Cwc3SRWJ.js → create-BUcVG4Ab.js} +23 -23
- package/dist/{create-BBrtgUgS.js → create-CfK3PeKA.js} +6 -6
- package/dist/{doctor-C9ldpPFC.js → doctor-BWqIYcMn.js} +6 -6
- package/dist/{drivers-DNrx4LWA.js → drivers-CPhdPkW5.js} +3 -3
- package/dist/entry.js +20 -21
- package/dist/{environment-DF1qKlny.js → environment-eBXjELoN.js} +1 -1
- package/dist/{existing-78LWSsqS.js → existing-BltvQiX5.js} +2 -2
- package/dist/held-CPve03KJ.js +16 -0
- package/dist/{held-Cy8Wl4D1.js → held-DgnTFMl3.js} +6 -6
- package/dist/{integrate-DcJhpXy8.js → integrate-BRsqoe01.js} +22 -22
- package/dist/{login-B2TsCE2H.js → login-BCEH5q0U.js} +1 -1
- package/dist/login-BPOONe7n.js +16 -0
- package/dist/{login-D0lh3_JI.js → login-BbTIrCFT.js} +5 -5
- package/dist/{lookup-D-nmmAbw.js → lookup-rr1AkCJA.js} +2 -2
- package/dist/{migrate-Cfec564E.js → migrate-C9X2Vz81.js} +22 -22
- package/dist/{notification-url-YDbq6FMA.js → notification-url-CV86qiKP.js} +2 -2
- package/dist/{open-Ba2vBl1_.js → open-CcpXotHG.js} +10 -10
- package/dist/{org-D0g_q3mv.js → org-BQQDo7wm.js} +2 -2
- package/dist/{paths-DxSLdpOI.js → paths-CRlU72cq.js} +1 -1
- package/dist/{playbook-DIeb7hne.js → playbook-DVMXN7fh.js} +10 -10
- package/dist/{promote-COD4fYdz.js → promote-Da8xctzy.js} +16 -16
- package/dist/push-BV-grvQg.js +22 -0
- package/dist/{push-CncywhkQ.js → push-D6R9icWN.js} +27 -14
- package/dist/{registry-DSrosOYs.js → registry-BYVD-_h6.js} +206 -49
- package/dist/{resources-Dqr01Dep.js → resources-DLON3-61.js} +18 -6
- package/dist/{run-C9qg_QlC.js → run-Co-BwhOg.js} +2 -2
- package/dist/scan-B88OlWOt.js +4 -0
- package/dist/{scan-DLrsrFS9.js → scan-CKuk-_6W.js} +1 -1
- package/dist/{scope-V336uz8j.js → scope-DV22_Ufm.js} +4 -4
- package/dist/{selection-Rdw-ZUoG.js → selection-C2_KbLuo.js} +10 -4
- package/dist/server-C4f6ccUr.js +22 -0
- package/dist/{server-D0tGG8C4.js → server-D0d2oP-5.js} +10 -8
- package/dist/{session-CFAmMhem.js → session-B-Uz0cQ7.js} +1 -1
- package/dist/session-BuvArt1j.js +6 -0
- package/dist/{session-D_nEWKXT.js → session-C4rbE3VS.js} +41 -13
- package/dist/skills/superwall-framework/SKILL.md +7 -3
- package/dist/skills/superwall-framework/references/cli.md +1 -0
- package/dist/skills/superwall-framework/references/layout.md +34 -1
- package/dist/{skills-DMG4bpKk.js → skills-CLGJuMnF.js} +8 -8
- package/dist/{skills-BvFOa4y6.js → skills-CZcpnEnG.js} +5 -4
- package/dist/{spinner-CneRK5rk.js → spinner-C2U6QBJ9.js} +3 -3
- package/dist/{storage-s2Dnz-yl.js → storage-6h9vyiAz.js} +1 -1
- package/dist/storekit-CK9JmM2D.js +16 -0
- package/dist/{storekit-yY_kS2iR.js → storekit-CinJra3V.js} +3 -3
- package/dist/{telemetry-DtG92m5O.js → telemetry-DKyDhURo.js} +1 -1
- package/dist/{token-DzRh7dI1.js → token-DaxQgQkv.js} +1 -1
- package/dist/tools-skills/animate-onboarding/SKILL.md +467 -0
- package/dist/tools-skills/animate-onboarding/references/engine.md +494 -0
- package/dist/tools-skills/animate-onboarding/references/framework/Question.tsx +71 -0
- package/dist/tools-skills/animate-onboarding/references/framework/README.md +40 -0
- package/dist/tools-skills/animate-onboarding/references/framework/answers.ts +19 -0
- package/dist/tools-skills/animate-onboarding/references/framework/flow.ts +80 -0
- package/dist/tools-skills/animate-onboarding/references/framework/handoffs.ts +869 -0
- package/dist/tools-skills/animate-onboarding/references/framework/layout.tsx +113 -0
- package/dist/tools-skills/animate-onboarding/references/framework/motion.css +559 -0
- package/dist/tools-skills/animate-onboarding/references/framework/useStoryRouter.ts +48 -0
- package/dist/tools-skills/animate-onboarding/references/handoffs.md +375 -0
- package/dist/tools-skills/animate-onboarding/references/imageReady.ts +92 -0
- package/dist/tools-skills/animate-onboarding/references/morphFrame.ts +356 -0
- package/dist/tools-skills/animate-onboarding/references/performance.md +41 -0
- package/dist/tools-skills/animate-onboarding/references/web-runtime/README.md +17 -0
- package/dist/tools-skills/animate-onboarding/references/web-runtime/handoffs.ts +858 -0
- package/dist/tools-skills/animate-onboarding/references/web-runtime/story-motion.css +301 -0
- package/dist/tools-skills/mobile-design/SKILL.md +447 -0
- package/dist/tools-skills/mobile-design/references/responsive.md +162 -0
- package/dist/tools-skills/onboarding-questions/SKILL.md +231 -0
- package/dist/tools-skills/onboarding-questions/references/arpu-questions.md +139 -0
- package/dist/tools-skills/onboarding-questions/references/craft.md +142 -0
- package/dist/tools-skills/onboarding-questions/references/example-reflective.md +117 -0
- package/dist/tools-skills/superwall/SKILL.md +263 -0
- package/dist/tools-skills/superwall/references/api.md +303 -0
- package/dist/tools-skills/superwall/references/asa.md +166 -0
- package/dist/tools-skills/superwall/references/asc.md +95 -0
- package/dist/tools-skills/superwall/references/dashboard-links.md +57 -0
- package/dist/tools-skills/superwall/references/data-analytics.md +896 -0
- package/dist/tools-skills/superwall/references/docs.md +51 -0
- package/dist/tools-skills/superwall/references/sdk-integration.md +104 -0
- package/dist/tools-skills/superwall/references/sdk-source.md +18 -0
- package/dist/tools-skills/superwall/workflows/dashboard/playbook.md +76 -0
- package/dist/tools-skills/superwall/workflows/dashboard/setup.md +100 -0
- package/dist/tools-skills/superwall/workflows/integrate/android.md +292 -0
- package/dist/tools-skills/superwall/workflows/integrate/expo.md +272 -0
- package/dist/tools-skills/superwall/workflows/integrate/flutter.md +285 -0
- package/dist/tools-skills/superwall/workflows/integrate/ios.md +314 -0
- package/dist/tools-skills/superwall/workflows/integrate/playbook.md +83 -0
- package/dist/tools-skills/superwall/workflows/integrate/react-native.md +246 -0
- package/dist/tools-skills/superwall/workflows/migrate/adapty.md +229 -0
- package/dist/tools-skills/superwall/workflows/migrate/playbook.md +78 -0
- package/dist/tools-skills/superwall/workflows/migrate/qonversion.md +227 -0
- package/dist/tools-skills/superwall/workflows/migrate/revenuecat.md +414 -0
- package/dist/tools-skills/superwall/workflows/placements/android.md +175 -0
- package/dist/tools-skills/superwall/workflows/placements/expo.md +161 -0
- package/dist/tools-skills/superwall/workflows/placements/flutter.md +139 -0
- package/dist/tools-skills/superwall/workflows/placements/ios.md +165 -0
- package/dist/tools-skills/superwall/workflows/placements/playbook.md +69 -0
- package/dist/tools-skills/superwall/workflows/placements/react-native.md +145 -0
- package/dist/tools-skills/superwall/workflows/placements/strategy.md +222 -0
- package/dist/tools-skills/superwall/workflows/review/android.md +120 -0
- package/dist/tools-skills/superwall/workflows/review/expo.md +100 -0
- package/dist/tools-skills/superwall/workflows/review/flutter.md +99 -0
- package/dist/tools-skills/superwall/workflows/review/ios.md +108 -0
- package/dist/tools-skills/superwall/workflows/review/playbook.md +70 -0
- package/dist/tools-skills/superwall/workflows/review/react-native.md +100 -0
- package/dist/tools-skills/superwall-editor/SKILL.md +113 -0
- package/dist/tools-skills/superwall-editor/references/cli.md +135 -0
- package/dist/tools-skills/superwall-editor/references/design.md +51 -0
- package/dist/tools-skills/superwall-editor/references/native-elements.md +171 -0
- package/dist/tools-skills/superwall-editor/references/workflow.md +65 -0
- package/dist/tools-skills/superwall-editor/scripts/sw-editor.sh +662 -0
- package/dist/tools-skills/wwdc/SKILL.md +22 -0
- package/dist/tools-skills/wwdc/references/docs.md +52 -0
- package/dist/tools-skills/wwdc/scripts/wwdc.sh +266 -0
- package/dist/tools.d.ts +1 -1
- package/dist/tools.js +200 -18
- package/dist/{upgrade-Bt4Ouw1y.js → upgrade-DPo0a4Es.js} +1 -1
- package/dist/{upgrade-Cqy5orjb.js → upgrade-ffseQDMx.js} +2 -2
- package/package.json +2 -2
- package/dist/create-Yvf2gStM.js +0 -19
- package/dist/held-Ddw1XSsr.js +0 -16
- package/dist/kinds-GFXB3sYu.js +0 -11
- package/dist/login-BoBe8Psl.js +0 -16
- package/dist/push-CtD4FZQV.js +0 -22
- package/dist/scan-Cv5uOwVY.js +0 -4
- package/dist/send-BxD9yf6F.js +0 -150
- package/dist/server-z1LH94R_.js +0 -22
- package/dist/session-1AV_Bs_d.js +0 -6
- package/dist/storekit-DafAnGkM.js +0 -16
- /package/dist/{devtools-ByZ6XYnn.js → devtools-pBl_vt03.js} +0 -0
- /package/dist/{reports-DdPq4blM.js → reports-D_qbl7_u.js} +0 -0
- /package/dist/{screenshot-file-0UETadF8.js → screenshot-file-tVBfUEIi.js} +0 -0
- /package/dist/{storage-DYvmIOHa.d.ts → storage-CerJ5KLP.d.ts} +0 -0
|
@@ -0,0 +1,314 @@
|
|
|
1
|
+
# Integrate Superwall - iOS / Swift
|
|
2
|
+
|
|
3
|
+
You are integrating Superwall into a native iOS app (SwiftUI or UIKit). Get the
|
|
4
|
+
SDK installed and configured cleanly. **Do not add paywall triggers (`register`)**;
|
|
5
|
+
that is the separate **superwall-placements** skill.
|
|
6
|
+
|
|
7
|
+
## Checklist
|
|
8
|
+
|
|
9
|
+
Work top to bottom. Steps 1-4 are this skill; 5-6 verify; 7 is the hand-off list.
|
|
10
|
+
|
|
11
|
+
- [ ] **0. Decide the purchase-handling path** (default / RevenueCat / custom) - it changes what you write in steps 2 & 4.
|
|
12
|
+
- [ ] **1. Install** `SuperwallKit` via the manager the project already uses (SPM or CocoaPods).
|
|
13
|
+
- [ ] **2. Configure** once at launch with the public `pk_` key.
|
|
14
|
+
- [ ] **3. API key** handled correctly (public key, not a secret; follow existing config pattern).
|
|
15
|
+
- [ ] **4. Purchase handling** wired for the chosen path.
|
|
16
|
+
- [ ] **5. Build** - compiles with `SuperwallKit` resolved.
|
|
17
|
+
- [ ] **6. Run** - console shows Superwall SDK startup; StoreKit test config in place if testing purchases.
|
|
18
|
+
- [ ] **7. Post-integration** (identity, attributes, subscription state, deep links, analytics) - see the final section; wire what the app needs, then move to **superwall-placements**.
|
|
19
|
+
|
|
20
|
+
## Docs access - read the current page when baked steps aren't enough
|
|
21
|
+
|
|
22
|
+
Superwall's docs are fetchable **as markdown**. When a step below is ambiguous or
|
|
23
|
+
you need current detail, fetch the page rather than guessing:
|
|
24
|
+
|
|
25
|
+
```bash
|
|
26
|
+
curl -sL https://superwall.com/docs/ios/llms.txt # index: every iOS doc path
|
|
27
|
+
curl -sL https://superwall.com/docs/llms-full.txt # broad context across all SDKs
|
|
28
|
+
curl -sL https://superwall.com/docs/ios/quickstart/install.md # any page + ".md"
|
|
29
|
+
```
|
|
30
|
+
|
|
31
|
+
Pattern: fetch `ios/llms.txt` to find the slug, then fetch
|
|
32
|
+
`https://superwall.com/docs/ios/{path}.md`. Every `curl` in this file is verified
|
|
33
|
+
working. **Never invent an API** - if a symbol isn't in this reference or a page
|
|
34
|
+
you fetched, fetch the page and confirm.
|
|
35
|
+
|
|
36
|
+
## Quickstart walk
|
|
37
|
+
|
|
38
|
+
The iOS quickstart is a sequence of pages. This reference mirrors it. Fetch any
|
|
39
|
+
page with the `curl` shown at that step.
|
|
40
|
+
|
|
41
|
+
| Order | Slug | Covered by |
|
|
42
|
+
| ----- | -------------------------------------------- | ----------------------------------------- |
|
|
43
|
+
| 1 | `ios/quickstart/install` | Step 1 here |
|
|
44
|
+
| 2 | `ios/quickstart/configure` | Step 2 here |
|
|
45
|
+
| 3 | `ios/quickstart/feature-gating` | **superwall-placements** skill (not here) |
|
|
46
|
+
| 4 | `ios/quickstart/in-app-paywall-previews` | placements / QA |
|
|
47
|
+
| 5 | `ios/quickstart/setting-user-properties` | Step 7 here |
|
|
48
|
+
| 6 | `ios/quickstart/tracking-subscription-state` | Step 7 here |
|
|
49
|
+
| 7 | `ios/quickstart/user-management` | Step 7 here |
|
|
50
|
+
|
|
51
|
+
## Step 0 - Purchase-handling path (decide first)
|
|
52
|
+
|
|
53
|
+
> **Important:** This choice determines whether you pass a `PurchaseController`
|
|
54
|
+
> and whether _you_ must keep `subscriptionStatus` in sync. Paths (b) and (c)
|
|
55
|
+
> require manual subscription-status management; path (a) does not.
|
|
56
|
+
|
|
57
|
+
- **(a) Default - Superwall handles StoreKit.** No existing IAP code. Recommended,
|
|
58
|
+
zero purchase code. Superwall manages purchases, restores, and subscription
|
|
59
|
+
status. Use this unless the app already has a billing SDK.
|
|
60
|
+
- **(b) RevenueCat stays the source of truth.** The app already uses RevenueCat.
|
|
61
|
+
Keep RC as the purchase controller and sync its `CustomerInfo` into Superwall.
|
|
62
|
+
Follow `curl -sL https://superwall.com/docs/ios/guides/using-revenuecat.md`.
|
|
63
|
+
- **(c) Custom `PurchaseController`.** The app has its own StoreKit/billing stack.
|
|
64
|
+
Implement `PurchaseController` and drive `subscriptionStatus` yourself.
|
|
65
|
+
|
|
66
|
+
For a full migration off another SDK, use the **superwall-migrate** skill.
|
|
67
|
+
|
|
68
|
+
## Step 1 - Install
|
|
69
|
+
|
|
70
|
+
The SDK product is **`SuperwallKit`** from `github.com/superwall/Superwall-iOS`.
|
|
71
|
+
Use the dependency manager the project already uses.
|
|
72
|
+
|
|
73
|
+
```bash
|
|
74
|
+
curl -sL https://superwall.com/docs/ios/quickstart/install.md
|
|
75
|
+
```
|
|
76
|
+
|
|
77
|
+
### Swift Package Manager (preferred; detect `Package.swift` or existing SPM setup)
|
|
78
|
+
|
|
79
|
+
**Via Xcode UI:**
|
|
80
|
+
|
|
81
|
+
1. File ▸ Add Package Dependencies…
|
|
82
|
+
2. Paste `https://github.com/superwall/Superwall-iOS`.
|
|
83
|
+
3. Dependency Rule: **Up to Next Major Version**, lower bound **`4.0.0`**.
|
|
84
|
+
4. Add Package; confirm the **SuperwallKit** product is added to your app target.
|
|
85
|
+
|
|
86
|
+
**Via `Package.swift`** (SPM projects, and the safe route for an agent with Xcode closed):
|
|
87
|
+
|
|
88
|
+
```swift
|
|
89
|
+
dependencies: [
|
|
90
|
+
.package(url: "https://github.com/superwall/Superwall-iOS", from: "4.0.0"),
|
|
91
|
+
],
|
|
92
|
+
targets: [
|
|
93
|
+
.target(
|
|
94
|
+
name: "YourApp",
|
|
95
|
+
dependencies: [
|
|
96
|
+
.product(name: "SuperwallKit", package: "Superwall-iOS"),
|
|
97
|
+
]
|
|
98
|
+
),
|
|
99
|
+
]
|
|
100
|
+
```
|
|
101
|
+
|
|
102
|
+
**Editing `.pbxproj` directly** (agent, no Xcode): only if the project already has
|
|
103
|
+
SPM references to copy the exact `XCRemoteSwiftPackageReference` /
|
|
104
|
+
`XCSwiftPackageProductDependency` structure from; then
|
|
105
|
+
`xcodebuild -resolvePackageDependencies`. Otherwise instruct the user to add it via
|
|
106
|
+
the Xcode UI - safer than hand-editing.
|
|
107
|
+
|
|
108
|
+
### CocoaPods (detect a `Podfile`)
|
|
109
|
+
|
|
110
|
+
Add to the app target:
|
|
111
|
+
|
|
112
|
+
```ruby
|
|
113
|
+
pod 'SuperwallKit', '< 5.0.0'
|
|
114
|
+
```
|
|
115
|
+
|
|
116
|
+
Then:
|
|
117
|
+
|
|
118
|
+
```bash
|
|
119
|
+
pod repo update
|
|
120
|
+
pod install
|
|
121
|
+
```
|
|
122
|
+
|
|
123
|
+
> **Important:** With CocoaPods, set **User Script Sandboxing = No** in the
|
|
124
|
+
> target's Build Settings, or the build fails on the SDK's build phase.
|
|
125
|
+
|
|
126
|
+
## Step 2 - Configure
|
|
127
|
+
|
|
128
|
+
Call `Superwall.configure(apiKey:)` **once, at launch, as early as possible**.
|
|
129
|
+
|
|
130
|
+
```bash
|
|
131
|
+
curl -sL https://superwall.com/docs/ios/quickstart/configure.md
|
|
132
|
+
```
|
|
133
|
+
|
|
134
|
+
```swift
|
|
135
|
+
import SuperwallKit
|
|
136
|
+
```
|
|
137
|
+
|
|
138
|
+
### SwiftUI - in the `App` struct's `init()`
|
|
139
|
+
|
|
140
|
+
```swift
|
|
141
|
+
import SwiftUI
|
|
142
|
+
import SuperwallKit
|
|
143
|
+
|
|
144
|
+
@main
|
|
145
|
+
struct MyApp: App {
|
|
146
|
+
init() {
|
|
147
|
+
Superwall.configure(apiKey: "pk_YOUR_PUBLIC_KEY")
|
|
148
|
+
}
|
|
149
|
+
|
|
150
|
+
var body: some Scene {
|
|
151
|
+
WindowGroup { ContentView() }
|
|
152
|
+
}
|
|
153
|
+
}
|
|
154
|
+
```
|
|
155
|
+
|
|
156
|
+
### UIKit - in `AppDelegate`
|
|
157
|
+
|
|
158
|
+
```swift
|
|
159
|
+
import UIKit
|
|
160
|
+
import SuperwallKit
|
|
161
|
+
|
|
162
|
+
@main
|
|
163
|
+
class AppDelegate: UIResponder, UIApplicationDelegate {
|
|
164
|
+
func application(
|
|
165
|
+
_ application: UIApplication,
|
|
166
|
+
didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?
|
|
167
|
+
) -> Bool {
|
|
168
|
+
Superwall.configure(apiKey: "pk_YOUR_PUBLIC_KEY")
|
|
169
|
+
return true
|
|
170
|
+
}
|
|
171
|
+
}
|
|
172
|
+
```
|
|
173
|
+
|
|
174
|
+
With a `SceneDelegate`, still configure in `AppDelegate`'s
|
|
175
|
+
`didFinishLaunchingWithOptions` - it runs first and only once.
|
|
176
|
+
|
|
177
|
+
### Objective-C
|
|
178
|
+
|
|
179
|
+
```objectivec
|
|
180
|
+
@import SuperwallKit;
|
|
181
|
+
[Superwall configureWithApiKey:@"pk_YOUR_PUBLIC_KEY"];
|
|
182
|
+
```
|
|
183
|
+
|
|
184
|
+
## Step 3 - API key handling
|
|
185
|
+
|
|
186
|
+
Use the **Public API Key** (starts with `pk_`) from Dashboard ▸ Settings ▸ Keys.
|
|
187
|
+
On iOS it is conventional to inline the public key in the `configure` call - it is
|
|
188
|
+
not a secret. **Never** use a secret/server key here and never commit one. If the
|
|
189
|
+
project centralizes config (an `.xcconfig`, a `Secrets` enum), follow that pattern.
|
|
190
|
+
|
|
191
|
+
## Step 4 - Purchase handling (implements Step 0's choice)
|
|
192
|
+
|
|
193
|
+
### (a) Default
|
|
194
|
+
|
|
195
|
+
Nothing extra. `Superwall.configure(apiKey:)` with no `purchaseController` means
|
|
196
|
+
Superwall manages purchases, restores, and subscription status automatically.
|
|
197
|
+
|
|
198
|
+
### (b) RevenueCat
|
|
199
|
+
|
|
200
|
+
Create an `RCPurchaseController: PurchaseController` that forwards `purchase` to
|
|
201
|
+
`Purchases.shared.purchase()` and `restorePurchases` to
|
|
202
|
+
`Purchases.shared.restorePurchases()`, then sync entitlements via RevenueCat's
|
|
203
|
+
`customerInfoStream` into `Superwall.shared.subscriptionStatus`:
|
|
204
|
+
|
|
205
|
+
```swift
|
|
206
|
+
let purchaseController = RCPurchaseController()
|
|
207
|
+
Superwall.configure(apiKey: "pk_YOUR_PUBLIC_KEY", purchaseController: purchaseController)
|
|
208
|
+
purchaseController.syncSubscriptionStatus()
|
|
209
|
+
```
|
|
210
|
+
|
|
211
|
+
> **Important:** Copy the full `RCPurchaseController` from the doc - do not hand-roll it.
|
|
212
|
+
> `curl -sL https://superwall.com/docs/ios/guides/using-revenuecat.md`
|
|
213
|
+
|
|
214
|
+
### (c) Custom `PurchaseController`
|
|
215
|
+
|
|
216
|
+
```bash
|
|
217
|
+
curl -sL https://superwall.com/docs/ios/guides/advanced-configuration.md
|
|
218
|
+
```
|
|
219
|
+
|
|
220
|
+
```swift
|
|
221
|
+
import SuperwallKit
|
|
222
|
+
import StoreKit
|
|
223
|
+
|
|
224
|
+
final class MyPurchaseController: PurchaseController {
|
|
225
|
+
static let shared = MyPurchaseController()
|
|
226
|
+
|
|
227
|
+
func purchase(product: StoreProduct) async -> PurchaseResult {
|
|
228
|
+
// Purchase via StoreKit / your billing system, then return one of:
|
|
229
|
+
return .purchased // .cancelled, .pending, .failed(Error)
|
|
230
|
+
}
|
|
231
|
+
|
|
232
|
+
func restorePurchases() async -> RestorationResult {
|
|
233
|
+
return .restored // .failed(error)
|
|
234
|
+
}
|
|
235
|
+
}
|
|
236
|
+
|
|
237
|
+
Superwall.configure(
|
|
238
|
+
apiKey: "pk_YOUR_PUBLIC_KEY",
|
|
239
|
+
purchaseController: MyPurchaseController.shared
|
|
240
|
+
)
|
|
241
|
+
```
|
|
242
|
+
|
|
243
|
+
> **Important (paths b & c):** With a `PurchaseController` you **must** set
|
|
244
|
+
> `Superwall.shared.subscriptionStatus` whenever entitlements change. Cases:
|
|
245
|
+
> `.unknown` (default - paywalls wait), `.active(let entitlements)` (a
|
|
246
|
+
> `Set<Entitlement>`), `.inactive`. Leaving it `.unknown` means paywalls never present.
|
|
247
|
+
|
|
248
|
+
```swift
|
|
249
|
+
Superwall.shared.subscriptionStatus = .active(entitlements) // Set<Entitlement>
|
|
250
|
+
Superwall.shared.subscriptionStatus = .inactive
|
|
251
|
+
```
|
|
252
|
+
|
|
253
|
+
## Step 5 & 6 - Verify
|
|
254
|
+
|
|
255
|
+
1. **Build:** `xcodebuild -scheme <YourScheme> -destination 'generic/platform=iOS' build`
|
|
256
|
+
(or ⌘B). Must compile with `SuperwallKit` resolved.
|
|
257
|
+
2. **Run** on a simulator; the Xcode console logs Superwall SDK startup. To confirm
|
|
258
|
+
the key, temporarily set `SuperwallOptions.logging.level = .debug` and look for a
|
|
259
|
+
successful config fetch.
|
|
260
|
+
3. **StoreKit testing** (test purchases without App Store Connect): File ▸ New ▸
|
|
261
|
+
File… ▸ StoreKit Configuration File, name it `Products`, save at project root
|
|
262
|
+
(don't add to target). Scheme ▸ Run ▸ Options ▸ StoreKit Configuration ▸ select
|
|
263
|
+
`Products.storekit`. Product IDs must match the products on your paywall. Reset via
|
|
264
|
+
Debug ▸ StoreKit ▸ Manage Transactions.
|
|
265
|
+
`curl -sL https://superwall.com/docs/ios/guides/testing-purchases.md`
|
|
266
|
+
|
|
267
|
+
## Step 7 - Post-integration (wire what the app needs, then → placements)
|
|
268
|
+
|
|
269
|
+
Do the ones the app requires. Each has a fetchable page.
|
|
270
|
+
|
|
271
|
+
- **User identity - REQUIRED if the app has ANY auth/login system.** Not optional: without it every logged-in user is anonymous to Superwall, breaking user-scoped audiences, attribution, and cross-device status. Wire it the moment you see a login/logout flow (grep for signIn/login/logout/signOut/auth). call `Superwall.shared.identify(userId:)` on login,
|
|
272
|
+
`Superwall.shared.reset()` on logout. `userId` **must be a valid UUID** (StoreKit
|
|
273
|
+
compat) and must not be an email, device id, or guessable value.
|
|
274
|
+
`curl -sL https://superwall.com/docs/ios/quickstart/user-management.md`
|
|
275
|
+
```swift
|
|
276
|
+
Superwall.shared.identify(userId: user.id)
|
|
277
|
+
Superwall.shared.reset() // on sign-out
|
|
278
|
+
```
|
|
279
|
+
- **User attributes** - target audiences / fill paywall variables.
|
|
280
|
+
`curl -sL https://superwall.com/docs/ios/quickstart/setting-user-properties.md`
|
|
281
|
+
```swift
|
|
282
|
+
Superwall.shared.setUserAttributes(["email": user.email, "plan": "trial"])
|
|
283
|
+
// pass nil to unset a key (Swift only)
|
|
284
|
+
```
|
|
285
|
+
- **Tracking subscription state** - read `Superwall.shared.subscriptionStatus`
|
|
286
|
+
(or `.isActive`); observe changes via the delegate's
|
|
287
|
+
`subscriptionStatusDidChange(from:to:)`.
|
|
288
|
+
`curl -sL https://superwall.com/docs/ios/quickstart/tracking-subscription-state.md`
|
|
289
|
+
- **Deep links** - pass incoming URLs to `Superwall.handleDeepLink(url)`; it fires
|
|
290
|
+
the `deepLink_open` placement so routing is dashboard-driven.
|
|
291
|
+
`curl -sL https://superwall.com/docs/ios/guides/handling-deep-links.md`
|
|
292
|
+
- **3rd-party analytics** - forward Superwall events to your analytics via the
|
|
293
|
+
delegate. `curl -sL https://superwall.com/docs/ios/guides/3rd-party-analytics.md`
|
|
294
|
+
|
|
295
|
+
## Pitfalls
|
|
296
|
+
|
|
297
|
+
- **CocoaPods build failure** → **User Script Sandboxing = No** in Build Settings.
|
|
298
|
+
- **`.pbxproj` hand-edits with Xcode open** → Xcode overwrites them; close Xcode or use the UI.
|
|
299
|
+
- **Configured but paywalls never show** → `subscriptionStatus` stuck at `.unknown`
|
|
300
|
+
(only when you use a `PurchaseController` - you must set it), or no placement yet
|
|
301
|
+
(that's the placements skill).
|
|
302
|
+
- **Configuring more than once / not at launch** → configure exactly once in
|
|
303
|
+
`App.init()` or `didFinishLaunchingWithOptions`, not in a view body.
|
|
304
|
+
- **Secret key** → the key must start with `pk_`; a secret key fails config.
|
|
305
|
+
|
|
306
|
+
## Deeper docs
|
|
307
|
+
|
|
308
|
+
- Index: `curl -sL https://superwall.com/docs/ios/llms.txt`
|
|
309
|
+
- Install: https://superwall.com/docs/ios/quickstart/install
|
|
310
|
+
- Configure: https://superwall.com/docs/ios/quickstart/configure
|
|
311
|
+
- Advanced purchasing / PurchaseController: https://superwall.com/docs/ios/guides/advanced-configuration
|
|
312
|
+
- Using RevenueCat: https://superwall.com/docs/ios/guides/using-revenuecat
|
|
313
|
+
- StoreKit testing: https://superwall.com/docs/ios/guides/testing-purchases
|
|
314
|
+
- SDK reference: https://superwall.com/docs/ios/sdk-reference/Superwall
|
|
@@ -0,0 +1,83 @@
|
|
|
1
|
+
# Integrate the Superwall SDK
|
|
2
|
+
|
|
3
|
+
Get Superwall installed and configured with the smallest, cleanest set of edits.
|
|
4
|
+
Placements (paywall triggers) are a **separate step** - do not add `register()` /
|
|
5
|
+
`registerPlacement()` calls or example "Go Premium" buttons here. After this skill
|
|
6
|
+
succeeds, use the **superwall-placements** skill to add triggers.
|
|
7
|
+
|
|
8
|
+
## Docs access
|
|
9
|
+
|
|
10
|
+
Superwall's docs are fetchable **as markdown** - always prefer fetching the current
|
|
11
|
+
page over relying on memory:
|
|
12
|
+
|
|
13
|
+
```bash
|
|
14
|
+
curl -sL https://superwall.com/docs/llms.txt # index: discover any doc path
|
|
15
|
+
curl -sL https://superwall.com/docs/llms-full.txt # broad context across all SDKs
|
|
16
|
+
curl -sL https://superwall.com/docs/{path}.md # any page as markdown (append .md)
|
|
17
|
+
```
|
|
18
|
+
|
|
19
|
+
Each SDK also has its own index - `curl -sL https://superwall.com/docs/{ios|android|expo|react-native|flutter}/llms.txt`.
|
|
20
|
+
Fetch the index to find the slug, then fetch `{path}.md`. Every reference file
|
|
21
|
+
below embeds the exact `curl` at each step so you can pull current detail when the
|
|
22
|
+
baked-in steps aren't enough. **Never invent an API** - if a symbol isn't in a
|
|
23
|
+
reference or a page you fetched, fetch and confirm.
|
|
24
|
+
|
|
25
|
+
## Principles
|
|
26
|
+
|
|
27
|
+
- Make the smallest set of edits that yields a working, verifiable integration.
|
|
28
|
+
Don't refactor or reformat unrelated code.
|
|
29
|
+
- **Read a file before editing it**; match its existing style and conventions.
|
|
30
|
+
- **Detect the package manager / build system** from the project (lockfiles,
|
|
31
|
+
`Podfile`, `app.json`, `pubspec.yaml`, `Package.swift`) - never assume
|
|
32
|
+
npm/yarn/pnpm/bun/CocoaPods/SPM.
|
|
33
|
+
- **Never invent an API key.** Use the exact public key you were given (it starts
|
|
34
|
+
with `pk_`). Never commit a secret. The public key may be inlined where the
|
|
35
|
+
platform conventionally does so (e.g. iOS `configure()`); otherwise use the
|
|
36
|
+
platform's standard env/config mechanism.
|
|
37
|
+
- **Never invent an API.** Every symbol you write must come from the reference
|
|
38
|
+
file or the linked docs. If the docs are ambiguous, say so and link the page.
|
|
39
|
+
- Configure **once, at app launch**, as early in the launch path as possible.
|
|
40
|
+
|
|
41
|
+
## Steps
|
|
42
|
+
|
|
43
|
+
1. **Detect the framework** from the project files:
|
|
44
|
+
|
|
45
|
+
| Signal in the project | Framework | Read this reference |
|
|
46
|
+
| ------------------------------------------------------------- | ------------------- | ---------------------------- |
|
|
47
|
+
| `*.xcodeproj` / `Package.swift` / `*.swift`, no JS | iOS / Swift | `ios.md` (beside this file) |
|
|
48
|
+
| `app.json`/`app.config.js` with an `expo` key, `expo` in deps | Expo | `expo.md` (beside this file) |
|
|
49
|
+
| `package.json` with `react-native`, no `expo` config | React Native (bare) | `react-native.md` (beside this file) |
|
|
50
|
+
| `pubspec.yaml` | Flutter | `flutter.md` (beside this file) |
|
|
51
|
+
| `build.gradle(.kts)` applying `com.android.application` | Android (Kotlin) | `android.md` (beside this file) |
|
|
52
|
+
|
|
53
|
+
If both Expo and bare RN signals exist, treat it as **Expo**. If unsure, ask.
|
|
54
|
+
|
|
55
|
+
2. **Read `<framework>.md` beside this file and follow it exactly.** Each reference is a
|
|
56
|
+
complete, verified playbook: install, configure, API key handling, verify,
|
|
57
|
+
pitfalls, and doc links.
|
|
58
|
+
|
|
59
|
+
3. **Pick the purchase-handling path** (covered in each reference):
|
|
60
|
+
- **No existing IAP system** → default. No `PurchaseController`; Superwall
|
|
61
|
+
manages purchases, restoration, and subscription state.
|
|
62
|
+
- **RevenueCat / Adapty / Qonversion / custom StoreKit already present** →
|
|
63
|
+
implement a `PurchaseController` and keep `subscriptionStatus` in sync with
|
|
64
|
+
your source of truth. (For a full migration off another SDK, use the
|
|
65
|
+
**superwall-migrate** skill.)
|
|
66
|
+
|
|
67
|
+
## What else belongs in Superwall
|
|
68
|
+
|
|
69
|
+
While reading the app, note any screen the user would rather change
|
|
70
|
+
without a release: a paywall or offer, onboarding, an update-required or
|
|
71
|
+
force-upgrade screen, a rate-us or notifications prompt, an announcement,
|
|
72
|
+
a consent change. Mention them in your closing note as candidates for a
|
|
73
|
+
Superwall surface (`superwall create` in the app, built with the
|
|
74
|
+
`superwall-framework` skill) behind a placement. Don't build them here;
|
|
75
|
+
the placements step wires the triggers and the framework skill builds the
|
|
76
|
+
screens.
|
|
77
|
+
|
|
78
|
+
## Definition of done
|
|
79
|
+
|
|
80
|
+
1. SDK installed and resolving (pods/SPM/gradle/pub resolved).
|
|
81
|
+
2. Superwall configured exactly once at launch with the provided public `pk_` key.
|
|
82
|
+
3. If a build command exists, build to verify it compiles.
|
|
83
|
+
4. No placements added - that is the placements step.
|
|
@@ -0,0 +1,246 @@
|
|
|
1
|
+
# Integrate Superwall - React Native (bare, non-Expo)
|
|
2
|
+
|
|
3
|
+
You are integrating Superwall into a **bare** React Native app (no Expo config).
|
|
4
|
+
Get the SDK installed and configured. **Do not add paywall triggers** - that is the
|
|
5
|
+
separate **superwall-placements** skill.
|
|
6
|
+
|
|
7
|
+
> **Important - which SDK:** Superwall's recommended SDK for React Native is now
|
|
8
|
+
> **`expo-superwall`**, installed into bare RN via Expo modules (**Path A**). The
|
|
9
|
+
> standalone **`@superwall/react-native-superwall`** is **deprecated** (**Path B**,
|
|
10
|
+
> kept only for existing setups). Default to Path A. Use Path B only if the project
|
|
11
|
+
> cannot add Expo modules or is already on the legacy SDK.
|
|
12
|
+
|
|
13
|
+
**Requirements (Path A):** React Native **0.79+**, Node **18+**, iOS deployment
|
|
14
|
+
target **15.1+**, Android **minSdkVersion 21+**.
|
|
15
|
+
|
|
16
|
+
## Checklist
|
|
17
|
+
|
|
18
|
+
- [ ] **0. Decide the purchase-handling path** (default / RevenueCat / custom).
|
|
19
|
+
- [ ] **0b. Pick the SDK** - Path A (`expo-superwall`, default) or Path B (legacy).
|
|
20
|
+
- [ ] **1. Install** the SDK + native deps (pods / gradle).
|
|
21
|
+
- [ ] **2. Configure** at launch with per-platform `pk_` keys.
|
|
22
|
+
- [ ] **3. API keys** branched on platform (public keys, never secrets).
|
|
23
|
+
- [ ] **4. Purchase handling** for the chosen path.
|
|
24
|
+
- [ ] **5. Native rebuild** (not just a Metro reload) - module links.
|
|
25
|
+
- [ ] **6. Run** - native logs show Superwall startup.
|
|
26
|
+
- [ ] **7. Post-integration** (identity, attributes, subscription state, deep links, analytics), then → **superwall-placements**.
|
|
27
|
+
|
|
28
|
+
## Docs access - read the current page when baked steps aren't enough
|
|
29
|
+
|
|
30
|
+
```bash
|
|
31
|
+
curl -sL https://superwall.com/docs/expo/llms.txt # Path A docs (expo-superwall) live here
|
|
32
|
+
curl -sL https://superwall.com/docs/react-native/llms.txt # Path B legacy SDK reference
|
|
33
|
+
curl -sL https://superwall.com/docs/llms-full.txt # broad context
|
|
34
|
+
curl -sL https://superwall.com/docs/expo/guides/using-expo-sdk-in-bare-react-native.md
|
|
35
|
+
```
|
|
36
|
+
|
|
37
|
+
Pattern: fetch the index, then `https://superwall.com/docs/{sdk}/{path}.md`. Every
|
|
38
|
+
`curl` here is verified working. **Path A uses the Expo docs** - the hooks/provider
|
|
39
|
+
API (`SuperwallProvider`, `useUser`) is documented under `/docs/expo/…`. **Never
|
|
40
|
+
invent an API**; fetch and confirm.
|
|
41
|
+
|
|
42
|
+
## Quickstart walk
|
|
43
|
+
|
|
44
|
+
Path A follows the **Expo** quickstart. Path B uses the (deprecated) react-native
|
|
45
|
+
SDK reference.
|
|
46
|
+
|
|
47
|
+
| Order | Path A slug (Expo docs) | Covered by |
|
|
48
|
+
| ----- | ------------------------------------------------- | --------------- |
|
|
49
|
+
| 1 | `expo/guides/using-expo-sdk-in-bare-react-native` | Step 1 (Path A) |
|
|
50
|
+
| 2 | `expo/quickstart/configure` | Step 2 |
|
|
51
|
+
| 3 | `expo/quickstart/setting-user-properties` | Step 7 |
|
|
52
|
+
| 4 | `expo/quickstart/tracking-subscription-state` | Step 7 |
|
|
53
|
+
| 5 | `expo/quickstart/user-management` | Step 7 |
|
|
54
|
+
|
|
55
|
+
Path B reference: `curl -sL https://superwall.com/docs/react-native/llms.txt`
|
|
56
|
+
|
|
57
|
+
## Step 0 - Purchase-handling path (decide first)
|
|
58
|
+
|
|
59
|
+
> **Important:** Paths (b)/(c) require manual subscription-status management; (a) doesn't.
|
|
60
|
+
|
|
61
|
+
- **(a) Default - Superwall handles StoreKit/Billing.** Recommended, zero purchase code.
|
|
62
|
+
- **(b) RevenueCat stays the source of truth.** Keep RC purchasing; sync entitlements in.
|
|
63
|
+
- **(c) Custom purchase controller.** Supply a `PurchaseController`, drive status.
|
|
64
|
+
|
|
65
|
+
Full migration off another SDK → **superwall-migrate** skill.
|
|
66
|
+
|
|
67
|
+
---
|
|
68
|
+
|
|
69
|
+
## Path A - `expo-superwall` in bare React Native (recommended)
|
|
70
|
+
|
|
71
|
+
### 1. Install
|
|
72
|
+
|
|
73
|
+
Add Expo modules support to the bare project (the Superwall-documented way to
|
|
74
|
+
consume `expo-superwall` without full Expo):
|
|
75
|
+
|
|
76
|
+
```bash
|
|
77
|
+
curl -sL https://superwall.com/docs/expo/guides/using-expo-sdk-in-bare-react-native.md
|
|
78
|
+
npx -y install-expo-modules@0.16.0
|
|
79
|
+
```
|
|
80
|
+
|
|
81
|
+
Install the SDK with the project's package manager (detect from lockfile):
|
|
82
|
+
|
|
83
|
+
```bash
|
|
84
|
+
npm install expo-superwall
|
|
85
|
+
# or: yarn add expo-superwall / pnpm add expo-superwall / bun add expo-superwall
|
|
86
|
+
```
|
|
87
|
+
|
|
88
|
+
Install iOS pods, ensure Android mins:
|
|
89
|
+
|
|
90
|
+
```bash
|
|
91
|
+
cd ios && pod install
|
|
92
|
+
```
|
|
93
|
+
|
|
94
|
+
`android/app/build.gradle`: `minSdkVersion 21`+ (with `compileSdkVersion` /
|
|
95
|
+
`targetSdkVersion` 34).
|
|
96
|
+
|
|
97
|
+
### 2. Configure
|
|
98
|
+
|
|
99
|
+
Wrap the app root in `SuperwallProvider` with per-platform public keys:
|
|
100
|
+
|
|
101
|
+
```tsx
|
|
102
|
+
import { SuperwallProvider } from "expo-superwall";
|
|
103
|
+
|
|
104
|
+
export default function App() {
|
|
105
|
+
return (
|
|
106
|
+
<SuperwallProvider
|
|
107
|
+
apiKeys={{ ios: "pk_YOUR_IOS_PUBLIC_KEY", android: "pk_YOUR_ANDROID_PUBLIC_KEY" }}
|
|
108
|
+
>
|
|
109
|
+
{/* your existing app tree */}
|
|
110
|
+
</SuperwallProvider>
|
|
111
|
+
);
|
|
112
|
+
}
|
|
113
|
+
```
|
|
114
|
+
|
|
115
|
+
`SuperwallProvider` configures the SDK on mount - **do not** also call a separate
|
|
116
|
+
`configure()`. Optional behavior goes through the `options` prop.
|
|
117
|
+
|
|
118
|
+
Path A shares the Expo API. Skip to **API key handling**, **Purchase handling**,
|
|
119
|
+
**Post-integration** - they apply to both paths (Path A uses the hooks form).
|
|
120
|
+
|
|
121
|
+
---
|
|
122
|
+
|
|
123
|
+
## Path B - legacy `@superwall/react-native-superwall`
|
|
124
|
+
|
|
125
|
+
Use only if you cannot add Expo modules, or the project already uses this SDK.
|
|
126
|
+
|
|
127
|
+
### 1. Install
|
|
128
|
+
|
|
129
|
+
```bash
|
|
130
|
+
npm install @superwall/react-native-superwall
|
|
131
|
+
# or: yarn add @superwall/react-native-superwall
|
|
132
|
+
cd ios && pod install
|
|
133
|
+
```
|
|
134
|
+
|
|
135
|
+
Android autolinks - no extra native step beyond a normal build.
|
|
136
|
+
|
|
137
|
+
### 2. Configure
|
|
138
|
+
|
|
139
|
+
Import the default export and call `Superwall.configure` once at launch (root
|
|
140
|
+
component's `useEffect` with empty deps). The public key is per-platform:
|
|
141
|
+
|
|
142
|
+
```tsx
|
|
143
|
+
import { useEffect } from "react";
|
|
144
|
+
import { Platform } from "react-native";
|
|
145
|
+
import Superwall from "@superwall/react-native-superwall";
|
|
146
|
+
|
|
147
|
+
export default function App() {
|
|
148
|
+
useEffect(() => {
|
|
149
|
+
const apiKey = Platform.OS === "ios" ? "pk_YOUR_IOS_PUBLIC_KEY" : "pk_YOUR_ANDROID_PUBLIC_KEY";
|
|
150
|
+
Superwall.configure({ apiKey });
|
|
151
|
+
}, []);
|
|
152
|
+
|
|
153
|
+
return (/* your app */);
|
|
154
|
+
}
|
|
155
|
+
```
|
|
156
|
+
|
|
157
|
+
Full signature: `Superwall.configure({ apiKey, options?, purchaseController?, completion? })`
|
|
158
|
+
(returns a Promise resolving to the configured instance, also at `Superwall.shared`).
|
|
159
|
+
`curl -sL https://superwall.com/docs/react-native/sdk-reference/configure.md`
|
|
160
|
+
|
|
161
|
+
---
|
|
162
|
+
|
|
163
|
+
## API key handling (both paths)
|
|
164
|
+
|
|
165
|
+
Use the **Public API Key(s)** (`pk_…`) from Dashboard ▸ Settings ▸ Keys - iOS and
|
|
166
|
+
Android apps have separate keys, so branch on platform. Public keys aren't secrets;
|
|
167
|
+
inline them, or read from existing config (`react-native-config`). **Never** use a
|
|
168
|
+
secret/server key.
|
|
169
|
+
|
|
170
|
+
## Purchase handling (both paths - implements Step 0)
|
|
171
|
+
|
|
172
|
+
### (a) Default
|
|
173
|
+
|
|
174
|
+
Nothing extra - Superwall manages purchases, restores, and subscription status.
|
|
175
|
+
|
|
176
|
+
### (b) RevenueCat / (c) custom
|
|
177
|
+
|
|
178
|
+
Subclass `PurchaseController` and implement `purchaseFromAppStore(productId)`,
|
|
179
|
+
`purchaseFromGooglePlay(productId, basePlanId?, offerId?)`, `restorePurchases()`;
|
|
180
|
+
pass it at configure time. Read the page first - **do not invent method names**:
|
|
181
|
+
|
|
182
|
+
```bash
|
|
183
|
+
curl -sL https://superwall.com/docs/expo/guides/advanced-configuration.md
|
|
184
|
+
```
|
|
185
|
+
|
|
186
|
+
```tsx
|
|
187
|
+
export class MyPurchaseController extends PurchaseController {
|
|
188
|
+
async purchaseFromAppStore(productId: string): Promise<PurchaseResult> { /* ... */ }
|
|
189
|
+
async purchaseFromGooglePlay(
|
|
190
|
+
productId: string, basePlanId?: string, offerId?: string
|
|
191
|
+
): Promise<PurchaseResult> { /* ... */ }
|
|
192
|
+
async restorePurchases(): Promise<RestorationResult> { /* ... */ }
|
|
193
|
+
}
|
|
194
|
+
```
|
|
195
|
+
|
|
196
|
+
> **Important (paths b & c):** keep subscription status synced whenever entitlements
|
|
197
|
+
> change. Path A (hooks): `const { setSubscriptionStatus } = useUser();
|
|
198
|
+
setSubscriptionStatus({ status: "ACTIVE", entitlements: [{ id: "pro" }] })`.
|
|
199
|
+
> Shared instance:
|
|
200
|
+
> `Superwall.shared.setSubscriptionStatus(SubscriptionStatus.Active([new Entitlement("pro")]))`
|
|
201
|
+
> / `SubscriptionStatus.Inactive()`. For (b), map RevenueCat's active entitlements in.
|
|
202
|
+
|
|
203
|
+
## Verify (both paths)
|
|
204
|
+
|
|
205
|
+
1. **Native rebuild** & run: `./node_modules/.bin/react-native run-ios` / `run-android`.
|
|
206
|
+
Run from the app root after installing its lockfile dependencies. Path A must
|
|
207
|
+
relink the native module - rebuild, don't just reload JS.
|
|
208
|
+
2. Watch native logs on launch for Superwall SDK startup.
|
|
209
|
+
3. iOS purchase testing: StoreKit testing in Xcode.
|
|
210
|
+
|
|
211
|
+
## Post-integration (wire what the app needs, then → placements)
|
|
212
|
+
|
|
213
|
+
Path A uses the `useUser` hook; Path B uses static `Superwall` methods.
|
|
214
|
+
|
|
215
|
+
- **User identity - REQUIRED if the app has ANY auth/login system.** Not optional: without it every logged-in user is anonymous to Superwall, breaking user-scoped audiences, attribution, and cross-device status. Wire it the moment you see a login/logout flow (grep for signIn/login/logout/signOut/auth). Path A: `const { identify, signOut } = useUser()`. Path B:
|
|
216
|
+
`Superwall.shared.identify(userId)` / `Superwall.shared.reset()`. `userId` should
|
|
217
|
+
be a **UUID** (StoreKit compat), never an email/device id/guessable value.
|
|
218
|
+
`curl -sL https://superwall.com/docs/expo/quickstart/user-management.md`
|
|
219
|
+
- **User attributes** - `setUserAttributes(...)`.
|
|
220
|
+
`curl -sL https://superwall.com/docs/expo/quickstart/setting-user-properties.md`
|
|
221
|
+
- **Tracking subscription state** - Path A: `subscriptionStatus` from `useUser`
|
|
222
|
+
(`status` = `"ACTIVE" | "INACTIVE" | "UNKNOWN"`).
|
|
223
|
+
`curl -sL https://superwall.com/docs/expo/quickstart/tracking-subscription-state.md`
|
|
224
|
+
- **Deep links** - pass URLs to `handleDeepLink`; fires the `deepLink_open` placement.
|
|
225
|
+
`curl -sL https://superwall.com/docs/expo/guides/handling-deep-links.md`
|
|
226
|
+
- **3rd-party analytics** - forward events (Path A: `useSuperwallEvents`).
|
|
227
|
+
`curl -sL https://superwall.com/docs/expo/guides/3rd-party-analytics.md`
|
|
228
|
+
|
|
229
|
+
## Pitfalls
|
|
230
|
+
|
|
231
|
+
- **iOS module not found / link errors** → `cd ios && pod install`, then a full
|
|
232
|
+
native rebuild (not just Metro reload).
|
|
233
|
+
- **Reached for the wrong SDK** → prefer Path A (`expo-superwall`); the standalone
|
|
234
|
+
`@superwall/react-native-superwall` is deprecated.
|
|
235
|
+
- **Path A native module missing** → `npx -y install-expo-modules@0.16.0` must succeed
|
|
236
|
+
before `pod install`; rebuild afterward.
|
|
237
|
+
- **Configuring on every render** → Path B: wrap `configure` in `useEffect(..., [])`.
|
|
238
|
+
- **Secret key** → key must start with `pk_`.
|
|
239
|
+
|
|
240
|
+
## Deeper docs
|
|
241
|
+
|
|
242
|
+
- Bare RN install guide (Path A): https://superwall.com/docs/expo/guides/using-expo-sdk-in-bare-react-native
|
|
243
|
+
- Migrating from the legacy SDK: https://superwall.com/docs/expo/guides/migrating-react-native
|
|
244
|
+
- Legacy `configure()` (Path B): https://superwall.com/docs/react-native/sdk-reference/configure
|
|
245
|
+
- React Native SDK reference index: `curl -sL https://superwall.com/docs/react-native/llms.txt`
|
|
246
|
+
- Expo docs index (applies to Path A): `curl -sL https://superwall.com/docs/expo/llms.txt`
|