StoreKit 2 currentEntitlements without internet

Hello, I am implementing StoreKit2.

My app uses Transaction.currentEntitlements to load the user's purchased subscriptions after the app is launched, how the transactions are loaded? (from the AppStore/Internet or from the local receipt)

currentEntitlements doesn't throw any exception, and I'm not sure how to handle the offline case.

Answered by App Store Commerce Engineer in 714480022

To get the latest transactions the device will need internet access but it does cache data locally and new transactions are pushed to the device when online, so could be up to date when it goes offline.

Accepted Answer

To get the latest transactions the device will need internet access but it does cache data locally and new transactions are pushed to the device when online, so could be up to date when it goes offline.

Hi @App Store Commerce Engineer, is there a way to programmatically know if the user cant access their currentEntitlements due to an internet or other error? If a user has no internet when they first open an app in wihch have previously purchased some items on another device, they will not get access to these items on the device with no internet. This makes perfect sense, but we should have a way to inform the user of this.

When this happens I get the following error in Xcode:

Error enumerating all current transactions: Error Domain=NSURLErrorDomain Code=-1009 "The Internet connection appears to be offline." UserInfo={AMSStatusCode=0, _NSURLErrorFailingURLSessionTaskErrorKey=LocalDataTask <33FA368E-0213-4D4D-AF53-C93CE9E32018>.<1>, NSErrorFailingURLKey=https://mzstorekit-sb.itunes.apple.com/inApps/v1/history?guid=00008027-001970E00185002E&reason=initial, _kCFStreamErrorDomainKey=1, _NSURLErrorRelatedURLSessionTaskErrorKey=(
    "LocalDataTask <33FA368E-0213-4D4D-AF53-C93CE9E32018>.<1>"
), NSLocalizedDescription=The Internet connection appears to be offline., NSErrorFailingURLStringKey=https://mzstorekit-sb.itunes.apple.com/inApps/v1/history?guid=00008027-001970E00185002E&reason=initial, NSUnderlyingError=0x281c314d0 {Error Domain=kCFErrorDomainCFNetwork Code=-1009 "(null)" UserInfo={_NSURLErrorNWPathKey_desc=unsatisfied (No network route), _kCFStreamErrorCodeKey=50, _kCFStreamErrorDomainKey=1}}, _kCFStreamErrorCodeKey=50}

Which is great, but I can't catch it anywere in my code to trigger UI changes. Do you know how could I catch this error?

Best, Joaquín.

StoreKit 2 currentEntitlements without internet
 
 
Q