iOS App Extensions
App Extensions in iOS are an important component of the iOS ecosystem that are supported by RevenueCat. The most popular use of App Extensions for subscription apps are Today Widgets and iMessage apps.
Even though you can configure the SDK, it's just read-only. Purchasing will not work because extensions don't have access to the parent's app Bundle and therefore can't extract the receipt after a purchase
Configuring for App Extensions
To enable data sharing between the main app and extensions, you'll need to use Xcode or the Developer portal to enable app groups for the containing app and its contained app extensions. Then, register the app group in the portal and specify the app group to use in the containing app. If you are building a Safari extension, you will need to configure and interact with the RevenueCat SDK in the Swift code, rather than in the Javascript code.
After you enable app groups, you will be able to access a user's active subscriptions in your App Extension by configuring Purchases with a custom UserDefaults that's shared across your App Extension.
- Swift
Purchases.configure(
with: Configuration.Builder(withAPIKey: <your_api_key)
.with(appUserID: <app_user_id>)
.with(userDefaults: .init(suiteName: <group.your.bundle.here>))
.build()
)
Now the app extension and parent app can both use the a shared UserDefaults suite.