From bbb96fd1384ad05f176290b5b814d9e7c21f8a5f Mon Sep 17 00:00:00 2001 From: Armin Dervisagic Date: Thu, 7 May 2026 17:58:32 +0700 Subject: [PATCH] Updated migration support doc with info on how to sync back user attributes --- ...ate-from-another-provider-to-superwall.mdx | 58 +++++++++++++++++++ 1 file changed, 58 insertions(+) diff --git a/content/docs/support/faq/how-to-migrate-from-another-provider-to-superwall.mdx b/content/docs/support/faq/how-to-migrate-from-another-provider-to-superwall.mdx index f4b50c09..1134c9c3 100644 --- a/content/docs/support/faq/how-to-migrate-from-another-provider-to-superwall.mdx +++ b/content/docs/support/faq/how-to-migrate-from-another-provider-to-superwall.mdx @@ -34,6 +34,64 @@ When a user opens your app with the new Superwall SDK, their active subscription | A/B test history and experiment data | ❌ No | | Custom user attributes from previous SDK | ❌ No - must be re-set via Superwall SDK | +## Re-setting Custom User Attributes + +Superwall reads subscription state directly from Apple and Google, so transaction history does not need to be migrated. Your own user metadata can be added as user attributes. The original transaction ID is a stable key that bridges a returning subscriber back to their record in your backend. + +The flow: + + + +### Read the original transaction ID on device + +On iOS, use StoreKit 2's `Transaction.currentEntitlements` and read `transaction.originalID`. On Android, use the Play Billing `purchaseToken`. + +```swift +import StoreKit + +func fetchOriginalTransactionID() async -> String? { + for await result in Transaction.currentEntitlements { + guard case .verified(let transaction) = result else { continue } + return String(transaction.originalID) + } + return nil +} +``` + +### Look up the user in your backend + +Send the original transaction ID to your backend, which returns a stable `userId` and any metadata you want exposed to Superwall (plan tier, signup date, referrer, etc.). + +### Identify, then set attributes + +Call `identify` first so the attributes attach to the right user. + +```swift +Superwall.shared.identify(userId: userId) +Superwall.shared.setUserAttributes([ + "plan_tier": "pro", + "signup_date": "2024-01-15", + "referrer": "appstore_search" +]) +``` + + + + +`setUserAttributes` merges with existing attributes rather than replacing them. Pass `nil` for a key to remove it. + + + +A few things to watch for: + +- Always call `identify` before `setUserAttributes`, otherwise attributes attach to the anonymous user. +- On a fresh install before a restore, `currentEntitlements` may be empty. +- Sandbox and production original transaction IDs differ. +- With Family Sharing, the original transaction ID belongs to the original purchaser, not the family member. + + +Run this on app launch (after StoreKit hydrates), after a successful purchase, and after a restore. It is safe to call every launch since `identify` is idempotent. + ## Migration Steps 1. Remove your current subscription SDK from your project