dpa99c / cordova-launch-review

Cordova/Phonegap plugin for iOS and Android to assist in leaving user reviews/ratings in the App Stores
71 stars 26 forks source link

Cordova Launch Review plugin Latest Stable Version Total Downloads

Table of Contents

Overview

Cordova/Phonegap plugin for iOS and Android to assist in leaving user reviews/ratings in the App Stores.

The plugin published to npm as cordova-launch-review

donate

I dedicate a considerable amount of my free time to developing and maintaining this Cordova plugin, along with my other Open Source software. To help ensure this plugin is kept updated, new features are added and bugfixes are implemented quickly, please donate a couple of dollars (or a little more if you can stretch) as this will help me to afford to dedicate time to its maintenance. Please consider donating if you're using this plugin in an app that makes you money, if you're being paid to make the app, if you're asking for new features or priority bug fixes.

Installation

Using the Cordova/Phonegap CLI

$ cordova plugin add cordova-launch-review

Usage

The plugin is exposed via the LaunchReview global namespace.

launch()

Platforms: Android and iOS

Launches the App Store page for the current app in order for the user to leave a review.

Parameters

Simple usage

LaunchReview.launch();

Advanced usage

var appId, platform = device.platform.toLowerCase();

switch(platform){
    case "ios":
        appId = "585027354";
        break;
    case "android":
        appId = "com.google.android.apps.maps";
        break;
}

LaunchReview.launch(function(){
    console.log("Successfully launched store app");
},function(err){
    console.log("Error launching store app: " + err);
}, appId);

rating()

Platforms: Android and iOS

iOS notes

Android notes

Parameters

Simple usage

LaunchReview.rating();

Advanced usage

//max time to wait for rating dialog to display on iOS
var MAX_DIALOG_WAIT_TIME_IOS = 5*1000; 

//max time to wait for rating dialog to display on Android and be submitted by user
var MAX_DIALOG_WAIT_TIME_ANDROID = 60*1000; 

var ratingTimerId;

function ratingDialogNotShown(){
    var msg;
    if(cordova.platformId === "android"){
        msg = "Rating dialog outcome not received (after " + MAX_DIALOG_WAIT_TIME_ANDROID + "ms)";
    }else if(cordova.platformId === "ios"){
        msg = "Rating dialog was not shown (after " + MAX_DIALOG_WAIT_TIME_IOS + "ms)";
    }
    console.warn(msg);
}

function rating(){
    if(cordova.platformId === "android"){
        ratingTimerId = setTimeout(ratingDialogNotShown, MAX_DIALOG_WAIT_TIME_ANDROID);
    }

    LaunchReview.rating(function(status){
        if(status === "requested"){
            if(cordova.platformId === "android"){
                console.log("Displayed rating dialog");
                clearTimeout(ratingTimerId);
            }else if(cordova.platformId === "ios"){
                console.log("Requested rating dialog");
                ratingTimerId = setTimeout(ratingDialogNotShown, MAX_DIALOG_WAIT_TIME_IOS);
            }
        }else if(status === "shown"){
            console.log("Rating dialog displayed");
            clearTimeout(ratingTimerId);
        }else if(status === "dismissed"){
            console.log("Rating dialog dismissed");
            clearTimeout(ratingTimerId);
        }
    }, function (err){
        console.error("Error launching rating dialog: " + err);
        clearTimeout(ratingTimerId);
    });
}

rating(); // app invokes eg. via UI action

isRatingSupported()

Platforms: Android and iOS

Indicates if the current platform/version supports in-app ratings dialog, i.e. calling LaunchReview.rating(). Will return true if current platform is Android or iOS 10.3+.

var isSupported = LaunchReview.isRatingSupported();

Example usage

if(LaunchReview.isRatingSupported()){
    LaunchReview.rating();
}else{
    LaunchReview.launch();
}

Example project

An example project illustrating use of this plugin can be found here: https://github.com/dpa99c/cordova-launch-review-example

License

================

The MIT License

Copyright (c) 2015-2020 Working Edge Ltd.

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.