Question

Purchases won't retrieve info on a watchOS app

  • 21 February 2022
  • 3 replies
  • 162 views

Badge +3

I’m trying to set up Purchases on a watchOS app which has a companion iOS app.

I thought I could consume a Swift package for multiple targets at the same time but as per this post on SO it’s not quite straightforward as I thought it would be.
I followed Diego Carrera’s solution and added the Purchases framework in the Watch extension like this:

General tab, and in Frameworks, Libraries and Embedded Content press +, select the package and press Add

This did the trick for me and on my Watch App Extension I can finally see the import Purchases option.
I also added a shared singleton class to manage Purchases’ delegate, both for the iOS and the watchOS app. There, I configure everything, set the delegate to self and retrieve the purchaser info.

This is all good if I run everything on the iOS app but when I do the same on my watch, Purchases won’t work and I get no information at all:

<PurchaserInfo
originalApplicationVersion: (null),
latestExpirationDate: (null)
activeEntitlements: {
},
activeSubscriptions: {
},
nonConsumablePurchases: {(
)},
requestDate: 2022-02-21 13:39:30 +0000
firstSeen: 2022-02-21 13:39:00 +0000,
originalAppUserId: $RCAnonymousID:ec49...,
entitlements: {
},
>

What am I doing wrong? Is this the right way to set up Purchases on WatchOS?

Thank you!

 

My specs:

MacOS Big Sur 11.6.2

Xcode: 13.2.1

Purchases: 3.14.1


3 replies

Userlevel 6
Badge +8

Hey @Alberto!

Could you try to set up the Purchases SDK using shared UserDefaults suite as detailed here? Seems like maybe the watch app and companion app are using different user IDs: https://docs.revenuecat.com/docs/ios-app-extensions

Badge +3

Hi @cody ,

Thank you for the answer.
I set up an App Group between the iOS app and the watch extension as detailed in the documentation but I still get no info:

Purchases.configure(
withAPIKey: "...",
appUserID: nil,
observerMode: false,
userDefaults: UserDefaults(suiteName: "group.myappbundleid")
)

I thought that App Groups were not meant to be used with watch apps because of this: modern versions of watchOS run your WatchKit extension on the Apple Watch. As such, you can’t share content between your iOS app and your WatchKit extension via an App Group.
In fact, I’m currently bypassing this issue by using the Watch Connectivity framework to pass data between the iOS app and the watch app but I’d like to make Purchases work in the watch. 

 

Badge +4

Hey @Alberto!

Could you try to set up the Purchases SDK using shared UserDefaults suite as detailed here? Seems like maybe the watch app and companion app are using different user IDs: https://docs.revenuecat.com/docs/ios-app-extensions

This does not work because app groups cannot be used to share data between main iOS app and the watch extension

Reply