cordova-launch-review
Advanced tools
Comparing version 4.0.0 to 4.0.1
{ | ||
"version": "4.0.0", | ||
"version": "4.0.1", | ||
"name": "cordova-launch-review", | ||
@@ -4,0 +4,0 @@ "cordova_name": "Launch Review", |
@@ -120,2 +120,5 @@ Cordova Launch Review plugin [![Latest Stable Version](https://img.shields.io/npm/v/cordova-launch-review.svg)](https://www.npmjs.com/package/cordova-launch-review) [![Total Downloads](https://img.shields.io/npm/dt/cordova-launch-review.svg)](https://npm-stat.com/charts.html?package=cordova-launch-review) | ||
- The user must first rate your app in the native dialog before being shown the review textarea input. | ||
- Neither `success` or `error` will not be called if dialog was not shown due to rate limiting, etc. | ||
- If you need to know the outcome it's therefore best to set timeout after which you assume the dialog has failed to show - see the example project for an example of this. | ||
- If you're having problems with getting the native rating dialog to appear, make sure you've followed all the steps in the [Android guidelines on testing in-app reviews](https://developer.android.com/guide/playcore/in-app-review/test). | ||
@@ -125,3 +128,3 @@ | ||
- {function} success - (optional) function to execute on requesting and successful of launching rating dialog. | ||
- {function} success - (optional) function to execute on successfully requesting (note: this does not guarantee it will be displayed) the launch rating dialog | ||
- iOS | ||
@@ -133,4 +136,4 @@ - Will be passed a single string argument which indicates the result: `requested`, `shown` or `dismissed`. | ||
- Android | ||
- Will not be passed any callback arguments | ||
- Will not be called if dialog was not shown due to rate limiting | ||
- Will be passed a single string argument which indicates the result: `requested` | ||
- *May* be called once after the dialog was successfully displayed **and** the user dismisses the dialog. | ||
- {function} error - (optional) function to execute on failure to launch rating dialog. | ||
@@ -146,27 +149,48 @@ - Will be passed a single argument which is the error message string. | ||
var MAX_DIALOG_WAIT_TIME = 5000; //max time to wait for rating dialog to display | ||
//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); | ||
} | ||
LaunchReview.rating(function(result){ | ||
function rating(){ | ||
if(cordova.platformId === "android"){ | ||
console.log("Rating dialog displayed"); | ||
}else if(cordova.platformId === "ios"){ | ||
if(result === "requested"){ | ||
console.log("Requested display of rating dialog"); | ||
ratingTimerId = setTimeout(function(){ | ||
console.warn("Rating dialog was not shown (after " + MAX_DIALOG_WAIT_TIME + "ms)"); | ||
}, MAX_DIALOG_WAIT_TIME); | ||
}else if(result === "shown"){ | ||
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(result === "dismissed"){ | ||
}else if(status === "dismissed"){ | ||
console.log("Rating dialog dismissed"); | ||
clearTimeout(ratingTimerId); | ||
} | ||
} | ||
},function(err){ | ||
console.log("Error opening rating dialog: " + err); | ||
}); | ||
}, function (err){ | ||
console.error("Error launching rating dialog: " + err); | ||
clearTimeout(ratingTimerId); | ||
}); | ||
} | ||
rating(); // app invokes eg. via UI action | ||
@@ -173,0 +197,0 @@ |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
46691
14
138
240