cordova-plugin-apprate
Advanced tools
Comparing version 1.4.0 to 1.5.0
# Changelog | ||
- UNRELEASED | ||
- Nothing yet | ||
- 1.5.0 | ||
- [PR #253](https://github.com/pushandplay/cordova-plugin-apprate/pull/253) - Remove iOS rating counter in favor of native approach | ||
- [PR #252](https://github.com/pushandplay/cordova-plugin-apprate/pull/252) - Postpone initial AppRate.init() until `deviceready` | ||
- [PR #239](https://github.com/pushandplay/cordova-plugin-apprate/pull/239) - Remove inappbrowser dependency adding support to choose between inappbrowser and safariviewcontroller | ||
- [PR #244](https://github.com/pushandplay/cordova-plugin-apprate/pull/244) - Use ES5 var instead of ES6 const for better browser compatibility | ||
- [PR #231](https://github.com/pushandplay/cordova-plugin-apprate/pull/231) - Displaying store view page before it loads for improved UX | ||
- [PR #228](https://github.com/pushandplay/cordova-plugin-apprate/pull/228) - Add native support for windows platform rating | ||
- [PR #220](https://github.com/pushandplay/cordova-plugin-apprate/pull/220) - Remove dependency on deprecated cordova-plugin-globalization in favor of browser `Intl` api | ||
- Various language fixes and improvements | ||
- [View All Merged PR's](https://github.com/pushandplay/cordova-plugin-apprate/compare/v1.4.0...master) | ||
@@ -6,0 +14,0 @@ - 1.4.0 |
{ | ||
"name": "cordova-plugin-apprate", | ||
"version": "1.4.0", | ||
"version": "1.5.0", | ||
"repository": { | ||
@@ -5,0 +5,0 @@ "type": "git", |
126
README.md
# Cordova-Plugin-Apprate | ||
<a href="https://badge.fury.io/js/cordova-plugin-apprate" target="_blank"><img height="21" style='border:0px;height:21px;' border='0' src="https://badge.fury.io/js/cordova-plugin-apprate.svg" alt="NPM Version"></a> | ||
<a href='https://www.npmjs.org/package/cordova-plugin-apprate' target='_blank'><img height='21' style='border:0px;height:21px;' src='https://img.shields.io/npm/dt/cordova-plugin-apprate.svg?label=NPM+Downloads' border='0' alt='NPM Downloads' /></a> | ||
@@ -14,2 +16,43 @@ A plugin to provide rate this app functionality into your cordova application | ||
## Installation Prerequisites | ||
Choose your preferred browser plugin which will be used to open the store and install it: | ||
- https://github.com/EddyVerbruggen/cordova-plugin-safariviewcontroller | ||
- https://github.com/apache/cordova-plugin-inappbrowser | ||
NOTE: If you chose inappbrowser then make sure to add `openUrl: AppRate.preferences.openUrl` option to preferences if you will override the preference object. And if you chose cordova-plugin-safariviewcontroller then you must configure it with this plugin by setting: | ||
```javascript | ||
AppRate.preferences.openUrl = function (url) { | ||
if (!window.SafariViewController) { | ||
window.open(url, '_blank', 'location=yes'); | ||
} | ||
else { | ||
SafariViewController.isAvailable(function (available) { | ||
if (available) { | ||
SafariViewController.show({ | ||
url: url, | ||
barColor: "#0000ff", // on iOS 10+ you can change the background color as well | ||
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 | ||
}, | ||
// this success handler will be invoked for the lifecycle events 'opened', 'loaded' and 'closed' | ||
function(result) { | ||
if (result.event === 'opened') { | ||
console.log('opened'); | ||
} else if (result.event === 'loaded') { | ||
console.log('loaded'); | ||
} else if (result.event === 'closed') { | ||
console.log('closed'); | ||
} | ||
}, | ||
function(msg) { | ||
console.log("error: " + msg); | ||
}) | ||
} else { | ||
window.open(url, '_blank', 'location=yes'); | ||
} | ||
}); | ||
} | ||
}; | ||
``` | ||
## Installation | ||
@@ -23,2 +66,4 @@ | ||
- 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 | ||
## Options / Preferences | ||
@@ -50,2 +95,4 @@ These options are available on the `AppRate.preferences` object. | ||
Note: windows does not need an URL as this is done by the native code. | ||
```javascript | ||
@@ -55,3 +102,2 @@ AppRate.preferences.storeAppURL = { | ||
android: 'market://details?id=<package_name>', | ||
windows: 'ms-windows-store://pdp/?ProductId=<the apps Store ID>', | ||
blackberry: 'appworld://content/[App Id]/', | ||
@@ -102,3 +148,3 @@ windows8: 'ms-windows-store:Review?name=<the Package Family Name of the application>' | ||
### Full setup | ||
### Full setup using SafariViewController | ||
@@ -142,5 +188,81 @@ ```javascript | ||
AppRate.preferences.openUrl = function (url) { | ||
if (!window.SafariViewController) { | ||
window.open(url, '_blank', 'location=yes'); | ||
} | ||
else { | ||
SafariViewController.isAvailable(function (available) { | ||
if (available) { | ||
SafariViewController.show({ | ||
url: url, | ||
barColor: "#0000ff", // on iOS 10+ you can change the background color as well | ||
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 | ||
}, | ||
// this success handler will be invoked for the lifecycle events 'opened', 'loaded' and 'closed' | ||
function(result) { | ||
if (result.event === 'opened') { | ||
console.log('opened'); | ||
} else if (result.event === 'loaded') { | ||
console.log('loaded'); | ||
} else if (result.event === 'closed') { | ||
console.log('closed'); | ||
} | ||
}, | ||
function(msg) { | ||
console.log("error: " + msg); | ||
}) | ||
} else { | ||
window.open(url, '_blank', 'location=yes'); | ||
} | ||
}); | ||
} | ||
}; | ||
AppRate.promptForRating(); | ||
``` | ||
### Full setup using inappbrowser | ||
```javascript | ||
AppRate.preferences = { | ||
displayAppName: 'My custom app title', | ||
usesUntilPrompt: 5, | ||
promptAgainForEachNewVersion: false, | ||
inAppReview: true, | ||
storeAppURL: { | ||
ios: '<my_app_id>', | ||
android: 'market://details?id=<package_name>', | ||
windows: 'ms-windows-store://pdp/?ProductId=<the apps Store ID>', | ||
blackberry: 'appworld://content/[App Id]/', | ||
windows8: 'ms-windows-store:Review?name=<the Package Family Name of the application>' | ||
}, | ||
customLocale: { | ||
title: "Would you mind rating %@?", | ||
message: "It won’t take more than a minute and helps to promote our app. Thanks for your support!", | ||
cancelButtonLabel: "No, Thanks", | ||
laterButtonLabel: "Remind Me Later", | ||
rateButtonLabel: "Rate It Now", | ||
yesButtonLabel: "Yes!", | ||
noButtonLabel: "Not really", | ||
appRatePromptTitle: 'Do you like using %@', | ||
feedbackPromptTitle: 'Mind giving us some feedback?', | ||
}, | ||
callbacks: { | ||
handleNegativeFeedback: function(){ | ||
window.open('mailto:feedback@example.com','_system'); | ||
}, | ||
onRateDialogShow: function(callback){ | ||
callback(1) // cause immediate click on 'Rate Now' button | ||
}, | ||
onButtonClicked: function(buttonIndex){ | ||
console.log("onButtonClicked -> " + buttonIndex); | ||
} | ||
}, | ||
openUrl: AppRate.preferences.openUrl | ||
}; | ||
AppRate.promptForRating(); | ||
``` | ||
### Access to locales | ||
@@ -147,0 +269,0 @@ |
@@ -30,3 +30,3 @@ /* | ||
AppRate = (function() { | ||
var FLAG_NATIVE_CODE_SUPPORTED, LOCAL_STORAGE_COUNTER, PREF_STORE_URL_FORMAT_IOS, counter, getAppTitle, getAppVersion, promptForRatingWindowButtonClickHandler, showDialog, updateCounter; | ||
var FLAG_NATIVE_CODE_SUPPORTED, LOCAL_STORAGE_COUNTER, counter, getAppTitle, getAppVersion, showDialog, updateCounter; | ||
@@ -36,3 +36,2 @@ function AppRate() {} | ||
LOCAL_STORAGE_COUNTER = 'counter'; | ||
LOCAL_STORAGE_IOS_RATING = 'iosRating'; | ||
@@ -50,7 +49,2 @@ FLAG_NATIVE_CODE_SUPPORTED = /(iPhone|iPod|iPad|Android)/i.test(navigator.userAgent.toLowerCase()); | ||
var iOSRating = { | ||
timesPrompted: 0, | ||
lastPromptDate: null | ||
}; | ||
promptForAppRatingWindowButtonClickHandler = function (buttonIndex) { | ||
@@ -138,15 +132,4 @@ var base = AppRate.preferences.callbacks, currentBtn = null; | ||
updateiOSRatingData = function() { | ||
if (checkIfDateIsAfter(iOSRating.lastPromptDate, 365)) { | ||
iOSRating.timesPrompted = 0; | ||
} | ||
iOSRating.timesPrompted++; | ||
iOSRating.lastPromptDate = new Date(); | ||
Storage.set(LOCAL_STORAGE_IOS_RATING, iOSRating); | ||
} | ||
showDialog = function(immediately) { | ||
var base = AppRate.preferences.callbacks; | ||
updateCounter(); | ||
if (counter.countdown === AppRate.preferences.usesUntilPrompt || immediately) { | ||
@@ -161,2 +144,3 @@ localeObj = Locales.getLocale(AppRate.preferences.useLanguage, AppRate.preferences.displayAppName, AppRate.preferences.customLocale); | ||
var base = AppRate.preferences.callbacks; | ||
if (typeof base.onRateDialogShow === "function") { | ||
@@ -191,9 +175,2 @@ base.onRateDialogShow(promptForStoreRatingWindowButtonClickHandler); | ||
counter = storedCounter || counter | ||
}), | ||
Storage.get(LOCAL_STORAGE_IOS_RATING).then(function (storedRating) { | ||
iOSRating = storedRating || iOSRating | ||
if (iOSRating.lastPromptDate) { | ||
iOSRating.lastPromptDate = new Date(iOSRating.lastPromptDate); | ||
} | ||
}) | ||
@@ -244,3 +221,6 @@ ]) | ||
}, | ||
customLocale: null | ||
customLocale: null, | ||
openUrl: function (url) { | ||
cordova.InAppBrowser.open(url, '_system', 'location=no'); | ||
} | ||
}; | ||
@@ -253,13 +233,9 @@ | ||
} | ||
if (AppRate.preferences.useLanguage === null) { | ||
navigator.globalization.getPreferredLanguage((function(_this) { | ||
return function(language) { | ||
_this.preferences.useLanguage = language.value; | ||
return showDialog(immediately); | ||
}; | ||
})(AppRate)); | ||
} else { | ||
showDialog(immediately); | ||
// see also: https://cordova.apache.org/news/2017/11/20/migrate-from-cordova-globalization-plugin.html | ||
if (AppRate.preferences.useLanguage === null && window.Intl && typeof window.Intl === 'object') { | ||
AppRate.preferences.useLanguage = window.navigator.language; | ||
} | ||
updateCounter(); | ||
showDialog(immediately); | ||
}); | ||
@@ -275,4 +251,3 @@ return this; | ||
if (this.preferences.inAppReview) { | ||
updateiOSRatingData(); | ||
var showNativePrompt = iOSRating.timesPrompted < 3; | ||
var showNativePrompt = true; | ||
exec(null, null, 'AppRate', 'launchiOSReview', [this.preferences.storeAppURL.ios, showNativePrompt]); | ||
@@ -287,12 +262,12 @@ } else { | ||
} | ||
cordova.InAppBrowser.open(iOSStoreUrl, '_system', 'location=no'); | ||
AppRate.preferences.openUrl(iOSStoreUrl); | ||
} | ||
} else if (/(Android)/i.test(navigator.userAgent.toLowerCase())) { | ||
cordova.InAppBrowser.open(this.preferences.storeAppURL.android, '_system', 'location=no'); | ||
AppRate.preferences.openUrl(this.preferences.storeAppURL.android); | ||
} else if (/(Windows|Edge)/i.test(navigator.userAgent.toLowerCase())) { | ||
cordova.InAppBrowser.open(this.preferences.storeAppURL.windows, '_blank', 'location=no'); | ||
Windows.Services.Store.StoreRequestHelper.sendRequestAsync(Windows.Services.Store.StoreContext.getDefault(), 16, ""); | ||
} else if (/(BlackBerry)/i.test(navigator.userAgent.toLowerCase())) { | ||
cordova.InAppBrowser.open(this.preferences.storeAppURL.blackberry, '_system', 'location=no'); | ||
AppRate.preferences.openUrl(this.preferences.storeAppURL.blackberry); | ||
} else if (/(IEMobile|Windows Phone)/i.test(navigator.userAgent.toLowerCase())) { | ||
cordova.InAppBrowser.open(this.preferences.storeAppURL.windows8, '_system', 'location=no'); | ||
AppRate.preferences.openUrl(this.preferences.storeAppURL.windows8); | ||
} | ||
@@ -306,16 +281,6 @@ return this; | ||
AppRate.init(); | ||
document.addEventListener("deviceready", function() { | ||
AppRate.init(); | ||
}, false) | ||
function checkIfDateIsAfter(date, minimumDifference) { | ||
if (!date) { | ||
return false; | ||
} | ||
const dateTimestamp = date.getTime(); | ||
const todayTimestamp = new Date().getTime(); | ||
const differenceInDays = Math.abs((todayTimestamp - dateTimestamp) / (3600 * 24 * 1000)); | ||
return differenceInDays > minimumDifference; | ||
} | ||
module.exports = AppRate; |
@@ -57,2 +57,3 @@ /* | ||
localeObject = customLocale || locales[language] || locales[language.split(/-/)[0]] || locales[LOCALE_DEFAULT]; | ||
localeObject = Object.assign({}, locales[LOCALE_DEFAULT], localeObject); //use entries of default locale as fallback for unset entries | ||
localeObject.title = localeObject.title.replace(/%@/g, applicationTitle); | ||
@@ -92,18 +93,13 @@ localeObject.appRatePromptTitle = (localeObject.appRatePromptTitle || '').replace(/%@/g, applicationTitle); | ||
title: "রেট %@", | ||
message: "আপনি %@ ব্যবহার করে ভোগ, আপনি এটি রেট একটি মুহূর্ত গ্রহণ কিছু মনে করবে? এটি একটি মিনিট চেয়ে বেশি গ্রহণ করা হবে না. আপনার সমর্থনের জন্য ধন্যবাদ!", | ||
message: "মাত্র এক মিনিট ব্যয় করুন এবং আমাদের এ্যপের প্রচারে সহায়তা করুন। আপনার সহযোগীতার জন্য ধন্যবাদ", | ||
cancelButtonLabel: "না, ধন্যবাদ", | ||
laterButtonLabel: "পরে আমাকে মনে করিয়ে দিন", | ||
rateButtonLabel: "এখন এটি রেটিং করুন" | ||
laterButtonLabel: "আমাকে পরে মনে করিয়ে দিন", | ||
rateButtonLabel: "এখন এটি রেটিং দিন", | ||
yesButtonLabel: "হ্যাঁ!", | ||
noButtonLabel: "সত্যিই না", | ||
appRatePromptTitle: '%@ ব্যবহার করে ভালো লেগেছে কি?', | ||
feedbackPromptTitle: 'কিছু মতামত দিবেন কি?', | ||
})); | ||
Locales.addLocale(new Locale({ | ||
language: 'bn', | ||
title: "রেট %@", | ||
message: "আপনি %@ ব্যবহার করে ভোগ, আপনি এটি রেট একটি মুহূর্ত গ্রহণ কিছু মনে করবে? এটি একটি মিনিট চেয়ে বেশি গ্রহণ করা হবে না. আপনার সমর্থনের জন্য ধন্যবাদ!", | ||
cancelButtonLabel: "না, ধন্যবাদ", | ||
laterButtonLabel: "পরে আমাকে মনে করিয়ে দিন", | ||
rateButtonLabel: "এখন এটি রেটিং করুন" | ||
})); | ||
Locales.addLocale(new Locale({ | ||
language: 'ca', | ||
@@ -141,3 +137,9 @@ title: "Ressenya %@", | ||
laterButtonLabel: "Später erinnern", | ||
rateButtonLabel: "Jetzt bewerten" | ||
rateButtonLabel: "Jetzt bewerten", | ||
yesButtonLabel: "Ja!", | ||
noButtonLabel: "Nicht wirklich", | ||
appRatePromptTitle: 'Gefällt dir %@', | ||
feedbackPromptTitle: 'Würdest du uns eine kurze Rückmeldung geben?', | ||
appRatePromptMessage:'', | ||
feedbackPromptMessage:'' | ||
})); | ||
@@ -151,3 +153,9 @@ | ||
laterButtonLabel: "Später erinnern", | ||
rateButtonLabel: "Jetzt bewerten" | ||
rateButtonLabel: "Jetzt bewerten", | ||
yesButtonLabel: "Ja!", | ||
noButtonLabel: "Nicht wirklich", | ||
appRatePromptTitle: 'Gefällt dir %@', | ||
feedbackPromptTitle: 'Würdest du uns eine kurze Rückmeldung geben?', | ||
appRatePromptMessage:'', | ||
feedbackPromptMessage:'' | ||
})); | ||
@@ -185,6 +193,27 @@ | ||
laterButtonLabel: "Recordarme más tarde", | ||
rateButtonLabel: "Escribir reseña ahora" | ||
rateButtonLabel: "Escribir reseña ahora", | ||
yesButtonLabel: "Si", | ||
noButtonLabel: "No", | ||
appRatePromptTitle: "¿Te gusta %@?", | ||
feedbackPromptTitle: "¿Darías tu opinión?", | ||
appRatePromptMessage:"", | ||
feedbackPromptMessage:"" | ||
})); | ||
Locales.addLocale(new Locale({ | ||
language: 'eu', | ||
title: "%@ iruzkindu nahi?", | ||
message: "%@ gustuko baduzu asko eskertuko genuke zure iruzkina, minutu bat baino gutxiago izango da. Eskerrik asko zure laguntzagatik!", | ||
cancelButtonLabel: "Ez, Eskerrik asko", | ||
laterButtonLabel: "Beranduago gogoratu", | ||
rateButtonLabel: "Iruzkindu orain", | ||
yesButtonLabel: "Bai!", | ||
noButtonLabel: "Ez", | ||
appRatePromptTitle: 'Gustuko duzu %@ ?', | ||
feedbackPromptTitle: 'Iruzkin bat lagatzerik nahi?', | ||
appRatePromptMessage:'', | ||
feedbackPromptMessage:'' | ||
})); | ||
Locales.addLocale(new Locale({ | ||
language: 'fa', | ||
@@ -213,3 +242,9 @@ title: "نرخ %@", | ||
laterButtonLabel: "Me le rappeler ultérieurement", | ||
rateButtonLabel: "Votez maintenant" | ||
rateButtonLabel: "Votez maintenant", | ||
yesButtonLabel: "Oui", | ||
noButtonLabel: "Non, merci", | ||
appRatePromptTitle: "Vous aimez %@", | ||
feedbackPromptTitle: "Voulez-vous voter sur l'App Store?", | ||
appRatePromptMessage:"", | ||
feedbackPromptMessage:"" | ||
})); | ||
@@ -250,3 +285,9 @@ | ||
laterButtonLabel: "Più tardi", | ||
rateButtonLabel: "Valuta ora" | ||
rateButtonLabel: "Valuta ora", | ||
yesButtonLabel: "Si", | ||
noButtonLabel: "No", | ||
appRatePromptTitle: "Ti piace %@", | ||
feedbackPromptTitle: "Daresti il tuo giudizio?", | ||
appRatePromptMessage:"", | ||
feedbackPromptMessage:"" | ||
})); | ||
@@ -344,3 +385,7 @@ | ||
laterButtonLabel: "Напомнить позже", | ||
rateButtonLabel: "Оценить сейчас" | ||
rateButtonLabel: "Оценить сейчас", | ||
yesButtonLabel: "Да!", | ||
noButtonLabel: "Нет", | ||
appRatePromptTitle: "Вам нравится приложение?", | ||
feedbackPromptTitle: "Не могли бы вы дать нам обратную связь?" | ||
})); | ||
@@ -395,7 +440,13 @@ | ||
language: 'tr', | ||
title: "Oy %@", | ||
message: "Eğer %@ uygulamamız hoşunuza gittiyse, oy vermek ister misiniz? Bir dakikadan fazla sürmeyecektir. Desteğiniz için teşekkürler!", | ||
title: "%@ Uygulamamızı değerlendirmek ister misiniz?", | ||
message: "Bir dakikadan fazla sürmeyecektir ve uygulamamızı tanıtmamıza yardımcı olacaktır. Desteğiniz için teşekkürler!", | ||
cancelButtonLabel: "Teşekkürler, Hayır", | ||
laterButtonLabel: "Sonra Hatırlat", | ||
rateButtonLabel: "Şimdi Oyla" | ||
rateButtonLabel: "Şimdi Değerlendir", | ||
yesButtonLabel: "Evet!", | ||
noButtonLabel: "Pek Değil", | ||
appRatePromptTitle: '%@ kullanmayı seviyor musunuz ?', | ||
feedbackPromptTitle: 'Geribildirim vermek ister misiniz?', | ||
appRatePromptMessage:'', | ||
feedbackPromptMessage:'' | ||
})); | ||
@@ -409,3 +460,7 @@ | ||
laterButtonLabel: "Нагадати пізніше", | ||
rateButtonLabel: "Оцінити зараз" | ||
rateButtonLabel: "Оцінити зараз", | ||
yesButtonLabel: "Так!", | ||
noButtonLabel: "Ні", | ||
appRatePromptTitle: "Вам подобається додаток?", | ||
feedbackPromptTitle: "Чи не могли б ви дати нам зворотний зв'язок?" | ||
})); | ||
@@ -412,0 +467,0 @@ |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
71017
852
280
13