Fix crash related to Amazon AppStore SDK #1621
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Description
One Line Summary
Fix crash for users of Amazon AppStore SDK v3.x.
Details
Motivation
PurchasingService.registerListener()
must run on the main thread. See documentation.Other Changes
in-app-purchasing-2.0.1.jar
which is from 2015, and instead compile against its replacementamazon-appstore-sdk
v3.x. This change currently makes no difference at compile time, as this crash was only encountered at runtime, but still good to update this dependency to what users are more likely to be currently using.Scope
Only affects users of Amazon's AppStore SDK v3.x, for whom the OneSignal SDK was not working in the first place. So even though there is a danger zone to calling this method on the main thread, it is still preferable.
Note that
onAppLostFocus()
can triggerPurchasingService.registerListener()
in certain cases. See here. We will need to monitor or make changes.^⚠️ I am concerned if this will pose a significant issue.
Testing
Unit testing
There are no existing unit tests for Amazon purchases. No new tests are added.
Note: Unrelated, but test
testNotificationProcessingAndForegroundHandler_displayCalled_noMutateId
is failing. Looks like due to changes in #1597Manual testing
Environment: Android Studio 2020.3.1.
Device: Pixel 3a emulator - API 30
App: OneSignal demo app in the SDK
First, reproduced the crash by using amazon appstore v3.0.1 and v3.0.3 (the latest version at time of writing).
Then, confirm IAP SDK works the same as before by using
in-app-purchasing-2.0.1.jar
(these are not available on Maven).Affected code checklist
Checklist
Overview
Testing
Final pass
This change is