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.
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.
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.
Purchases.configure(withAPIKey: "<your_api_key>", appUserID: "<my_app_user_id>", userDefaults: UserDefaults(suiteName: "group.your.bundle.here"))
Now the app extension and parent app can both use the a shared UserDefaults suite.
Updated 5 months ago