App rate and review in ionic 4

App rate and review in ionic 4

At some point all of us love to have users rate and reviews for our applications to know how we did it right? whats better than encouraging our users to go and rate our app? to do this today i will introduce you to cordova/ionic plugin names Launch Review and show you how it's done.

Note: this works on Andrid and Ios only.

Let's begin

Open your terminal in your app location and run this commands

$ ionic cordova plugin add cordova-launch-review
$ npm install @ionic-native/launch-review

After installing plugins open your prefered page where you want place your link (in my case i've added it to profile page)

Open profile.page.ts file and add this lines:

import { LaunchReview } from '@ionic-native/launch-review/ngx';

export class ProfilePage implements OnInit {

  appId = "PLACE_YOUR_APP_ID_HERE";

  constructor(
    private launchReview: LaunchReview
  ) { }

  rateUs(){
    this.launchReview.launch(this.appId)
      .then(() => console.log('Successfully launched store app for rating'));

    if (this.launchReview.isRatingSupported()) {
      this.launchReview.rating()
        .then(() => console.log('Successfully launched rating dialog'));
    }
  }
}

In code above trick is using appId so the plugin can know which app should it open in store.

Next open your profile.page.html and add this link:

<ion-item>
  <ion-label (click)="rateUs()" class="ion-text-wrap">Rate Us!</ion-label>
</ion-item>

the important part in code above is (click)="rateUs()" so you're not limited to use item list but any other element as you wish, as long as it has (click)="rateUs()" with it.

Last but not least add this line in your config.xml file.

<plugin name="cordova-launch-review" spec="5.13.0" />

Remember spec part is your plugin version change it according to installed version. (you can find plugin version from package.json file)

Sample:

"@ionic-native/launch-review": "^5.13.0",

 

Go ahead and test it.

Leave a comment

Enjoy this?

Subscribe our newsletter and get latest updates straight to your inbox.