Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix: add Amazon IAP v3.0.5 handle #2255

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

jetie000
Copy link

@jetie000 jetie000 commented Feb 4, 2025

Description

Added Amazon IAP v3.0.5 handle

Details

I'm developing app for business and faced this error while integrating
[email protected]
Error appeared because I also use @revenuecat/[email protected] (versions between 8.0.0 and 9.2.1 use Amazon IAP v3.0.5)
So Amazon IAP v3.0.5 is downloaded and we can't access method at class com.amazon.device.iap.internal.d
line:

Error screenshot:

image

This method at v3.0.4

image

This method at v3.0.5

image

Manual testing

Steps:

Affected code checklist

  • Notifications
    • Display
    • Open
    • Push Processing
    • Confirm Deliveries
  • Outcomes
  • Sessions
  • In-App Messaging
  • REST API requests
  • Public API changes

Checklist

Overview

  • I have filled out all REQUIRED sections above
  • PR does one thing
    • If it is hard to explain how any codes changes are related to each other then it most likely needs to be more than one PR
  • Any Public API changes are explained in the PR details and conform to existing APIs

Testing

  • I have included test coverage for these changes, or explained why they are not needed
  • All automated tests pass, or I explained why that is not possible
  • I have personally tested this on my device, or explained why that is not possible

Final pass

  • Code is as readable as possible.
    • Simplify with less code, followed by splitting up code into well named functions and variables, followed by adding comments to the code.
  • I have reviewed this PR myself, ensuring it meets each checklist item
    • WIP (Work In Progress) is ok, but explain what is still in progress and what you would like feedback on. Start the PR title with "WIP" to indicate this.

This change is Reviewable

@jetie000
Copy link
Author

@nan-li @jkasten2 Can you please have a look?

@nan-li nan-li self-requested a review February 13, 2025 19:58
Copy link
Contributor

@nan-li nan-li left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for submitting this PR, please see my comments and we can get this change in!

// appstore v3.0.4
listenerHandlerObject = listenerHandlerClass.getMethod("g").invoke(null)
registerListenerOnMainThread = true
} catch (err: NullPointerException) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

From the error log you provided and my own testing, this should catch a NoSuchMethodException.

I don't have clear insight into the Amazon IAP source code, but it seems that calling listenerHandlerObject = listenerHandlerClass.getMethod("e").invoke(null) throws a NPE but calling listenerHandlerObject = listenerHandlerClass.getMethod("g").invoke(null) throws a NoSuchMethodException.

Since we are also nesting try-catches here, even though it is not currently used, let's rename the inner err variable to differ from the outer err variable.

Copy link
Author

@jetie000 jetie000 Feb 20, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for review, I don't have experience with kotlin or java, noticed error in logcat while integrating capacitor library
Changed error variable names and exception class in the catch block

Copy link
Contributor

@nan-li nan-li Feb 21, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Great! Thanks!
Noting that g() returns a NoSuchMethodException instead of NPE is because in Amazon IAP 3.0.5, g() is an inaccessible private method. In contrast, there are public methods called d(), e(), f().

@jetie000 jetie000 force-pushed the fix/add-amazon-purchases-3.0.5-handle branch from a73d6db to 106ed55 Compare February 20, 2025 19:54
@nan-li nan-li requested review from nan-li and jkasten2 February 21, 2025 03:40
Copy link
Contributor

@nan-li nan-li left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Tested and confirmed on my end with Amazon IAP 3.0.5.

@nan-li nan-li requested a review from jinliu9508 February 21, 2025 15:51
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants