Skip to main content
Question

Purchases won't retrieve info on a watchOS app

  • February 21, 2022
  • 3 replies
  • 191 views

Forum|alt.badge.img+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

This post has been closed for comments

3 replies

cody
RevenueCat Staff
Forum|alt.badge.img+8
  • RevenueCat Staff
  • 501 replies
  • March 4, 2022

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


Forum|alt.badge.img+3
  • Author
  • New Member
  • 1 reply
  • March 8, 2022

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. 

 


Forum|alt.badge.img+5
  • Member
  • 6 replies
  • March 23, 2022
cody wrote:

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


Cookie policy

We use cookies to enhance and personalize your experience. If you accept you agree to our full cookie policy. Learn more about our cookies.

 
Cookie settings