Skip to content

Commit

Permalink
feat(app-rate): update plugin functions (#3598)
Browse files Browse the repository at this point in the history
* cordova-plugin-apprate

* Update index.ts
  • Loading branch information
osben authored Jan 23, 2021
1 parent de6dee7 commit 3e92f64
Showing 1 changed file with 88 additions and 5 deletions.
93 changes: 88 additions & 5 deletions src/@ionic-native/plugins/app-rate/index.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,33 @@
import { Injectable } from '@angular/core';
import { Cordova, CordovaProperty, IonicNativePlugin, Plugin } from '@ionic-native/core';

export enum AppRateReviewTypeIos {
/**
* Write review directly in your application (iOS 10.3+), limited to 3 prompts per year.
* Will fallback to 'AppStoreReview' for other iOS versions
*/
InAppReview = 'InAppReview',
/**
* Open the store within the app. Use this option as an alternative to inAppReview to avoid the rate action from doing nothing
*/
AppStoreReview = 'AppStoreReview',
/**
* Open the store using the openUrl preference (defaults to InAppBrowser). Be advised that WKWebView might not open the app store links
*/
InAppBrowser = 'InAppBrowser'
}

export enum AppRateReviewTypeAndroid {
/**
* Write review directly in your application. Will fallback to InAppBrowser if not available
*/
InAppReview = 'InAppReview',
/**
* Open the store using the openUrl preference (defaults to InAppBrowser)
*/
InAppBrowser = 'InAppBrowser',
}

export interface AppRatePreferences {
/**
* Custom BCP 47 language tag
Expand All @@ -22,11 +49,29 @@ export interface AppRatePreferences {
*/
usesUntilPrompt?: number;

reviewType?: {
/**
* the type of review display to show the user on iOS
* Default: AppStoreReview
*/
ios?: AppRateReviewTypeIos
/**
* the type of review display to show the user on Android
* Default: InAppBrowser
*/
android?: AppRateReviewTypeAndroid
}

/**
* Simple Mode to display the rate dialog directly and bypass negative feedback filtering flow
*/
simpleMode?: boolean;

/**
* Disabling would skip displaying a rate dialog if in app review is set and available. Defaults to `true`
*/
showPromptForInAppReview?: boolean;

/**
* leave app or no when application page opened in app store (now supported only for iOS). Defaults to `false`
*/
Expand Down Expand Up @@ -93,20 +138,30 @@ export interface AppRateCustomLocale {
feedbackPromptMessage?: string;
}

export interface AppRateLocales {
addLocale(localeObject: AppRateCustomLocale): AppRateCustomLocale

getLocale(language: string, applicationTitle?: string, customLocale?: AppRateCustomLocale)

getLocalesNames(): { [prop: string]: AppRateCustomLocale; }
}

export interface AppRateCallbacks {
/**
* call back function. called when user clicked on rate-dialog buttons
*/
onButtonClicked?: Function;
onButtonClicked?: (buttonIndex: number) => void;

/**
* call back function. called when rate-dialog showing
*/
onRateDialogShow?: Function;
onRateDialogShow?: (rateCallback: (buttonIndex: number) => void) => void;
/**
* call back function. called when user clicked on negative feedback
*/
handleNegativeFeedback?: Function;
handleNegativeFeedback?: () => void;

done?: () => void;
}

export interface AppUrls {
Expand Down Expand Up @@ -196,16 +251,44 @@ export class AppRate extends IonicNativePlugin {
@CordovaProperty()
preferences: AppRatePreferences;

/**
* Manager custom locales
*/
@CordovaProperty()
locales: AppRateLocales;

/**
* Set preferences
* @return void
*/
@Cordova()
setPreferences(pref: AppRatePreferences): void {
return;
}

/**
* Get preferences
* @return AppRatePreferences
*/
@Cordova()
getPreferences(): AppRatePreferences {
return;
}

/**
* Prompts the user for rating
* @param {boolean} immediately Show the rating prompt immediately.
*/
@Cordova()
promptForRating(immediately: boolean): void {}
promptForRating(immediately?: boolean): void {
return;
}


/**
* Immediately send the user to the app store rating page
*/
@Cordova()
navigateToAppStore(): void {}
navigateToAppStore(): void {
}
}

0 comments on commit 3e92f64

Please sign in to comment.