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: 216
  • InAppReviewExample.zip
    9.6 KB · Views: 208
Last edited:

JohnC

Expert
Licensed User
WOW!!!

This is a game changer because reviews are the BIGGEST factor in users just being able to see our app in the playstore when they do a search.

This API will be so much more effective in getting positive reviews because:

1) Before this API, our app would not know if a user posted a review or not, so our app would either annoy the user with repeated prompts, or have a "I already left a review" or "Don't ask again" option in the prompt.
2) We can easily configure our app to first ask a simple question like "How much do you like this app?", and ONLY if the user responds favorably, then call this API to allow them to actually post a review.
3) Many times I will see in analytics the event that a user selected "Rate in Playstore" in my app, but only to find out that those events happen much more often then when a new review actually posts. This API will significantly increase the number of not only reviews posted (by eliminating the lazy, or "I forgot to post the review" users), but they will be "positive" reviews too (because our apps will obviously not allow a user to post a review if their response to item #2 above was not positive).

I am assume this API will let our app know if the user already posted a review, so we won't bother them about posting one.

I know this would be wishful thinking, but it would be cool if the API can let us know what the star rating was that the user selected after calling this API.
 

JohnC

Expert
Licensed User
Well, scratch #2 because the guidelines say:

Your app should not ask the user any questions before or while presenting the rating button or card, including questions about their opinion (such as “Do you like the app?”) or predictive questions (such as “Would you rate this app 5 stars”).

So, then maybe our app should prompt the user with this API only after the user has been using the app for a long time because that would suggest they must like the app if they use it a lot and keep it installed on their phone.
 

JohnC

Expert
Licensed User
Oh, so when the blog post said:
We’ve also placed cap limits to ensure that users won’t be prompted excessively should they choose not to leave a review.

...it meant that THEIR api has cap limits so THEIR api won't bother the user too much.
 
Last edited:

ronnhdf

Member
Licensed User
Unfortunately it does not work for me, is there a way to find the error?
B4X:
sending message to waiting queue (inappreview_oncomplete)
running waiting messages (1)
OnComplete

No Error
 

Pendrush

Well-Known Member
Licensed User
Unfortunately it does not work for me, is there a way to find the error?


Did you do step 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.

If answer is YES, did you already ratted/reviewed that app before?

Also do you have this in app 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"/>)
 
Last edited:

ronnhdf

Member
Licensed User
Yes is in Playstore
But no error is displayed!

because I have also added code.
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"/>)

or could it be that he has a bug here ?
B4X:
android:theme="@style/Theme.PlayCore.Transparent"

Test it
https://play.google.com/apps/internaltest/4699990649678614924
 

Pendrush

Well-Known Member
Licensed User
Example and library are updated, please download them again. FakeReviewManager is exposed now.
Just add True in initialize line:
B4X:
InAppReview.Initialize("InAppReview", True)
Can you test it again?
 

Pendrush

Well-Known Member
Licensed User
Thank you for testing, source code is attached do post #1, obviously I need some help.
 

Jack Cole

Well-Known Member
Licensed User
It is working for me as long as I use this to initialize:

B4X:
InAppReview.Initialize("InAppReview", False)

This never results in the pop-up:

B4X:
InAppReview.Initialize("InAppReview", True)

The UseFakeReviewManager set to true seems to be the part that makes it not work.
 

Jack Cole

Well-Known Member
Licensed User
I used an existing app and published a version in the internal testing track. I then had to wait for it to actually update from the play store. After that finally happened, I was able to run the app from the IDE in debug mode and it would work fine.

Again, the FakeReviewManager has to be set to false. It never works if it is set to true.
 

Jack Cole

Well-Known Member
Licensed User
Well, I looked at the Java code and read the documentation on the FakeReviewManager. Turns out, it is functioning as expected. I imagined that it would pop-up with a fake review pop-up. That is not how it is intended to function. Instead, it just always returns with the oncomplete event.

Here is what they say:

Note: FakeReviewManager does not simulate the UI. 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.

So, I think this library is functioning as intended.
 

ronnhdf

Member
Licensed User
Sorry for the late reply, after I changed that it works now.
Thanks for your effort and keep up the good work
 

asales

Well-Known Member
Licensed User
Top