-
Notifications
You must be signed in to change notification settings - Fork 795
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
How to deal with auto-renewable subscription? #174
Comments
@gerchicov-bp apologies for the late reply. This snippet summarises how to:
let productId = "your-product-id"
SwiftyStoreKit.purchaseProduct(productId, atomically: true) { result in
if case .success(let product) = result {
// Deliver content from server, then:
if product.needsFinishTransaction {
SwiftyStoreKit.finishTransaction(product.transaction)
}
let appleValidator = AppleReceiptValidator(service: .production)
SwiftyStoreKit.verifyReceipt(using: appleValidator, password: "your-shared-secret") { result in
if case .success(let receipt) = result {
let purchaseResult = SwiftyStoreKit.verifySubscription(
type: .autoRenewable,
productId: productId,
inReceipt: receipt)
switch purchaseResult {
case .purchased(let expiryDate):
print("Product is valid until \(expiryDate)")
case .expired(let expiryDate):
print("Product is expired since \(expiryDate)")
case .notPurchased:
print("This product has never been purchased")
}
} else {
// receipt verification error
}
}
} else {
// purchase error
}
} This is a combination of the Purchase and Verify Subscription methods. As requested, I have updated the documentation in the README: #189 |
@gerchicov-bp Suggested Read: |
Documentation further improved on #213. |
@bizz84 How to handle it for restored? Please correct me if I am wrong. I really need a way to handle restore process on auto-renewable subscription. And I only find documentation for restore provided only for consumable. Any Help? |
Do you just need to check if an auto-renewable subscription is valid? If so, this is all you need: https://github.com/bizz84/SwiftyStoreKit#verify-subscription |
@htarwara6245 you can information about all previously purchased non-consumable purchases and subscriptions by verifying the receipt, even if the user reinstalled the app. In your case, you can verify an auto-renewable subscription as explained in the README. Closing this issue. |
My code keeps going to the |
Need to update a readme file.
Current readme just describes how to send a purchase request.
How to handle result? How to renew it? Does sandbox users' behaviour differs from real one?
The text was updated successfully, but these errors were encountered: