New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

cordova-plugin-apprate

Package Overview
Dependencies
Maintainers
2
Versions
18
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

cordova-plugin-apprate - npm Package Compare versions

Comparing version 1.5.0 to 1.6.0

8

CHANGELOG.md
# Changelog
- Unreleased
- Nothing yet
- 1.6.0
- [PR #280](https://github.com/pushandplay/cordova-plugin-apprate/pull/280) - Removed iOS option `inAppReview` in favor of new option `reviewType`. Please update your app according to the updated documentation
- [PR #280](https://github.com/pushandplay/cordova-plugin-apprate/pull/280) - Fixed race condition on `deviceready` events causing the module to not be fully initialized
- [PR #281](https://github.com/pushandplay/cordova-plugin-apprate/pull/281) - feature: Android in-app review
- 1.5.0

@@ -4,0 +12,0 @@ - [PR #253](https://github.com/pushandplay/cordova-plugin-apprate/pull/253) - Remove iOS rating counter in favor of native approach

2

package.json
{
"name": "cordova-plugin-apprate",
"version": "1.5.0",
"version": "1.6.0",
"repository": {

@@ -5,0 +5,0 @@ "type": "git",

@@ -33,3 +33,3 @@ # Cordova-Plugin-Apprate

barColor: "#0000ff", // on iOS 10+ you can change the background color as well
controlTintColor: "#00ffff" // on iOS 10+ you can override the default tintColor
controlTintColor: "#00ffff", // on iOS 10+ you can override the default tintColor
tintColor: "#00ffff", // should be set to same value as controlTintColor and will be a fallback on older ios

@@ -64,5 +64,10 @@ },

## Integrating Google Play Core
To set up Google Play Core version, you can use PLAY_CORE_VERSION parameter (with `1.+` value by default). It is useful in order to avoid conflicts with another plugins which use any other different version of Google Play Core.
## Customization and usage
- Note: During development the submit button will be disabled and cannot be pressed. This is expected behavior per Apple when the app has not been downloaded from the app store. Details here: https://github.com/pushandplay/cordova-plugin-apprate/issues/182
- Note: Using the in-app review for Android/iOS will not prompt the user, and the native review prompt will be _requested_ and not guaranteed to be shown

@@ -78,4 +83,5 @@ ## Options / Preferences

| usesUntilPrompt | Integer | 3 | count of runs of application before dialog will be displayed |
| inAppReview | Boolean | true | iOS Only. Write review directly in your application (iOS 10.3+), limit of 3 prompts per year. Fallback to opening the store within the app for other iOS versions. Use false to use in app browser. |
| simpleMode | Boolean | false | enabling simplemode would display the rate dialog directly without the negative feedback filtering flow|
| reviewType.ios | [Enum](#reviewtypeios-enum) | AppStoreReview | the type of review display to show the user on iOS |
| reviewType.android | [Enum](#reviewtypeandroid-enum) | InAppBrowser | the type of review display to show the user on Android |
| simpleMode | Boolean | false | enabling simplemode would display the rate dialog directly without the negative feedback filtering flow |
| callbacks.onButtonClicked | Function | null | call back function. called when user clicked on rate-dialog buttons |

@@ -90,2 +96,25 @@ | callbacks.onRateDialogShow | Function | null | call back function. called when rate-dialog showing |

### reviewType
The `InAppReview` review type will attempt to launch a native in-app review dialog (as opposed to opening the app store).
The native dialog is designed to maintain the privacy of the users and to prevent applications from harassing them with too many review requests.
As such, the dialog might or might not appear, and we will not be able to know whether it appeared, or whether the user reviewed the app or not.
Since we can't know if the dialog will be shown, and in order to comply to the requirements of Apple/Android,
no custom prompt will be shown to the user before attempting to open the in-app review dialog.
Native in-app review can only be possible under certain conditions. If those conditions are not met, a fallback method will be used (see information per platform below).
#### reviewType.ios [Enum]
- `InAppReview` - Write review directly in your application (iOS 10.3+), limited to 3 prompts per year. Will fallback to 'AppStoreReview' for other iOS versions
- `AppStoreReview` - Open the store within the app. Use this option as an alternative to inAppReview to avoid the rate action from [doing nothing](https://developer.apple.com/documentation/storekit/skstorereviewcontroller/2851536-requestreview)
- `InAppBrowser` - Open the store using the `openUrl` preference (defaults to InAppBrowser). Be advised that WKWebView might not open the app store links
#### reviewType.android [Enum]
- `InAppReview` - Write review directly in your application. Will fallback to `InAppBrowser` if not available
- `InAppBrowser` - Open the store using the `openUrl` preference (defaults to InAppBrowser)
Notice that the `InAppReview` will only work on released versions. To test it our please refer to [this article](https://developer.android.com/guide/playcore/in-app-review/test)
## Examples

@@ -155,3 +184,6 @@

promptAgainForEachNewVersion: false,
inAppReview: true,
reviewType: {
ios: 'AppStoreReview',
android: 'InAppBrowser'
},
storeAppURL: {

@@ -231,3 +263,6 @@ ios: '<my_app_id>',

promptAgainForEachNewVersion: false,
inAppReview: true,
reviewType: {
ios: 'AppStoreReview',
android: 'InAppBrowser'
},
storeAppURL: {

@@ -234,0 +269,0 @@ ios: '<my_app_id>',

@@ -21,75 +21,84 @@ /*

*/
declare class AppRate {
static locales:Locales;
static preferences:AppRatePreferences;
static init():AppRate;
static promptForRating(immediately?:boolean):AppRate;
static navigateToAppStore():AppRate;
}
declare module "cordova-plugin-apprate" {
declare class AppRatePreferences {
useLanguage:string;
displayAppName:string;
promptAgainForEachNewVersion:boolean;
usesUntilPrompt:number;
inAppReview:boolean;
simpleMode:boolean;
callbacks:CallbackPreferences;
storeAppURL:StoreAppURLPreferences;
customLocale:CustomLocale;
}
export class AppRate {
static locales: Locales;
static preferences: AppRatePreferences;
declare class StoreAppURLPreferences {
ios:string;
android:string;
blackberry:string;
windows8:string;
windows:string;
}
static init(): AppRate;
static promptForRating(immediately?: boolean): AppRate;
static navigateToAppStore(): AppRate;
}
declare class CallbackPreferences {
onButtonClicked:(buttonIndex:number) => void;
onRateDialogShow:(rateCallback:(buttonIndex:number) => void) => void;
handleNegativeFeedback:() => void;
done:() => void;
}
export class AppRatePreferences {
useLanguage: string;
displayAppName: string;
promptAgainForEachNewVersion: boolean;
usesUntilPrompt: number;
reviewType: {
ios: 'AppStoreReview' | 'InAppReview' | 'InAppBrowser';
android: 'InAppReview' | 'InAppBrowser';
};
simpleMode: boolean;
callbacks: CallbackPreferences;
storeAppURL: StoreAppURLPreferences;
customLocale: CustomLocale;
openUrl: (url: string) => void;
}
declare class CustomLocale {
title:string;
message:string;
cancelButtonLabel:string;
laterButtonLabel:string;
rateButtonLabel:string;
yesButtonLabel:string;
noButtonLabel:string;
appRatePromptTitle:string;
feedbackPromptTitle:string;
appRatePromptMessage:string;
feedbackPromptMessage:string;
}
export class StoreAppURLPreferences {
ios: string;
android: string;
blackberry: string;
windows8: string;
windows: string;
}
declare class Locales {
addLocale(localeObject:Locale):Locale;
getLocale(language:string, applicationTitle?:string):Locale;
getLocalesNames():Array<string>;
}
export class CallbackPreferences {
onButtonClicked: (buttonIndex: number) => void;
onRateDialogShow: (rateCallback: (buttonIndex: number) => void) => void;
handleNegativeFeedback: () => void;
done: () => void;
}
declare class Locale {
constructor(localeOptions:LocaleOptions);
}
export class CustomLocale {
title: string;
message: string;
cancelButtonLabel: string;
laterButtonLabel: string;
rateButtonLabel: string;
yesButtonLabel: string;
noButtonLabel: string;
appRatePromptTitle: string;
feedbackPromptTitle: string;
appRatePromptMessage: string;
feedbackPromptMessage: string;
}
declare class LocaleOptions {
language:string
title:string;
message:string;
cancelButtonLabel:string;
laterButtonLabel:string;
rateButtonLabel:string;
yesButtonLabel:string;
noButtonLabel:string;
appRatePromptTitle:string;
feedbackPromptTitle:string;
appRatePromptMessage:string;
feedbackPromptMessage:string;
export class Locales {
addLocale(localeObject: Locale): Locale;
getLocale(language: string, applicationTitle?: string): Locale;
getLocalesNames(): Array<string>;
}
export class Locale {
constructor(localeOptions: LocaleOptions);
}
export class LocaleOptions {
language: string
title: string;
message: string;
cancelButtonLabel: string;
laterButtonLabel: string;
rateButtonLabel: string;
yesButtonLabel: string;
noButtonLabel: string;
appRatePromptTitle: string;
feedbackPromptTitle: string;
appRatePromptMessage: string;
feedbackPromptMessage: string;
}
}

@@ -21,24 +21,32 @@ /*

*/;
var AppRate, Locales, localeObj, exec, Storage;
var exec = require('cordova/exec');
var Locales = require('./locales');
var Storage = require('./storage')
Locales = require('./locales');
var AppRate = (function() {
exec = require('cordova/exec');
function noop(){}
Storage = require('./storage')
var localeObj;
var isNativePromptAvailable = false;
AppRate = (function() {
var FLAG_NATIVE_CODE_SUPPORTED, LOCAL_STORAGE_COUNTER, counter, getAppTitle, getAppVersion, showDialog, updateCounter;
function AppRate() {}
LOCAL_STORAGE_COUNTER = 'counter';
AppRate.initialized = false;
AppRate.ready = new Promise(function (resolve, reject) {
AppRate.readyResolve = resolve;
AppRate.readyReject = reject;
});
FLAG_NATIVE_CODE_SUPPORTED = /(iPhone|iPod|iPad|Android)/i.test(navigator.userAgent.toLowerCase());
var LOCAL_STORAGE_COUNTER = 'counter';
PREF_STORE_URL_PREFIX_IOS9 = "itms-apps://itunes.apple.com/app/viewContentsUserReviews/id";
PREF_STORE_URL_POSTFIX_IOS9 = "?action=write-review";
PREF_STORE_URL_FORMAT_IOS8 = "http://itunes.apple.com/WebObjects/MZStore.woa/wa/viewContentsUserReviews?pageNumber=0&sortOrdering=1&type=Purple+Software&mt=8&id=";
var IS_IOS = /(iPhone|iPod|iPad)/i.test(navigator.userAgent.toLowerCase());
var IS_ANDROID = /Android/i.test(navigator.userAgent.toLowerCase());
var FLAG_NATIVE_CODE_SUPPORTED = IS_IOS || IS_ANDROID;
counter = {
var PREF_STORE_URL_PREFIX_IOS9 = "itms-apps://itunes.apple.com/app/viewContentsUserReviews/id";
var PREF_STORE_URL_POSTFIX_IOS9 = "?action=write-review";
var PREF_STORE_URL_FORMAT_IOS8 = "http://itunes.apple.com/WebObjects/MZStore.woa/wa/viewContentsUserReviews?pageNumber=0&sortOrdering=1&type=Purple+Software&mt=8&id=";
var counter = {
applicationVersion: void 0,

@@ -48,3 +56,3 @@ countdown: 0

promptForAppRatingWindowButtonClickHandler = function (buttonIndex) {
function promptForAppRatingWindowButtonClickHandler(buttonIndex) {
var base = AppRate.preferences.callbacks, currentBtn = null;

@@ -67,5 +75,5 @@ switch (buttonIndex) {

return typeof base.onButtonClicked === "function" ? base.onButtonClicked(buttonIndex, currentBtn, "AppRatingPrompt") : function(){ };
};
}
promptForStoreRatingWindowButtonClickHandler = function(buttonIndex) {
function promptForStoreRatingWindowButtonClickHandler(buttonIndex) {
var base = AppRate.preferences.callbacks, currentBtn = null;

@@ -94,5 +102,5 @@ switch (buttonIndex) {

return typeof base.done === "function" ? base.done() : function(){ };
};
}
promptForFeedbackWindowButtonClickHandler = function(buttonIndex) {
function promptForFeedbackWindowButtonClickHandler(buttonIndex) {
var base = AppRate.preferences.callbacks, currentBtn = null;

@@ -111,5 +119,5 @@ switch (buttonIndex) {

return typeof base.onButtonClicked === "function" ? base.onButtonClicked(buttonIndex, currentBtn, "FeedbackPrompt") : function(){ };
};
}
updateCounter = function(action) {
function updateCounter(action) {
if (action == null) {

@@ -132,5 +140,5 @@ action = 'increment';

return counter;
};
}
showDialog = function(immediately) {
function showDialog(immediately) {
updateCounter();

@@ -140,3 +148,9 @@ if (counter.countdown === AppRate.preferences.usesUntilPrompt || immediately) {

if(AppRate.preferences.simpleMode) {
if (isNativePromptAvailable && AppRate.preferences.reviewType) {
if ((IS_IOS && AppRate.preferences.reviewType.ios === 'InAppReview')
|| (IS_ANDROID && AppRate.preferences.reviewType.android === 'InAppReview')) {
updateCounter('stop');
AppRate.navigateToAppStore();
}
} else if(AppRate.preferences.simpleMode) {
navigator.notification.confirm(localeObj.message, promptForStoreRatingWindowButtonClickHandler, localeObj.title, [localeObj.cancelButtonLabel, localeObj.laterButtonLabel, localeObj.rateButtonLabel]);

@@ -153,46 +167,77 @@ } else {

return AppRate;
};
}
getAppVersion = function(successCallback, errorCallback) {
if (FLAG_NATIVE_CODE_SUPPORTED) {
exec(successCallback, errorCallback, 'AppRate', 'getAppVersion', []);
} else {
successCallback(counter.applicationVersion);
}
return AppRate;
};
function getAppVersion() {
return new Promise(function (resolve, reject){
if (FLAG_NATIVE_CODE_SUPPORTED) {
exec(resolve, reject, 'AppRate', 'getAppVersion', []);
} else {
resolve(counter.applicationVersion);
}
});
}
getAppTitle = function(successCallback, errorCallback) {
if (FLAG_NATIVE_CODE_SUPPORTED) {
exec(successCallback, errorCallback, 'AppRate', 'getAppTitle', []);
} else {
successCallback(AppRate.preferences.displayAppName);
}
return AppRate;
};
function getAppTitle() {
return new Promise(function (resolve, reject){
if (FLAG_NATIVE_CODE_SUPPORTED) {
exec(resolve, reject, 'AppRate', 'getAppTitle', []);
} else {
resolve(AppRate.preferences.displayAppName);
}
});
}
function checkIsNativePromptAvailable() {
return new Promise(function (resolve, reject){
if (FLAG_NATIVE_CODE_SUPPORTED) {
exec(resolve, reject, 'AppRate', 'isNativePromptAvailable', []);
} else {
resolve(false);
}
});
}
AppRate.init = function() {
AppRate.ready = Promise.all([
Storage.get(LOCAL_STORAGE_COUNTER).then(function (storedCounter) {
counter = storedCounter || counter
})
])
getAppVersion((function(_this) {
return function(applicationVersion) {
var appVersionPromise = getAppVersion()
.then(function(applicationVersion) {
if (counter.applicationVersion !== applicationVersion) {
counter.applicationVersion = applicationVersion;
if (_this.preferences.promptAgainForEachNewVersion) {
if (AppRate.preferences.promptAgainForEachNewVersion) {
updateCounter('reset');
}
}
return _this;
};
})(this));
getAppTitle((function(_this) {
return function(displayAppName) {
_this.preferences.displayAppName = displayAppName;
return _this;
};
})(this));
})
.catch(noop);
var appTitlePromise = getAppTitle()
.then(function(displayAppName) {
AppRate.preferences.displayAppName = displayAppName;
})
.catch(noop);
var checkIsNativePromptAvailablePromise = checkIsNativePromptAvailable()
.then(function(isNativePromptAvailableResult) {
isNativePromptAvailable = isNativePromptAvailableResult;
})
.catch(function () {
isNativePromptAvailable = false;
});
var storagePromise = Storage.get(LOCAL_STORAGE_COUNTER).then(function (storedCounter) {
counter = storedCounter || counter
});
var initPromise = Promise.all([
checkIsNativePromptAvailablePromise,
appVersionPromise,
appTitlePromise,
storagePromise
]);
if (AppRate.initialized) {
AppRate.ready = initPromise;
} else {
AppRate.initialized = true;
initPromise
.then(AppRate.readyResolve)
.catch(AppRate.readyReject);
}
return this;

@@ -209,3 +254,6 @@ };

usesUntilPrompt: 3,
inAppReview: true,
reviewType: {
ios: 'AppStoreReview',
android: 'InAppBrowser'
},
callbacks: {

@@ -250,6 +298,7 @@ onButtonClicked: null,

if (/(iPhone|iPod|iPad)/i.test(navigator.userAgent.toLowerCase())) {
if (this.preferences.inAppReview) {
var showNativePrompt = true;
exec(null, null, 'AppRate', 'launchiOSReview', [this.preferences.storeAppURL.ios, showNativePrompt]);
if (IS_IOS) {
if (!this.preferences.reviewType || !this.preferences.reviewType.ios || this.preferences.reviewType.ios === 'AppStoreReview') {
exec(null, null, 'AppRate', 'launchiOSReview', [this.preferences.storeAppURL.ios, false]);
} else if (this.preferences.reviewType.ios === 'InAppReview') {
exec(null, null, 'AppRate', 'launchiOSReview', [this.preferences.storeAppURL.ios, true]);
} else {

@@ -263,8 +312,12 @@ iOSVersion = navigator.userAgent.match(/OS\s+([\d\_]+)/i)[0].replace(/_/g, '.').replace('OS ', '').split('.');

}
AppRate.preferences.openUrl(iOSStoreUrl);
AppRate.preferences.openUrl(iOSStoreUrl);
}
} else if (/(Android)/i.test(navigator.userAgent.toLowerCase())) {
AppRate.preferences.openUrl(this.preferences.storeAppURL.android);
} else if (IS_ANDROID) {
if (isNativePromptAvailable && this.preferences.reviewType && this.preferences.reviewType.android === 'InAppReview') {
exec(null, null, 'AppRate', 'launchReview', []);
} else {
AppRate.preferences.openUrl(this.preferences.storeAppURL.android);
}
} else if (/(Windows|Edge)/i.test(navigator.userAgent.toLowerCase())) {
Windows.Services.Store.StoreRequestHelper.sendRequestAsync(Windows.Services.Store.StoreContext.getDefault(), 16, "");
Windows.Services.Store.StoreRequestHelper.sendRequestAsync(Windows.Services.Store.StoreContext.getDefault(), 16, "");
} else if (/(BlackBerry)/i.test(navigator.userAgent.toLowerCase())) {

@@ -271,0 +324,0 @@ AppRate.preferences.openUrl(this.preferences.storeAppURL.blackberry);

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

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc