5

Does anyone know the easy way to check if the user already purchased a subscription or not when the app loads?

I just need to check if the user already purchased the subscription, nothing else. Seems easy, but it is not in reality, because I need to validate a receipt and check a subscription date.... The subscription validation technique seems to be not an easy task and I didn't find a good tutorial or a good guide that describes how to implement it step by step. I've read Apple documentation here Is there any easy Local Receipt Validation and Subscription Validation technique to check if the user subscribed or not?

Maybe anyone knows a framework or a method to do it fast? Any help appreciated.

Using: Swift 4, Xcode 9.4

Adelmaer
  • 2,209
  • 3
  • 22
  • 45
  • You can follow this. https://www.youtube.com/watch?v=o3hJ0rY1NNw&t=2280s and https://www.raywenderlich.com/5456-in-app-purchase-tutorial-getting-started – Rob Aug 24 '18 at 14:48
  • 2
    Thanks Rob, but these tutorials only show how to implement In-App Purchase. I know how to do that. I'm interested in how to check the status of a subscription without using User Defaults. Local receipt validation and subscription validation to check if the user purchased it or not – Adelmaer Aug 24 '18 at 14:54

2 Answers2

2

The RevenueCat SDK provides a good out-of-the box solution for this.

More than a couple reasons why I like this approach:

  • Validates receipt server side (without requiring me to set up a server)
  • Checks for an "active" subscription with a server timestamp so can't be spoofed by changing the device clock
  • Caches the result so it's super fast and works offline

There's some more details in this question: https://stackoverflow.com/a/55404121/3166209

Which boils down to:

subscriptionStatus { (subscribed) in
    if subscribed {
        // Show that great pro content
    }
}
Gurpartap Singh
  • 2,744
  • 1
  • 26
  • 30
enc_life
  • 4,973
  • 1
  • 15
  • 27
1

Ok here is your answer. I have also followed this same tutorial and it helped me. I validated the receipt and confirmed that the payment is made. See the link below. Hope it helps.

In App Purchase in Swift, with Receipt Validation

Rob
  • 164
  • 1
  • 2
  • 12
  • 1
    Links to external resources are encouraged, but please add context around the link so your fellow users will have some idea what it is and why it’s there. Always quote the most relevant part of an important link, in case the target site is unreachable or goes permanently offline. – Paulw11 Aug 24 '18 at 20:03
  • 1
    link doesn't work – Eric May 30 '22 at 19:40
  • 404 - this is really good (not). – Kenny Jun 27 '22 at 17:19