[in_app_purchase_android] Add showInAppMessages support (#107412)#11214
[in_app_purchase_android] Add showInAppMessages support (#107412)#11214fingerart wants to merge 1 commit intoflutter:mainfrom
Conversation
There was a problem hiding this comment.
Code Review
This pull request adds support for the showInAppMessages API from the Google Play Billing Library. This includes defining the new API in Pigeon, implementing it on the Android native side, adding Dart wrappers, and updating the example app to demonstrate its usage. Tests for the new functionality have also been added.
| static @NonNull PlatformInAppMessageResponse fromInAppMessageResponseCode( | ||
| @InAppMessageResult.InAppMessageResponseCode int inAppMessageResponseCode) { | ||
| switch (inAppMessageResponseCode) { | ||
| case InAppMessageResult.InAppMessageResponseCode.SUBSCRIPTION_STATUS_UPDATED: | ||
| return PlatformInAppMessageResponse.SUBSCRIPTION_STATUS_UPDATED; | ||
| case InAppMessageResult.InAppMessageResponseCode.NO_ACTION_NEEDED: | ||
| return PlatformInAppMessageResponse.NO_ACTION_NEEDED; | ||
| } | ||
| return PlatformInAppMessageResponse.NO_ACTION_NEEDED; | ||
| } |
There was a problem hiding this comment.
For better maintainability and to explicitly handle any future InAppMessageResponseCode values, it's good practice to include a default case in your switch statement. This makes the code's intent clearer and prevents new values from being silently treated as NO_ACTION_NEEDED.
| static @NonNull PlatformInAppMessageResponse fromInAppMessageResponseCode( | |
| @InAppMessageResult.InAppMessageResponseCode int inAppMessageResponseCode) { | |
| switch (inAppMessageResponseCode) { | |
| case InAppMessageResult.InAppMessageResponseCode.SUBSCRIPTION_STATUS_UPDATED: | |
| return PlatformInAppMessageResponse.SUBSCRIPTION_STATUS_UPDATED; | |
| case InAppMessageResult.InAppMessageResponseCode.NO_ACTION_NEEDED: | |
| return PlatformInAppMessageResponse.NO_ACTION_NEEDED; | |
| } | |
| return PlatformInAppMessageResponse.NO_ACTION_NEEDED; | |
| } | |
| static @NonNull PlatformInAppMessageResponse fromInAppMessageResponseCode( | |
| @InAppMessageResult.InAppMessageResponseCode int inAppMessageResponseCode) { | |
| switch (inAppMessageResponseCode) { | |
| case InAppMessageResult.InAppMessageResponseCode.SUBSCRIPTION_STATUS_UPDATED: | |
| return PlatformInAppMessageResponse.SUBSCRIPTION_STATUS_UPDATED; | |
| case InAppMessageResult.InAppMessageResponseCode.NO_ACTION_NEEDED: | |
| default: | |
| return PlatformInAppMessageResponse.NO_ACTION_NEEDED; | |
| } | |
| } |
|
@stuartmorgan-g @GaryQian What else do I need to do? |
|
@fingerart You need to wait for a review, which as our docs explain takes up to a couple of weeks. |
As mentioned in #107412, a new native feature (showInAppMessages) has been added.
Pre-Review Checklist
[shared_preferences]///).If you need help, consider asking for advice on the #hackers-new channel on Discord.
Note: The Flutter team is currently trialing the use of Gemini Code Assist for GitHub. Comments from the
gemini-code-assistbot should not be taken as authoritative feedback from the Flutter team. If you find its comments useful you can update your code accordingly, but if you are unsure or disagree with the feedback, please feel free to wait for a Flutter team member's review for guidance on which automated comments should be addressed.Footnotes
Regular contributors who have demonstrated familiarity with the repository guidelines only need to comment if the PR is not auto-exempted by repo tooling. ↩ ↩2