tikhop / TPInAppReceipt

Reading and Validating In App Purchase Receipt Locally.
MIT License
631 stars 93 forks source link

`Bundle.main.appStoreReceiptURL` returns wrong url when using StoreKit configuration file and running iOS app on macOS (m1) #75

Closed tikhop closed 3 years ago

tikhop commented 3 years ago

More info: https://developer.apple.com/forums/thread/667715?answerId=651424022#651424022

macoapps commented 3 years ago

same behavior here :( (Mac mini M1)

tikhop commented 3 years ago

Hi @macoapps, I'm sorry, I just can't try it by myself, since I don't have an access to m1 machine.

Do you have a chance to check what's the right url on your machine and what comes from Bundle.main.appStoreReceiptURL?

Thanks, Pavel

macoapps commented 3 years ago

Hi @tikhop, tried to print appStoreReceiptURL value in func appStoreReceiptData(), return nil with iPhone 12 simulator running on Mac mini M1.

Printing Bundle.main.appStoreReceiptURL?.path on AppDelegate gives me this : -> using iPhone 12 Pro as simulator nil

-> using My Mac M1 as simulator Capture d’écran 2021-03-26 à 13 09 25 /Users/XXXXXX/Library/Containers/E5CDC364-608E-4C8F-8E5B-FFE578B304D7/Data/StoreKit/sandboxReceipt

I'll check if I can run my app on my Mac but I'll have to solve other errors (not in TPInAppReceipt ;))

tikhop commented 3 years ago

Hi @macoapps,

Thanks for providing extra information. Seems that it returns the right path for m1 device. For iPhone simulator, it can be nil, as I know, when you run the app for the first time (When user downloads the app from AppStore, the local receipt is available right away). In order to get a receipt on simulator you must make a purchase or refresh your receipt:

InAppReceipt.refresh { (error) in
    print(error)
}

NOTE: User gets a prompt to sign into the store to download the receipt when InAppReceipt.refresh(completion:) is being called.

macoapps commented 3 years ago

Hi @tikhop

Did a quick check, I think I found what was wrong. I kept my old StoreKitTestCertificate from my previous computer. I've generated a new one from my M1, and everything new seems to be fine 👍 Sorry for that !

tikhop commented 3 years ago

Hi @macoapps,

No problem - glad it works for you now.