2016-07-08 00:33:07 +02:00
|
|
|
import { Cordova, CordovaProperty, Plugin } from './plugin';
|
|
|
|
|
2016-03-04 13:56:22 -06:00
|
|
|
declare var window;
|
2016-02-17 04:17:40 -05:00
|
|
|
|
2016-12-06 08:41:36 -05:00
|
|
|
export interface AppRatePreferences {
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Custom BCP 47 language tag
|
|
|
|
*/
|
|
|
|
useLanguage?: string;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Custom application title
|
|
|
|
*/
|
|
|
|
displayAppName?: string;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Show dialog again when application version will be updated. Defaults to `true`
|
|
|
|
*/
|
|
|
|
promptAgainForEachNewVersion?: boolean;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* count of runs of application before dialog will be displayed. Defaults to `3`
|
|
|
|
*/
|
|
|
|
usesUntilPrompt?: number;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* leave app or no when application page opened in app store (now supported only for iOS). Defaults to `false`
|
|
|
|
*/
|
|
|
|
openStoreInApp?: boolean;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* use custom view for rate dialog. Defaults to `false`
|
|
|
|
*/
|
|
|
|
useCustomRateDialog?: boolean;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Custom locale object
|
|
|
|
*/
|
|
|
|
customLocale?: any;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Callbacks for events
|
|
|
|
*/
|
|
|
|
callbacks?: AppRateCallbacks;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* App Store URLS
|
|
|
|
*/
|
|
|
|
storeAppUrl?: AppRateStoreAppUrls;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
export interface AppRateCallbacks {
|
|
|
|
|
|
|
|
/**
|
|
|
|
* call back function. called when user clicked on rate-dialog buttons
|
|
|
|
*/
|
|
|
|
onButtonClicked?: Function;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* call back function. called when rate-dialog showing
|
|
|
|
*/
|
|
|
|
onRateDialogShowed?: Function;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
export interface AppRateStoreAppUrls {
|
|
|
|
|
|
|
|
/**
|
|
|
|
* application id in AppStore
|
|
|
|
*/
|
|
|
|
ios?: string;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* application URL in GooglePlay
|
|
|
|
*/
|
|
|
|
android?: string;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* application URL in AppWorld
|
|
|
|
*/
|
|
|
|
blackberry?: string;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* application URL in WindowsStore
|
|
|
|
*/
|
|
|
|
windows8?: string;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
2016-02-17 04:17:40 -05:00
|
|
|
/**
|
2016-03-13 15:45:07 -04:00
|
|
|
* @name App Rate
|
2016-03-12 18:30:16 -05:00
|
|
|
* @description
|
2016-02-17 04:17:40 -05:00
|
|
|
* The AppRate plugin makes it easy to prompt the user to rate your app, either now, later, or never.
|
|
|
|
*
|
2016-03-04 15:42:21 -06:00
|
|
|
* Requires Cordova plugin: cordova-plugin-apprate. For more info, please see the [AppRate plugin docs](https://github.com/pushandplay/cordova-plugin-apprate).
|
2016-02-17 04:17:40 -05:00
|
|
|
*
|
|
|
|
* @usage
|
2016-07-20 17:17:09 +02:00
|
|
|
* ```typescript
|
|
|
|
* import { AppRate } from 'ionic-native';
|
2016-03-24 13:00:18 -04:00
|
|
|
*
|
2016-08-01 14:01:54 -04:00
|
|
|
* AppRate.preferences.storeAppURL = {
|
|
|
|
* ios: '<my_app_id>',
|
|
|
|
* android: 'market://details?id=<package_name>',
|
|
|
|
* };
|
2016-03-24 13:00:18 -04:00
|
|
|
*
|
2016-11-09 01:02:10 +03:00
|
|
|
* AppRate.promptForRating(false);
|
2016-02-17 04:17:40 -05:00
|
|
|
* ```
|
2016-07-01 15:16:52 -04:00
|
|
|
*
|
2016-12-06 08:41:36 -05:00
|
|
|
* @interfaces
|
|
|
|
* AppRatePreferences
|
|
|
|
* AppRateStoreAppUrls
|
|
|
|
* AppRateCallbacks
|
2016-07-01 15:16:52 -04:00
|
|
|
*
|
2016-02-17 04:17:40 -05:00
|
|
|
*/
|
|
|
|
@Plugin({
|
2016-10-27 12:48:50 -05:00
|
|
|
pluginName: 'AppRate',
|
2016-03-12 18:30:16 -05:00
|
|
|
plugin: 'cordova-plugin-apprate',
|
|
|
|
pluginRef: 'AppRate',
|
2016-03-14 13:38:35 -04:00
|
|
|
repo: 'https://github.com/pushandplay/cordova-plugin-apprate',
|
2016-04-29 23:56:49 -04:00
|
|
|
platforms: ['Android', 'iOS']
|
2016-02-17 04:17:40 -05:00
|
|
|
})
|
|
|
|
export class AppRate {
|
|
|
|
|
|
|
|
/**
|
2016-07-01 15:16:52 -04:00
|
|
|
* Configure various settings for the Rating View.
|
|
|
|
* See table below for options
|
2016-02-17 04:17:40 -05:00
|
|
|
*/
|
2016-03-04 13:56:22 -06:00
|
|
|
@CordovaProperty
|
2016-12-06 08:41:36 -05:00
|
|
|
static preferences: AppRatePreferences;
|
2016-02-17 04:17:40 -05:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Prompts the user for rating
|
2016-03-15 16:09:53 -05:00
|
|
|
* @param {boolean} immediately Show the rating prompt immediately.
|
2016-02-17 04:17:40 -05:00
|
|
|
*/
|
|
|
|
@Cordova()
|
2016-07-08 00:33:07 +02:00
|
|
|
static promptForRating(immediately: boolean): void { };
|
2016-02-17 04:17:40 -05:00
|
|
|
|
|
|
|
}
|