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. To integrate in-app reviews in your app, your app must use version 1.8.0 or higher of the Play Core library.
  2. Android devices (phones and tablets) running Android 5.0 (API level 21) or higher that have the Google Play Store installed.
  3. App minSdkVersion="21"
  4. Please check manifest in app example.
  5. 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: 1.00
  • 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.


To install Play Core library start SDK Manager and in search field type: com.google.android.play:core and install it.
1596732320345.png

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.missingsplits.PlayCoreMissingSplitsActivity" android:enabled="false" android:exported="false" android:process=":playcore_missing_splits_activity" android:launchMode="singleInstance" android:stateNotNeeded="true"/>
    <activity android:name="com.google.android.play.core.common.PlayCoreDialogWrapperActivity" android:enabled="false" android:exported="false" android:stateNotNeeded="true" android:theme="@style/Theme.PlayCore.Transparent"/>
    <service android:name="com.google.android.play.core.assetpacks.AssetPackExtractionService" android:enabled="false" android:exported="true"/>)

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.
 

Attachments

  • InAppReviewLibrary.zip
    4.1 KB · Views: 215
  • InAppReviewExample.zip
    9.6 KB · Views: 204
Last edited:

Pendrush

Well-Known Member
Licensed 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
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
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
Library is extremely simple, also there is nothing with a loop inside library.
 

tufanv

Expert
Licensed 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 !
 
Top