I want to use the RevenueCat SDK in my iOS widgets. I tried to use it once before but our users were reporting that their widgets would randomly show “no subscription” (our UI when we determine the user doesn’t have a current subscription), so I commented out the RevenueCat specific code but now I want to try to add it back in.
The SDK notes say (https://www.revenuecat.com/docs/configuring-sdk):
“You should only configure Purchases once, usually early in your application lifecycle. After configuration, the same instance is shared throughout your app by accessing the .shared
instance in the SDK.”
However there doesn’t seem to be a good way to achieve this inside an iOS widget since getTimeline() can be called multiple times, I didn’t see another place where you can easily instantiate a singleton RevenueCat instance. I’m not sure if this multiple Purchases object issue was the cause of our previous issues where sometimes it was reported the user didn’t have a subscription even when they did, or if it was something else.
Is there some example code of where/how to safely use the RevenueCat SDK inside an iOS widget. We were using the 4.13.2 version of the SDK before but I just updated to the 4.25.2 latest version, so maybe that might fix it as well, not sure.
We were already using the shared app group for the widget before as documented in this link: https://www.revenuecat.com/docs/ios-app-extensions
Thanks
Mark.