Solved

Family subscription does not update CustomerInfo

  • 19 March 2022
  • 1 reply
  • 89 views

Badge +3

My iOS SwiftUI app has 2 subscription options: Individual and Family. The level of access is the same, the only difference is that Family enables family sharing.

Because the package length cannot be the same for multiple packages, I worked around it by having the Individual subscription on a RC standard Annual length, and Family subscription on a custom length (for more on that, see my other post).

Everything seemed to work fine, but recently (RC update?) I started having the following problem with the Family subscription.

When a user purchases a subscription, I expect the following subscriptionActive value to update, as per RC documentation and sample apps:

class UserViewModel: NSObject, ObservableObject {

   static let shared = UserViewModel()

  @Published var subscriptionActive: Bool = false

  @Published var customerInfo: CustomerInfo? {

      didSet {

        subscriptionActive = customerInfo?.entitlements[Constants.entitlementID]?.isActive == true

      }

  }

I could just check if subscriptionActive to control what content to show.

However, the value now ONLY updates when the Individual subscription is purchased (or restored). When the Family subscription is purchased (or restored), subscriptionActive remains FALSE, and the app subsequently behaves as if nothing was purchased. Meanwhile, the App Store sandbox account correctly shows the Family subscription.

Any ideas would be very helpful!

icon

Best answer by Jan Stehlik 19 March 2022, 14:34

View original

1 reply

Badge +3

Ok, after some testing, I found that the value actually does set! So after a bit more digging, I realized that Constants.entitlementID is a simple String that only contains the id of the Individual subscription entitlement. An easy fix added a second value for the family entitlement, and it now works. Yey!

Reply