Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[expo-in-app-purchases] Add defensive null checks and missing iOS SKE…
…rrorCode values (#11773) # Why We have seen several crash reports in production on Android and iOS due to the platform IAP code sending invalid or missing Product SKU data to `expo-in-app-purchases`. On Android, despite the documentation implying that the parameters to methods like `onQueryPurchasesFinished()` and `onSkuDetailsResponse()` are not nullable, we have seen occasional crashes in production where they have been null. This patch adds some defensive null checks to the Android code to gracefully ignore invalid input rather than crash. On iOS, there are cases when some fields of `SKProduct` coming from the StoreKit API can be `nil`, specifically during the app review process when your IAP product is in a "Review Rejected" state. In this case, I think it's best to ignore the invalid product SKU, otherwise the `nil` values will propagate through the EXInAppPurchases code and inevitably cause a native Objective-C crash. (example crash report: https://sentry.io/share/issue/057be1d8c2f345c687feb82349a87adb/ - note, I believe the part of the stack trace that includes `expo::gl_cpp` is bogus due to threading or JSC issues - the actual error comes from receiving a SKProduct containing `nil` values from `[SKProductsRequest _start]` and passing it to `getProductData`) In addition, this patch adds a few missing `SKErrorCode` values to `errorCodeNativeToJS` that were added in more recent StoreKit versions. (happy to separate this part if you'd like). By the way, separately, I'd like to propose updating the Android Google Play Billing SDK to 2.2.0, which is the latest version that has no breaking changes relative to the version currently used by `expo-in-app-purchases` (2.0.0). # How Ignore invalid product SKUs at the Android/iOS API level. # Test Plan We've been running this patch in production on our app (https://badukpop.com) for several months with satisfactory results.
- Loading branch information