B4A Library In-App Review Library

Before you begin, please read THIS and THIS. You can also read Medium article Demystifying the new Play In-App Review API (thanks @fredo).

Requirements:
  1. Android devices (phones and tablets) running Android 5.0 (API level 21) or higher that have the Google Play Store installed.
  2. App minSdkVersion="21"
  3. Please check manifest in app example.
  4. After implementation, app must be uploaded to Play Store and downloaded from Play Store (beta test should work). If app is not downloaded from Play Store dialog will not work, OnComplete event will fire immediately.

InAppReview

Author:
Author: Google - B4a Wrapper: Pendrush
Version: 2.01
  • InAppReview
    • Events:
      • OnComplete
      • OnError (Error As String)
    • Functions:
      • Initialize (EventName As String, UseFakeReviewManager As Boolean)
        Initialize InAppReview
        UseFakeReviewManager = True - This should only be used for unit or integration tests to verify the behaviour of the app once the review is completed.
        Note: FakeReviewManager does not simulate the UI (no pop-up will be shown). It only fakes the API method result by always providing a fake ReviewInfo object and returning a success status when the in-app review flow is launched.
        UseFakeReviewManager = False - Use it for production app.
        InAppReview.Initialize("InAppReview", False)
      • LaunchReview
        Launch review process. Pop-up window will show only for app downloaded from Play Store (Production app).
        OnComplete event will fire immediately if you initialize with UseFakeReviewManager = True
        Emulator will rise OnError event.


Use SDK Manager and install:
B4X:
com.google.android.play:review
com.google.android.gms:play-services-tasks
com.google.android.play:core-common


Example app is attached to this post.
OnComplete event will fire immediately after you click on button in example app. This behavior is normal for example app, but app in production (app downloaded from Play Store) should show dialog like this:
1596735639381.png
OnComplete event will fire after dialog is closed.

You need to set minSdkVersion="21" and to add this in your manifest:
B4X:
AddApplicationText(<activity
            android:name="com.google.android.play.core.common.PlayCoreDialogWrapperActivity"
            android:exported="false"
            android:stateNotNeeded="true"
            android:theme="@style/Theme.PlayCore.Transparent" />)

Download library zip file and extract archive to Additional Libraries folder.
Example app will trigger OnError event in emulator.

Thanks to: @ronnhdf and @Jack Cole for testing.


v2.01:
  • Library update to use com.google.android.play:review as InAppReview will be removed from com.google.android.play:core. The Google Play Core Java and Kotlin library have been split into multiple separate libraries, one for each feature.
  • Manifest update.
  • Example app update (only manifest).
  • Some permissions removed.
  • Library dependencies has changed.
 

Attachments

  • InAppReviewExample.zip
    9.7 KB · Views: 208
  • InAppReviewLibrary.zip
    4.1 KB · Views: 234
Last edited:

Pendrush

Well-Known Member
Licensed User
Longtime User
As you can see in first post, I did not test this library, but two other members of this forum.
I'm glad that you can clearly understand my API usage.

You can also use code like this:
B4X:
Dim p As Phone
If p.SdkVersion < 21 Then
    'dont use library
End If
 

coldteam

Active Member
Licensed User
Longtime User
As you can see in first post, I did not test this library, but two other members of this forum.
I'm glad that you can clearly understand my API usage.

You can also use code like this:
B4X:
Dim p As Phone
If p.SdkVersion < 21 Then
    'dont use library
End If

ok, thanks for the clarification. i will test this.
 

tufanv

Expert
Licensed User
Longtime User
for me this does not work. both tried with fake enabled on local testing and fake disabled on store. Both of them makes my app get in to a infinite loop
 

Pendrush

Well-Known Member
Licensed User
Longtime User
Library is extremely simple, also there is nothing with a loop inside library.
 

tufanv

Expert
Licensed User
Longtime User
Yeah, I missed the pooint that activity_resume was firing the event again as on complete event was also firing the activity_resume. It fires once only now. Thanks !
 

benyamin

Member
Thanks, can you add this method? It is very important for this library to understand whether the user can give the app a rating or not

com.google.android.play.core.review.ReviewInfo

Java:
Task<Void> flow = manager.launchReviewFlow(activity, reviewInfo);
flow.addOnCompleteListener(task -> {
    // The flow has finished. The API does not indicate whether the user
    // reviewed or not, or even whether the review dialog was shown. Thus, no
    // matter the result, we continue our app flow.
});
 
Top