Open Yetispapa opened 6 years ago
Would like to know also.
This error appears when on a fresh install of the app with no receipt at all, you're trying to get that receipt, either from the iPhone or from the Apple servers, where there's no receipt as well, because you never bought anything. Make sure you handle this error.
I also have this issue. But I have it when I fetch receipt after successful purchase.
Same here. Apple reviewer has such an error after successful subscription. What can be wrong?
this issue still exists in release 0.15.0
in my case I got this error when :
Alert appears with title: Sign In to iTunes Store and message: Enter the password for your Apple ID. Cancel button pressed.
result received : FetchReceiptResult ▿ error : 1 element ▿ error : ReceiptError ▿ networkError : 1 element
error.localizedDescription "The operation couldn’t be completed. (SwiftyStoreKit.ReceiptError error 1.)"
I too have this issue, occurs when I try to verify receipt. Although it's fine for Me, only apple reviewer gets this each time. Does someone know what could be wrong or is this related to submitting our subscription. In appStoreConnect, my subscription is still showing "waiting for review".
SwiftyStoreKit.verifyReceipt(using: appleValidator) { result in ...
Same here in 0.16.0. Everything works fine on my device. But Apple rejected the build and sent the error screenshot.
Same here in 0.16.0. Everything works fine on my device. But Apple rejected the build and sent the error screenshot.
Do you know any alternative? Until these guys fix this?
Not found alternative solution yet.
Please let me know if you did. On Tue, 7 Jul 2020 at 14:20, cclaflin89 notifications@github.com wrote:
Not found alternative solution yet.
— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/bizz84/SwiftyStoreKit/issues/392#issuecomment-654700477, or unsubscribe https://github.com/notifications/unsubscribe-auth/AGIO2I6TKMSA5FIDF7CHYC3R2LOVJANCNFSM4FNPZNOQ .
I have also encountered this problem, but have been unable to find a solution, I hope to get help, thank you!
My app got rejected with the same error.
Update:
Something I noticed while reading this Apple document.
> Use the test environment URL https://sandbox.itunes.apple.com/verifyReceipt when testing your app in the sandbox and while your application is in review. Use the production URL https://buy.itunes.apple.com/verifyReceipt when your app is live in the App Store.
I wrote my code like this.
#if DEBUG
AppleReceiptValidator(service: .sandbox, sharedSecret: secret)
#else
AppleReceiptValidator(service: .production, sharedSecret: secret)
#endif
Since the app is technically a release build, it uses the production URL. But according to that article, while the app is in review, we should use the sandbox URL.
Could this be the issue?
If this is the case, we're at a dead-end when it comes to verifying receipts locally. Since there is no way to change the URLs within the app after the build is submitted, our only option is to go with the server-side validation, it seems.
Update 2:
Ignore my previous update. I found the real cause for the issue. See below.
I have used a different library to verify receipt, and for other operations such as purchase, I've used SSK.
My app is live!
I have used a different library to verify receipt, and for other operations such as purchase, I've used SSK.
My app is live!
Do you verify the receipts locally? What's the library you used?
Do you verify the receipts locally? What's the library you used?
I've used TPInAppReceipt Not a popular one, but works for now.
Do you verify the receipts locally? What's the library you used?
I've used TPInAppReceipt Not a popular one, but works for now.
Thanks :) btw I discovered something just now regarding this whilesifting through Apple docs. See my comment above. I updated it.
Thanks :) btw I discovered something just now regarding this whilesifting through Apple docs. See my comment above. I updated it.
Oh Cool! I've always given .production, will this "if else", fix it?
Thanks :) btw I discovered something just now regarding this whilesifting through Apple docs. See my comment above. I updated it.
Oh Cool! I've always given .production, will this "if else", fix it?
No, my code is what's causing the issue, I think. The if block runs while I'm in development, the if else block runs when the app is released. The problem is Apple requires us to still call the sandbox URL while the app is in review. Even though the app is technically a release build so it calls the production URL. This might be what's giving the error.
No, my code is what's causing the issue, I think. The if block runs while I'm in development, the if else block runs when the app is released. The problem is Apple requires us to still call the sandbox URL while the app is in review. Even though the app is technically a release build so it calls the production URL. This might be what's giving the error.
Ahh ok. Then I would recommend if you wanna quick fix for now, you can use this TPInApp receipt. As this library does not require the URL, and takes itself. Btw after using this lib, my app has been accepted. I'll attach the code snippet below!
No, my code is what's causing the issue, I think. The if block runs while I'm in development, the if else block runs when the app is released. The problem is Apple requires us to still call the sandbox URL while the app is in review. Even though the app is technically a release build so it calls the production URL. This might be what's giving the error.
Ahh ok. Then I would recommend if you wanna quick fix for now, you can use this TPInApp receipt. As this library does not require the URL, and takes itself. Btw after using this lib, my app has been accepted. I'll attach the code snippet below!
Thank you. I'll give this approach a try 👍🏼
No, my code is what's causing the issue, I think. The if block runs while I'm in development, the if else block runs when the app is released. The problem is Apple requires us to still call the sandbox URL while the app is in review. Even though the app is technically a release build so it calls the production URL. This might be what's giving the error.
Ahh ok. Then I would recommend if you wanna quick fix for now, you can use this TPInApp receipt. As this library does not require the URL, and takes itself. Btw after using this lib, my app has been accepted. I'll attach the code snippet below!
By the way, is local receipt validation ideal for auto-renewable subscriptions? Because I need to get the latest data like the expiration date. Do I have to refresh the receipt at every launch to get the most updated one?
By the way, is local receipt validation ideal for auto-renewable subscriptions? Because I need to get the latest data like the expiration date. Do I have to refresh the receipt at every launch to get the most updated one?
Mine is a social media app, I refresh receipt before user uses a premium feature, every time. Not sure about your use-case, but should be fine.
I got this issue fixed! @Starsky89 is correct. This error occurs when you're trying to refresh a receipt that does not exist. This seems to be the underlaying StoreKit error.
It doesn't tell much but upon further searching I came across this thread which confirmed the suspicion.
I changed my code to first check whether the receipt exist or not and then fire the verification code. My app got approved.
I got this issue fixed! @Starsky89 is correct. This error occurs when you're trying to refresh a receipt that does not exist. This seems to be the underlaying StoreKit error.
It doesn't tell much but upon further searching I came across this thread which confirmed the suspicion.
I changed my code to first check whether the receipt exist or not and then fire the verification code. My app got approved.
Great! Can you provide code snippet/SC of your function.
I don't do anything special. I just run this check and handle things accordingly.
if SwiftyStoreKit.localReceiptData != nil {
// Has a receipt. Verify it.
let validator = AppleReceiptValidator(service: .production, sharedSecret: Constant.Secret.inAppPurchase)
SwiftyStoreKit.verifyReceipt(using: validator) { result in
switch result {
case .success(let receipt):
// handle success
case .error(let error):
// show error
}
}
} else {
// There is no receipt.
// Possibly a brand new user who has not purchased anything in the app before.
}
The reviewers also rejected my app. In their test environment they get a "SwiftStoreKit.ReceiptError error 1" after restoring and verifying subscription purchases. In my sandbox environment, however, everything works fine.
So instead of receiving an empty receipt, they get no receipt and verification fails! (Thus, other approaches like InAppReceipt.refresh will also fail).
Isuru-Nanayakkara is right. You have to check if SwiftyStoreKit.localReceiptData is nil.
This information should be added to the wiki.
The App subscription works fine in the sandbox environment, but when apple reviewers test the app they got the below error after purchasing the subscription.
" The operation couldn't be completed. (SwiftyStoreKit.ReceiptError error1.) "
only fetch recipt is used , I'm not using validate recipt anywhere in the code, but still I get the error. Please can anyone help.
Code:-
SwiftyStoreKit.fetchReceipt(forceRefresh: true) { result in
switch result {
case .success(let receiptData):
let encryptedReceipt = receiptData.base64EncodedString(options: [])
// code to send recipt to backed server for verification and further process
case .error(let error):
print("Fetch receipt failed: \(error)")
AppDelegate.shared().window?.showToastAtMidBottom(message: (error as NSError).localizedDescription, time: 2.0)
}
}
@anta-semenov anta-semenov commented on 11 Jan 2019 I also have this issue. But I have it when I fetch receipt after successful purchase.
I also have this issue. But I have it when I fetch receipt after successful purchase.
hi Mr.anta-semenov did you find any solution
I had the same issue when I sent app that worked in sandbox for review. Review team still had the error on its iPad. I had my own IAP manager which worked with StoreKit natively. After that I switched to SwiftyStoreKit with the hope that all common issues are fixed in the library. Seems that the error is pretty common and not obvious for devs.
I also use SwiftyStoreKit.fetchReceipt(forceRefresh: true) but according to the SwiftyStoreKit sources it works in the same way as @Isuru-Nanayakkara solution.
/// Return receipt data from the application bundle. This is read from
Bundle.main.appStoreReceiptURL. public static var localReceiptData: Data? { return sharedInstance.receiptVerificator.appStoreReceiptData }
Code from receiptVerificator
var appStoreReceiptData: Data? { guard let receiptDataURL = appStoreReceiptURL, let data = try? Data(contentsOf: receiptDataURL) else { return nil } return data }
Does anybody have solution?
UPD: The problem is in accessing receipt at app's start on simulator after erasing its content and settings. I switched to TPInAppReceipt for receipt checks and the problem has gone.
Also I noticed that SwiftyStoreKit returns ReceiptError.noReceiptData in case there is no receipt data after fetchReceipt, but I can't remember that reviewers have faced that error.
fetchReceipt
not work for me. Its work in sandbox, but users without subscriptions have problem in AppStore.
upd: If you check subscriptions during App started, you use bad solution. Read this https://github.com/bizz84/SwiftyStoreKit/issues/397#issuecomment-430627148
Platform
In app purchase type
Environment
Version
0.13.3
Report
Issue summary
We're fetching the receipt in order to validate if the subscription is still valid or not. In order to do so we fetch the receipt and sent the encoded receipt to our server. This is our code:
Everything works on my side but unfortunately the Apple reviewer gets the error which is shown in the section below. So
error.localizedDescription
is the alert message. Now I looked through the errors from SwiftStoreKit and I'm a bit hopeless cause I couldn't find any error with code 1. Could someone help me here?What did you expect to happen
Fetching receipt is successfull and the receipt will be send to our sever for validation without error
What happened instead