cordova-launch-review
Advanced tools
Comparing version 3.0.0 to 3.1.0
{ | ||
"version": "3.0.0", | ||
"version": "3.1.0", | ||
"name": "cordova-launch-review", | ||
@@ -4,0 +4,0 @@ "cordova_name": "Launch Review", |
@@ -113,10 +113,10 @@ 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 Rating dialog may take several seconds to appear while iOS queries the Apple servers before displaying the dialog. | ||
- The success function will therefore be called either once or twice: | ||
- First: after `LaunchReview.rating()` is called and the request to show the dialog is successful | ||
- Second: if and when the Rating dialog is actually displayed. | ||
- Detection of the display of the Rating dialog is done using [inspection of the private class name](https://github.com/dpa99c/cordova-launch-review/blob/master/src/ios/LaunchReview.m#L95). | ||
- The success function will be called up to 3 times: | ||
- First: after `LaunchReview.rating()` is called and the request to show the dialog is successful. Will be passed the value `requested`. | ||
- Second: if and when the Rating dialog is actually displayed. Will be passed the value `shown`. | ||
- Third: if and when the Rating dialog is dismissed. Will be passed the value `dismissed`. | ||
- Detection of the display of the Rating dialog is done using [inspection of the private class name](https://github.com/dpa99c/cordova-launch-review/blob/master/src/ios/UIWindow+DismissNotification.m#L25). | ||
- This is not officially sanctioned by Apple, so while it **should** pass App Store review, it may break if the class name is changed in a future iOS version. | ||
- While it's possible to detect if the Rating dialog has been displayed, it's **not** possible to detect when it has been dismissed. | ||
- Therefore, since there's no guarantee the dialog will be displayed and even then it may take several seconds before it displays, the only way to determine if it has **not** be shown is to set a timeout after successful requesting of the dialog which is cleared upon successful display of the dialog, or otherwise expires after a pre-determined period (i.e. a few seconds). | ||
- See the [example project code](https://github.com/dpa99c/cordova-launch-review-example/blob/master/www/js/index.js#L32) for an illustration of this approach. | ||
- Since there's no guarantee the dialog will be displayed, and even then it may take several seconds before it displays, the only way to determine if it has **not** be shown is to set a timeout after successful requesting of the dialog which is cleared upon successful display of the dialog, or otherwise expires after a pre-determined period (i.e. a few seconds). | ||
- See the Advanced usage below and the [example project code](https://github.com/dpa99c/cordova-launch-review-example/blob/master/www/js/index.js#L22) for an illustration of this approach. | ||
@@ -126,7 +126,8 @@ ### Parameters | ||
- {function} success - (optional) function to execute on requesting and successful of launching rating dialog. | ||
Will be passed a single string argument which indicates the result. | ||
Will be called the first time after `LaunchReview.rating()` is called and the request to show the dialog is successful. | ||
*May* be called a second time if the rating dialog is successfully displayed. | ||
- Will be passed a single string argument which indicates the result: `requested`, `shown` or `dismissed`. | ||
- Will be called the first time after `LaunchReview.rating()` is called and the request to show the dialog is successful with value `requested`. | ||
- *May* be called a second time if/when the rating dialog is successfully displayed with value `shown`. | ||
- *May* be called a third time if/when the rating dialog is dismissed with value `dismissed`. | ||
- {function} error - optional) function to execute on failure to launch rating dialog. | ||
Will be passed a single argument which is the error message string. | ||
- Will be passed a single argument which is the error message string. | ||
@@ -140,8 +141,19 @@ | ||
var MAX_DIALOG_WAIT_TIME = 5000; //max time to wait for rating dialog to display | ||
var ratingTimerId; | ||
LaunchReview.rating(function(result){ | ||
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"){ | ||
console.log("Successfully displayed rating dialog"); | ||
} | ||
console.log("Rating dialog displayed"); | ||
clearTimeout(ratingTimerId); | ||
}else if(result === "dismissed"){ | ||
console.log("Rating dialog dismissed"); | ||
} | ||
},function(err){ | ||
@@ -148,0 +160,0 @@ console.log("Error opening rating dialog: " + err); |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
34644
10
206