Skip to content

Commit

Permalink
v1.3.0
Browse files Browse the repository at this point in the history
  • Loading branch information
westonganger committed May 9, 2017
1 parent e092466 commit c0ed9c0
Show file tree
Hide file tree
Showing 6 changed files with 105 additions and 103 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
# Changelog
- 1.3.0
- Added a general done callbacks called once we have completed the job, not showing or showing the popup
- Fix %@ with customLocale
- Fix bugs with callbacks
- Fix deep links on ios 9+
- Locales updates
- 1.2.1
- Align the version in the package.json and the plugin.xml
- 1.2.0
Expand Down
104 changes: 50 additions & 54 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,67 +1,57 @@
# cordova-plugin-apprate
# Cordova-Plugin-Apprate

This plugin provide the rate this app functionality into your Cordova/Phonegap application<br>
A plugin to provide rate this app functionality into your Cordova / Phonegap application<br>

[Donate with PayPal](https://www.paypal.com/cgi-bin/webscr?cmd=_donations&business=MS8RQAS2NVVQW&lc=RU&item_name=github%2ecom&item_number=cordova%2dplugin%2dapprate&currency_code=USD&bn=PP%2dDonationsBF%3abtn_donateCC_LG%2egif%3aNonHosted)

**PR's are greatly appreciated. If your interested in maintainer status please create a couple PR's and then contact westonganger@gmail.com**
**PR's are greatly appreciated**


<img src="https://dl.dropboxusercontent.com/u/26238/Cordova/Plugins/AppRate/preview_iPad.png" width="100%" alt="Preview iPad"/>

### Some Articles on the Importance of App Reviews and Ratings ###

+ [Begging For App Ratings](http://www.loopinsight.com/2014/02/04/begging-for-app-ratings/)
+ [Choices And Consequences](http://bitsplitting.org/2013/12/11/choices-and-consequences/)
+ [The importance of App Store reviews](http://www.cowlyowl.com/blog/app-store-reviews)
+ [The Rate Friday Initiative](http://blog.edovia.com/2014/01/03/the-rate-friday-initiative/)
+ [Prompting for App Reviews](http://dancounsell.com/articles/prompting-for-app-reviews)

## Supported platforms ##
## Supported platforms

- iOS
- Android
- Windows (experimental)
- Blackberry (experimental)
- Windows8 (experimental)
- Windows
- Blackberry

## Requirements ##
## Requirements

Phonegap / Cordova 3.0.0 or later
Cordova 3.0.0 or later

## Installation ##
## Installation

- From apache cordova plugins registry: `cordova plugins add cordova-plugin-apprate`
- From github repository: `cordova plugins add https://github.com/pushandplay/cordova-plugin-apprate.git`
- From github repository: `cordova plugins add https://github.com/pushandplay/cordova-plugin-apprate.git`
- From phonegap build add the following to your config.xml: `<gap:plugin name="cordova-plugin-apprate" />`

## Customization and usage ##
## Customization and usage

#### Note ####
All `%@` patterns in customLocale object will be automatically replaced to your application title
## Options / Preferences
These options are available on the `AppRate.preferences` object.

#### Available preferences options ####
Note: All `%@` patterns in customLocale object will be automatically replaced to your application title

| Option | Type | Default | Description |
| :------ | :---- | :------- | :----------- |
| useLanguage | {String} | null | custom BCP 47 language tag |
| displayAppName | {String} | '' | custom application title |
| promptAgainForEachNewVersion | {Boolean} | true | show dialog again when application version will be updated |
| usesUntilPrompt | {Integer} | 3 | count of runs of application before dialog will be displayed |
| openStoreInApp | {Boolean} | false | leave app or no when application page opened in app store (now supported only for iOS) |
| useCustomRateDialog | {Boolean} | false | use custom view for rate dialog |
| callbacks.onButtonClicked | {Function} | null | call back function. called when user clicked on rate-dialog buttons |
| callbacks.onRateDialogShow | {Function} | null | call back function. called when rate-dialog showing |
| storeAppURL.ios | {String} | null | application id in AppStore |
| storeAppURL.android | {String} | null | application URL in GooglePlay |
| storeAppURL.windows | {String} | null | application URL in Windows Store |
| storeAppURL.blackberry | {String} | null | application URL in AppWorld |
| storeAppURL.windows8 | {String} | null | application URL in WindowsStore |
| customLocale | {Object} | null | custom locale object |

## Examples ##

#### Simple setup and call ####
| useLanguage | String | null | custom BCP 47 language tag |
| displayAppName | String | '' | custom application title |
| promptAgainForEachNewVersion | Boolean | true | show dialog again when application version will be updated |
| usesUntilPrompt | Integer | 3 | count of runs of application before dialog will be displayed |
| openStoreInApp | Boolean | false | leave app or no when application page opened in app store (now supported only for iOS) |
| useCustomRateDialog | Boolean | false | use custom view for rate dialog |
| callbacks.onButtonClicked | Function | null | call back function. called when user clicked on rate-dialog buttons |
| callbacks.onRateDialogShow | Function | null | call back function. called when rate-dialog showing |
| storeAppURL.ios | String | null | application id in AppStore |
| storeAppURL.android | String | null | application URL in GooglePlay |
| storeAppURL.windows | String | null | application URL in Windows Store |
| storeAppURL.blackberry | String | null | application URL in AppWorld |
| storeAppURL.windows8 | String | null | application URL in WindowsStore |
| customLocale | Object | null | custom locale object |

## Examples

Makes sure all your calls to the plugin happen after the cordova `onDeviceReady` event has fired.

### Simple setup and call

```javascript
AppRate.preferences.storeAppURL = {
Expand All @@ -75,28 +65,28 @@ AppRate.preferences.storeAppURL = {
AppRate.promptForRating();
```

#### Don't Call rate dialog immediately ####
### Don't Call rate dialog immediately

```javascript
AppRate.promptForRating(false);
```
If false is not present it will ignore usesUntilPrompt, promptAgainForEachNewVersion, and button logic, it will prompt every time.

#### Override dialog button callback ####
### Override dialog button callback

```javascript
AppRate.preferences.callbacks.onButtonClicked = function(buttonIndex) {
console.log("onButtonClicked -> " + buttonIndex);
};
```

#### Set custom language ####
### Set custom language

```javascript
AppRate.preferences.useLanguage = 'ru';
```

#### Set custom Locale object ####
### Set custom Locale object

```javascript
AppRate.preferences.customLocale = {
Expand All @@ -108,7 +98,7 @@ AppRate.preferences.customLocale = {
};
```

#### Full setup ####
### Full setup

```javascript
AppRate.preferences = {
Expand All @@ -135,7 +125,7 @@ AppRate.preferences = {
AppRate.promptForRating();
```

#### Callbacks setup and use custom rate-dialog ####
### Callbacks setup and use custom rate-dialog

```javascript
AppRate.preferences = {
Expand All @@ -151,10 +141,7 @@ AppRate.preferences = {
};
```

## Already included translations ##
https://github.com/pushandplay/cordova-plugin-apprate/blob/master/www/locales.js

#### Access to locales ####
### Access to locales

```javascript
// Getting list of names for available locales
Expand All @@ -163,3 +150,12 @@ AppRate.locales.getLocalesNames();
// Getting locale object by name
AppRate.locales.getLocale('en');
```

### List of translations
https://github.com/pushandplay/cordova-plugin-apprate/blob/master/www/locales.js

# Credits

Currently maintained by [@westonganger](https://github.com/westonganger)

Created by [@pushandplay](https://github.com/pushandplay)
1 change: 1 addition & 0 deletions plugin.xml
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ under the License.

<dependency id="cordova-plugin-dialogs"/>
<dependency id="cordova-plugin-globalization"/>
<dependency id="cordova-plugin-inappbrowser"/>

<js-module src="www/AppRate.js" name="AppRate">
<clobbers target="AppRate"/>
Expand Down
75 changes: 38 additions & 37 deletions typescript/AppRate.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,62 +19,63 @@
*
*/
declare class AppRate {
static locales:Locales;
static preferences:AppRatePreferences;
static init():AppRate;
static promptForRating(immediately?:boolean):AppRate;
static navigateToAppStore():AppRate;
static locales:Locales;
static preferences:AppRatePreferences;

static init():AppRate;
static promptForRating(immediately?:boolean):AppRate;
static navigateToAppStore():AppRate;
}

declare class AppRatePreferences {
useLanguage:string;
displayAppName:string;
promptAgainForEachNewVersion:boolean;
usesUntilPrompt:number;
openStoreInApp:boolean;
useCustomRateDialog:boolean;
callbacks:CallbackPreferences;
storeAppURL:StoreAppURLPreferences;
customLocale:CustomLocale;
useLanguage:string;
displayAppName:string;
promptAgainForEachNewVersion:boolean;
usesUntilPrompt:number;
openStoreInApp:boolean;
useCustomRateDialog:boolean;
callbacks:CallbackPreferences;
storeAppURL:StoreAppURLPreferences;
customLocale:CustomLocale;
}

declare class StoreAppURLPreferences {
ios:string;
android:string;
blackberry:string;
windows8:string;
windows:string;
ios:string;
android:string;
blackberry:string;
windows8:string;
windows:string;
}

declare class CallbackPreferences {
onButtonClicked:(buttonIndex:number) => void;
onRateDialogShow:(rateCallback:(buttonIndex:number) => void) => void;
onButtonClicked:(buttonIndex:number) => void;
onRateDialogShow:(rateCallback:(buttonIndex:number) => void) => void;
done:() => void;
}

declare class CustomLocale {
title:string;
message:string;
cancelButtonLabel:string;
laterButtonLabel:string;
rateButtonLabel:string;
title:string;
message:string;
cancelButtonLabel:string;
laterButtonLabel:string;
rateButtonLabel:string;
}

declare class Locales {
addLocale(localeObject:Locale):Locale;
getLocale(language:string, applicationTitle?:string):Locale;
getLocalesNames():Array<string>;
addLocale(localeObject:Locale):Locale;
getLocale(language:string, applicationTitle?:string):Locale;
getLocalesNames():Array<string>;
}

declare class Locale {
constructor(localeOptions:LocaleOptions);
constructor(localeOptions:LocaleOptions);
}

declare class LocaleOptions {
language:string
title:string;
message:string;
cancelButtonLabel:string;
laterButtonLabel:string;
rateButtonLabel:string;
language:string
title:string;
message:string;
cancelButtonLabel:string;
laterButtonLabel:string;
rateButtonLabel:string;
}
20 changes: 10 additions & 10 deletions www/AppRate.js
Original file line number Diff line number Diff line change
Expand Up @@ -58,9 +58,9 @@ AppRate = (function() {
updateCounter('stop');
}
//This is called only in case the user clicked on a button
typeof (base = AppRate.preferences.callbacks).onButtonClicked === "function" ? base.onButtonClicked(buttonIndex) : void 0;
typeof (base = AppRate.preferences.callbacks).onButtonClicked === "function" ? base.onButtonClicked(buttonIndex) : function(){ };
//This one is called anyway once the process is done
return typeof (base = AppRate.preferences.callbacks).done === "function" ? base.done() : void 0;
return typeof (base = AppRate.preferences.callbacks).done === "function" ? base.done() : function(){ };
};

updateCounter = function(action) {
Expand All @@ -87,14 +87,14 @@ AppRate = (function() {
var base, localeObj;
if (counter.countdown === AppRate.preferences.usesUntilPrompt || immediately) {
if (!AppRate.preferences.useCustomRateDialog) {
localeObj = AppRate.preferences.customLocale || Locales.getLocale(AppRate.preferences.useLanguage, AppRate.preferences.displayAppName);
localeObj = Locales.getLocale(AppRate.preferences.useLanguage, AppRate.preferences.displayAppName, AppRate.preferences.customLocale);
navigator.notification.confirm(localeObj.message, promptForRatingWindowButtonClickHandler, localeObj.title, [localeObj.rateButtonLabel, localeObj.laterButtonLabel, localeObj.cancelButtonLabel]);
}
if (typeof (base = AppRate.preferences.callbacks).onRateDialogShow === "function") {
base.onRateDialogShow(promptForRatingWindowButtonClickHandler);
}
}else{
typeof (base = AppRate.preferences.callbacks).done === "function" ? base.done() : void 0;
typeof (base = AppRate.preferences.callbacks).done === "function" ? base.done() : function(){ };
}
return AppRate;
};
Expand Down Expand Up @@ -175,7 +175,7 @@ AppRate = (function() {
callbacks: {
onButtonClicked: null,
onRateDialogShow: null,
done:null
done: null
},
storeAppURL: {
ios: null,
Expand Down Expand Up @@ -219,16 +219,16 @@ AppRate = (function() {
} else {
PREF_STORE_URL_FORMAT_IOS = PREF_STORE_URL_FORMAT_IOS9;
}
window.open(PREF_STORE_URL_FORMAT_IOS + this.preferences.storeAppURL.ios, '_system');
cordova.InAppBrowser.open(PREF_STORE_URL_FORMAT_IOS + this.preferences.storeAppURL.ios, '_system', 'location=no');
}
} else if (/(Android)/i.test(navigator.userAgent.toLowerCase())) {
window.open(this.preferences.storeAppURL.android, '_system');
cordova.InAppBrowser.open(this.preferences.storeAppURL.android, '_system', 'location=no');
} else if (/(Windows|Edge)/i.test(navigator.userAgent.toLowerCase())) {
window.open(this.preferences.storeAppURL.windows, '_blank');
cordova.InAppBrowser.open(this.preferences.storeAppURL.windows, '_blank', 'location=no');
} else if (/(BlackBerry)/i.test(navigator.userAgent.toLowerCase())) {
window.open(this.preferences.storeAppURL.blackberry, '_system');
cordova.InAppBrowser.open(this.preferences.storeAppURL.blackberry, '_system', 'location=no');
} else if (/(IEMobile|Windows Phone)/i.test(navigator.userAgent.toLowerCase())) {
window.open(this.preferences.storeAppURL.windows8, '_system');
cordova.InAppBrowser.open(this.preferences.storeAppURL.windows8, '_system', 'location=no');
}
return this;
};
Expand Down
4 changes: 2 additions & 2 deletions www/locales.js
Original file line number Diff line number Diff line change
Expand Up @@ -44,12 +44,12 @@ Locales = (function() {
return locales[localeObject.language] = localeObject;
};

Locales.getLocale = function(language, applicationTitle) {
Locales.getLocale = function(language, applicationTitle, customLocale) {
var localeObject;
if (applicationTitle == null) {
applicationTitle = '';
}
localeObject = locales[language] || locales[language.split(/-/)[0]] || locales[LOCALE_DEFAULT];
localeObject = customLocale || locales[language] || locales[language.split(/-/)[0]] || locales[LOCALE_DEFAULT];
localeObject.title = localeObject.title.replace(/%@/g, applicationTitle);
localeObject.message = localeObject.message.replace(/%@/g, applicationTitle);
return localeObject;
Expand Down

0 comments on commit c0ed9c0

Please sign in to comment.