Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fixed concurrency issue on iOS. (#413)
The `productsRequest` method as per Apple docs can be called on any thread (source: https://developer.apple.com/documentation/storekit/skproductsrequestdelegate (please check text in read)). Working with `validProducts` on such thread can cause concurrency issues, such as this one: **"Terminating app due to uncaught exception 'NSGenericException', reason: '*** Collection <__NSArrayM: 0x283ca4090> was mutated while being enumerated.'"** Moreover, flutter results must be called on platform main thread only (source: https://docs.flutter.dev/development/platform-integration/platform-channels) _"Even though Flutter sends messages to and from Dart asynchronously, whenever you invoke a channel method, you must invoke that method on the platform’s main thread."_ To fix these issues I simply wrapped all the code in `dispatch_async(dispatch_get_main_queue, ^{ ... })`. Please pull this fix. Co-authored-by: Alfred Lapkovsky <[email protected]>
- Loading branch information