Post

Replies

Boosts

Views

Activity

Reply to StoreKit2: .purchase() not working after expiry of subscription in app, but renewing in AppStore sandbox does...
Originally I used an example implementation at a Swift tutorial web site, replacing the store classes from that with the ones in Apple’s StoreKit 2 tutorial ( https://developer.apple.com/documentation/storekit/in-app_purchase/implementing_a_store_in_your_app_using_the_storekit_api ) and now the call to purchase() not popping a dialog is resolved. I’ve gone through the original code I used and this new code and cannot see anything that would make a difference but it works so I’m sticking with it. Perhaps it coincided with an OS update or something else and it’s just a coincidence it works now since I left it unresolved for awhile before coming back to work on it and didn’t bother retesting that the old code still failed. Only issue now is it’s working except when the subscription expires, the listener isn’t always fired right away (including in Test Flight) so I am now polling the current entitlements list every hour to check if an expiry occurred. Note if you do polling like this you need to account for your app being backgrounded and make sure you’re checking every X minutes based on wall clock time, not app run time, otherwise you might not catch an expiry until way afterwards.
Topic: App & System Services SubTopic: StoreKit Tags:
May ’23
Reply to StoreKit2: .purchase() not working after expiry of subscription in app, but renewing in AppStore sandbox does...
Switching products that I am attempting to purchase doesn't solve it either for me, still returns success & verified showing older times I bought when testing, which have expired as well. If I go in to AppStore -> Sandbox users and successfully buy a new subscription (which results in currentEntitlements now having valid entries as one would expect), the call to purchase() for that product (as if trying to buy it again during a valid subscription) returns (again without a dialog box popping up) showing a new expiry date in the future, as one would expect from a successful transaction. I'm guessing this is some sandbox weirdness.
Topic: App & System Services SubTopic: StoreKit Tags:
Jan ’23
Reply to StoreKit2: .purchase() not working after expiry of subscription in app, but renewing in AppStore sandbox does...
I'll be sending it to TestFlight soon to try if it works there, was hoping to sort it out before submitting! I forgot to add in my original post, the call to purchase() (which is NOT popping a confirmation to purchase dialog) is returning a successful and verified result....but, the expiry date on the transaction is in the past.... Note: I've XXXX'd out some fields that shouldn't be relevant. Ran this at 6:12 p.m (GMT/UTC) on January 13, 2023, so should be expired....which would explain why later on, in self.updatePurchasedProducts(), Transactions.currentEntitlements is empty. But still no idea why there's a successful transaction and no confirmation dialog in the first place! {   "bundleId" : "app.XXXXXXXXXXXXXXXXXX",   "deviceVerification" : "Y+Jlapp.XXXXXXXXXXXXXXXXXXJnwgU0qV7YMP6x\/I",   "deviceVerificationNonce" : "42e5c641-2a67-4815-b162-3c15515028ea",   "environment" : "Sandbox",   "expiresDate" : 1673556592000,   "inAppOwnershipType" : "PURCHASED",   "originalPurchaseDate" : 1673369053000,   "originalTransactionId" : "2000000246509209",   "productId" : "XXXXXXXXXXXXXXX",   "purchaseDate" : 1673554432000,   "quantity" : 1,   "signedDate" : 1673559083181,   "subscriptionGroupIdentifier" : "21XXXXXXXXXXXXXXXXXX3",   "transactionId" : "2000000248833618",   "type" : "Auto-Renewable Subscription",   "webOrderLineItemId" : "2000XXXXXXXXXXXXXXXXXX7" } Original Purchase Date: 2023-01-10 16:44:13 +0000   Purchase Date: 2023-01-12 20:13:52 +0000   Expiration Date: 2023-01-12 20:49:52 +0000   Signed Date: 2023-01-12 21:31:23 +0000   let result = try await product.purchase()         switch result {             case .success(let verificationResult):                 switch verificationResult {                     case .verified(let verifiedSuccessfulTransaction):     print(verifiedSuccessfulTransaction) print("Original Purchase Date: \(verifiedSuccessfulTransaction.originalPurchaseDate ?? Date(timeIntervalSince1970: 0) )  ") print("Purchase Date: \(verifiedSuccessfulTransaction.purchaseDate ?? Date(timeIntervalSince1970: 0) )  ") print("Expiration Date: \(verifiedSuccessfulTransaction.expirationDate ?? Date(timeIntervalSince1970: 0) )  ")                   print("Signed Date: \(verifiedSuccessfulTransaction.signedDate ?? Date(timeIntervalSince1970: 0) )  ")                          await verifiedSuccessfulTransaction.finish()       await self.updatePurchasedProducts()
Topic: App & System Services SubTopic: StoreKit Tags:
Jan ’23