StoreHelper icon indicating copy to clipboard operation
StoreHelper copied to clipboard

Could not fetch Products array (tvOS)

Open rebeloper opened this issue 2 years ago • 5 comments

In requestProductsFromAppStore on tvOS, debug mode (not yet live on the App Store) I get a failure of requestProductsFailure either by having nil Products or an empty array of Products.

The same happens on watchOS production mode, while it works ok in debug.

I narrowed down the issue to the line try? await Product.products(for: productIds)

It seems that there's a bug in StoreKit2 🤔

Any thoughts?

rebeloper avatar Apr 22 '22 10:04 rebeloper

Hi Alex

Away from my machine at the moment but will look into it in a couple of hours.

One thing to check is if productIds actually has a set of ids or not. If not, it’s something to do with the property file containing your product ids not being read. If it does have ids then it sounds like a pretty fundamental StoreKit2 bug.

Russell

Sent from my iPhone

On 22 Apr 2022, at 11:18, Alex Nagy @.***> wrote:

 In requestProductsFromAppStore on tvOS, debug mode (not yet live on the App Store) I get a failure of requestProductsFailure ether by having nil Products or an empty array of Products.

The same happens on watchOS production mode, while it works ok in debug.

I narrowed down the issue to the line try? await Product.products(for: productIds)

It seems that there's a bug in StoreKit2 🤔

Any thoughts?

— Reply to this email directly, view it on GitHub, or unsubscribe. You are receiving this because you are subscribed to this thread.

russell-archer avatar Apr 22 '22 11:04 russell-archer

I can confirm I’m seeing the same problem as you are for tvOS on the simulator. The configuration file is being correctly read and the product ids are being returned OK. However, as you say, the call to try? await Product.products(for: productIds) fails. If you retry you get the same error. Interestingly, the first time you request localized product info the call doesn’t seem to return. If you you retry the call then it immediately fails and StoreHelper is able to log an error (Request products from the App Store failure).

I’m also seeing the following error: [StoreKit] Failed to get products through appstored in simulator, will try using appstoreagent on host mac: Error Domain=ASDErrorDomain Code=507 "Error decoding response" UserInfo={NSLocalizedDescription=Error decoding response, NSLocalizedFailureReason=Could not decode media products response}

This does indeed look like a bug in StoreKit2.

I’ll do some more playing with this over the weekend and see if I can workaround the issue!

Russell

On 22 Apr 2022, at 11:18, Alex Nagy @.***> wrote:

In requestProductsFromAppStore on tvOS, debug mode (not yet live on the App Store) I get a failure of requestProductsFailure ether by having nil Products or an empty array of Products.

The same happens on watchOS production mode, while it works ok in debug.

I narrowed down the issue to the line try? await Product.products(for: productIds)

It seems that there's a bug in StoreKit2 🤔

Any thoughts?

— Reply to this email directly, view it on GitHub https://github.com/russell-archer/StoreHelper/issues/2, or unsubscribe https://github.com/notifications/unsubscribe-auth/ABRLWA566676RA5BXSTND2LVGJ4HNANCNFSM5UB3ZNWQ. You are receiving this because you are subscribed to this thread.

russell-archer avatar Apr 22 '22 17:04 russell-archer

After more investigation I've found that using a real Apple TV device also fails at the same point when requesting localized products. However, I do get an additional error that I don't see when running on the TV simulator:

void * _Nullable NSMapGet(NSMapTable * _Nonnull, const void * _Nullable): map table argument is NULL

So, I've verified that from a StoreHelper perspective everything runs as expected on tvOS until the point where

try? await Product.products(for: ids)

is called. When the async call is made it doesn't return for about 10-15 seconds, and then times out with an error from StoreKit. For me this happens on both the tvOS simulator and a real Apple TV device. The exact same code runs perfectly on iOS and macOS. I haven't tested it on watchOS yet. I'm afraid this really seems like a StoreKit2 bug. I'll leave this issue open but without input/help from Apple I'm not sure how to proceed with fixing this as it's such a fundamental problem.

russell-archer avatar Apr 25 '22 15:04 russell-archer

Got to the same tests and conclusion myself :) Hopefully Apple will fix this issue with an update. Thanks for your research

rebeloper avatar Apr 25 '22 16:04 rebeloper

watchOS works. I found my error was in iOS Deployment Target, in my project was with compatibility from iOS 13, I change to iOS 15 because StoreKit 2 works only with this version but is very strange because my app only works in WatchOS without iPhone dependencies.

rebeloper avatar Apr 25 '22 16:04 rebeloper

This seems to have been fixed by Apple in StoreKit 2 released with Xcode 14.

russell-archer avatar Oct 18 '22 16:10 russell-archer