Auto Renewal Subscription deeply understanding
I'm implementing In-App Purchase with Auto-Renewal Subscriptions in my app using SwiftyStoreKit. I just need to understand some things.
First of all this is my code:
func verifyPurchase(product: SKProduct) {
NetworkAcivityIndicatorManager.NetworkOperationStaterd()
let appleValidator = AppleReceiptValidator(service: .sandbox, sharedSecret: SharedSecret)
SwiftyStoreKit.verifyReceipt(using: appleValidator) { (result) in
NetworkAcivityIndicatorManager.NetworkOperationFinished()
print("NEW IAP: Verify Purchase")
switch result {
case .success(receipt: let receipt):
if product.productIdentifier == self.bundleID + "." + RegisteredPurchases.Subscription.rawValue {
let purchaseResult: VerifySubscriptionResult = SwiftyStoreKit.verifySubscription(ofType: .autoRenewable, productId: product.productIdentifier, inReceipt: receipt, validUntil: Date())
print("NEW IAP: Verify Subscription: (purchaseResult)")
switch purchaseResult {
case .expired(let expiresDate):
print("NEW IAP: Expired: (expiresDate)")
case .purchased(let expiresDate):
print("NEW IAP: Purchased: (expiresDate)")
case .notPurchased:
print("NEW IAP: Not Purchased")
}
} else {
let purchaseResult = SwiftyStoreKit.verifyPurchase(productId: product.productIdentifier, inReceipt: receipt)
print("NEW IAP: Verify Purchase: (purchaseResult)")
}
case .error(let error):
print("NEW IAP: Verify Purchase: (error.localizedDescription)")
}
}
}
After purchasing for the first time, I've got 3 minutes (sandbox) before the receipt is expired, but what does it means on production? Do I need to renew the subscription or to do some action with it?
switch purchaseResult {
case .expired(let expiresDate):
print("NEW IAP: Expired: (expiresDate)")
case .purchased(let expiresDate):
print("NEW IAP: Purchased: (expiresDate)")
case .notPurchased:
print("NEW IAP: Not Purchased")
}
If the purchase result is purchased I don't need to do anything, if it's not purchased, I need to purchase it and if its expired I need to call refresh receipt? not to purchase it once again?
func refreshReceipt() {
SwiftyStoreKit.fetchReceipt(forceRefresh: true) { (result) in
print("NEW IAP: Receipt Refreshed: (result)")
}
}
swift
add a comment |
I'm implementing In-App Purchase with Auto-Renewal Subscriptions in my app using SwiftyStoreKit. I just need to understand some things.
First of all this is my code:
func verifyPurchase(product: SKProduct) {
NetworkAcivityIndicatorManager.NetworkOperationStaterd()
let appleValidator = AppleReceiptValidator(service: .sandbox, sharedSecret: SharedSecret)
SwiftyStoreKit.verifyReceipt(using: appleValidator) { (result) in
NetworkAcivityIndicatorManager.NetworkOperationFinished()
print("NEW IAP: Verify Purchase")
switch result {
case .success(receipt: let receipt):
if product.productIdentifier == self.bundleID + "." + RegisteredPurchases.Subscription.rawValue {
let purchaseResult: VerifySubscriptionResult = SwiftyStoreKit.verifySubscription(ofType: .autoRenewable, productId: product.productIdentifier, inReceipt: receipt, validUntil: Date())
print("NEW IAP: Verify Subscription: (purchaseResult)")
switch purchaseResult {
case .expired(let expiresDate):
print("NEW IAP: Expired: (expiresDate)")
case .purchased(let expiresDate):
print("NEW IAP: Purchased: (expiresDate)")
case .notPurchased:
print("NEW IAP: Not Purchased")
}
} else {
let purchaseResult = SwiftyStoreKit.verifyPurchase(productId: product.productIdentifier, inReceipt: receipt)
print("NEW IAP: Verify Purchase: (purchaseResult)")
}
case .error(let error):
print("NEW IAP: Verify Purchase: (error.localizedDescription)")
}
}
}
After purchasing for the first time, I've got 3 minutes (sandbox) before the receipt is expired, but what does it means on production? Do I need to renew the subscription or to do some action with it?
switch purchaseResult {
case .expired(let expiresDate):
print("NEW IAP: Expired: (expiresDate)")
case .purchased(let expiresDate):
print("NEW IAP: Purchased: (expiresDate)")
case .notPurchased:
print("NEW IAP: Not Purchased")
}
If the purchase result is purchased I don't need to do anything, if it's not purchased, I need to purchase it and if its expired I need to call refresh receipt? not to purchase it once again?
func refreshReceipt() {
SwiftyStoreKit.fetchReceipt(forceRefresh: true) { (result) in
print("NEW IAP: Receipt Refreshed: (result)")
}
}
swift
add a comment |
I'm implementing In-App Purchase with Auto-Renewal Subscriptions in my app using SwiftyStoreKit. I just need to understand some things.
First of all this is my code:
func verifyPurchase(product: SKProduct) {
NetworkAcivityIndicatorManager.NetworkOperationStaterd()
let appleValidator = AppleReceiptValidator(service: .sandbox, sharedSecret: SharedSecret)
SwiftyStoreKit.verifyReceipt(using: appleValidator) { (result) in
NetworkAcivityIndicatorManager.NetworkOperationFinished()
print("NEW IAP: Verify Purchase")
switch result {
case .success(receipt: let receipt):
if product.productIdentifier == self.bundleID + "." + RegisteredPurchases.Subscription.rawValue {
let purchaseResult: VerifySubscriptionResult = SwiftyStoreKit.verifySubscription(ofType: .autoRenewable, productId: product.productIdentifier, inReceipt: receipt, validUntil: Date())
print("NEW IAP: Verify Subscription: (purchaseResult)")
switch purchaseResult {
case .expired(let expiresDate):
print("NEW IAP: Expired: (expiresDate)")
case .purchased(let expiresDate):
print("NEW IAP: Purchased: (expiresDate)")
case .notPurchased:
print("NEW IAP: Not Purchased")
}
} else {
let purchaseResult = SwiftyStoreKit.verifyPurchase(productId: product.productIdentifier, inReceipt: receipt)
print("NEW IAP: Verify Purchase: (purchaseResult)")
}
case .error(let error):
print("NEW IAP: Verify Purchase: (error.localizedDescription)")
}
}
}
After purchasing for the first time, I've got 3 minutes (sandbox) before the receipt is expired, but what does it means on production? Do I need to renew the subscription or to do some action with it?
switch purchaseResult {
case .expired(let expiresDate):
print("NEW IAP: Expired: (expiresDate)")
case .purchased(let expiresDate):
print("NEW IAP: Purchased: (expiresDate)")
case .notPurchased:
print("NEW IAP: Not Purchased")
}
If the purchase result is purchased I don't need to do anything, if it's not purchased, I need to purchase it and if its expired I need to call refresh receipt? not to purchase it once again?
func refreshReceipt() {
SwiftyStoreKit.fetchReceipt(forceRefresh: true) { (result) in
print("NEW IAP: Receipt Refreshed: (result)")
}
}
swift
I'm implementing In-App Purchase with Auto-Renewal Subscriptions in my app using SwiftyStoreKit. I just need to understand some things.
First of all this is my code:
func verifyPurchase(product: SKProduct) {
NetworkAcivityIndicatorManager.NetworkOperationStaterd()
let appleValidator = AppleReceiptValidator(service: .sandbox, sharedSecret: SharedSecret)
SwiftyStoreKit.verifyReceipt(using: appleValidator) { (result) in
NetworkAcivityIndicatorManager.NetworkOperationFinished()
print("NEW IAP: Verify Purchase")
switch result {
case .success(receipt: let receipt):
if product.productIdentifier == self.bundleID + "." + RegisteredPurchases.Subscription.rawValue {
let purchaseResult: VerifySubscriptionResult = SwiftyStoreKit.verifySubscription(ofType: .autoRenewable, productId: product.productIdentifier, inReceipt: receipt, validUntil: Date())
print("NEW IAP: Verify Subscription: (purchaseResult)")
switch purchaseResult {
case .expired(let expiresDate):
print("NEW IAP: Expired: (expiresDate)")
case .purchased(let expiresDate):
print("NEW IAP: Purchased: (expiresDate)")
case .notPurchased:
print("NEW IAP: Not Purchased")
}
} else {
let purchaseResult = SwiftyStoreKit.verifyPurchase(productId: product.productIdentifier, inReceipt: receipt)
print("NEW IAP: Verify Purchase: (purchaseResult)")
}
case .error(let error):
print("NEW IAP: Verify Purchase: (error.localizedDescription)")
}
}
}
After purchasing for the first time, I've got 3 minutes (sandbox) before the receipt is expired, but what does it means on production? Do I need to renew the subscription or to do some action with it?
switch purchaseResult {
case .expired(let expiresDate):
print("NEW IAP: Expired: (expiresDate)")
case .purchased(let expiresDate):
print("NEW IAP: Purchased: (expiresDate)")
case .notPurchased:
print("NEW IAP: Not Purchased")
}
If the purchase result is purchased I don't need to do anything, if it's not purchased, I need to purchase it and if its expired I need to call refresh receipt? not to purchase it once again?
func refreshReceipt() {
SwiftyStoreKit.fetchReceipt(forceRefresh: true) { (result) in
print("NEW IAP: Receipt Refreshed: (result)")
}
}
swift
swift
asked Nov 23 at 7:34
Yossi Tsafar
2,54264192
2,54264192
add a comment |
add a comment |
active
oldest
votes
Your Answer
StackExchange.ifUsing("editor", function () {
StackExchange.using("externalEditor", function () {
StackExchange.using("snippets", function () {
StackExchange.snippets.init();
});
});
}, "code-snippets");
StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "1"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});
function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});
}
});
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53442399%2fauto-renewal-subscription-deeply-understanding%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
active
oldest
votes
active
oldest
votes
active
oldest
votes
active
oldest
votes
Thanks for contributing an answer to Stack Overflow!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Some of your past answers have not been well-received, and you're in danger of being blocked from answering.
Please pay close attention to the following guidance:
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53442399%2fauto-renewal-subscription-deeply-understanding%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown