Trending Articles       10 Flutter Listview Examples       Flutter Custom Button Example       Flutter Audio Recording       Flutter 2.0 Autocomplete TextField       Current Location Google Maps

GooglePlay Inapp Review API Integration in Android Application

Last updated Jan 27, 2021

Write a review to any Android application user has to go GooglePlay and there they has to select app and write  a review for the application.

Due to this lenthy process user might not interest on writing a review for the app.

This post will teach you how to integrate GooglePlay Inapp review API in Android

 

Let's get started
Step 1: Create an Android application in Android studio
Step 2: Add Inapp Review dependencies in build.gradle file

 

implementation 'com.google.android.play:core-ktx:1.8.1'


Step 3: To work with API we need to create an instance of ReviewManager class

 

Create RequestInfo Object

val request = manager.requestReviewFlow()
request.addOnCompleteListener { request ->
    if (request.isSuccessful) {
        // We got the ReviewInfo object
        val reviewInfo = request.result
    } else {
        // There was some problem, continue regardless of the result.
    }
}

 

Launch InApp Review Window

val flow = manager.launchReviewFlow(activity, reviewInfo)
flow.addOnCompleteListener { _ ->
    // 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.
}

 

Step 4: Add Internet permission in manifest file

<uses-permission android:name="android.permission.INTERNET"/>

 

Step 5: To Test the InApp Review API App should be publish in GooglePlay.

What i did for this is

  • Create a build
  • Released app in Internal Testing
  • After publishing app in Testing mode install app in rmobile and open applicatio

 

Minimum requirements

  • Android devices should be running on Android 5.0 (API level 21) or higher and should have Google play store installed
  • Chrome OS devices that have Google play store app installed Play core library with v1.8.0 or higher.

 

Design guidelines & Quota restrictions

  • The Review dialog should not be tampered or altered by modifying the design
  • Any overlay should not be added on top or around the card
  • Review dialog will automatically be removed based on user action
  • To protect user privacy and avoid API misuse, this API has a limited quota per user.
  • Hence this functionality should not be triggered on a button click
  • Before presenting the Review card, the app should not ask user opinions like “Do you like the app?” or “Give this app 5 stars”, etc

 

GooglePlay InApp Review

 

Complete code

package com.rrtutors.inappreview


import android.os.Bundle
import android.view.View
import androidx.appcompat.app.AppCompatActivity
import com.google.android.play.core.review.ReviewInfo
import com.google.android.play.core.review.ReviewManagerFactory

class MainActivity : AppCompatActivity() {
    override fun onCreate(savedInstanceState: Bundle?) {
        super.onCreate(savedInstanceState)
        setContentView(R.layout.activity_main)
    }

    fun rateus(view: View) {
        val manager = ReviewManagerFactory.create(applicationContext)
        val request = manager.requestReviewFlow()
         var reviewInfo: ReviewInfo? = null
        request.addOnCompleteListener { request ->
            if (request.isSuccessful) {
                // We got the ReviewInfo object
                reviewInfo = request.result
                val flow = manager.launchReviewFlow(MainActivity@this, request.result)
                flow.addOnCompleteListener { _ ->
                    // 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.
                }
            } else {
                // There was some problem, continue regardless of the result.
            }
        }



    }
}

 

Android ViewModel Interview Questions


Article Contributed By :
https://www.rrtutors.com/site_assets/profile/assets/img/avataaars.svg

647 Views

Flutter Questions

Android Questions

© 2021 RRTutors . All Rights Reserved.