refactor(launch-review): update the definitions for new v3 plugin API (#2162)

This commit is contained in:
Dave Alden 2017-12-02 03:50:21 +00:00 committed by Ibby Hadeed
parent 10a96fcdd6
commit 154a4bcacb

View File

@ -5,9 +5,9 @@ import { Plugin, Cordova, IonicNativePlugin } from '@ionic-native/core';
* @name Launch Review
* @description
*
* This launches the native store app in order for the user to leave a review.
* On Android, the plugin opens the the app's storepage in the Play Store where the user can leave a review by pressing the stars to give a rating.
* On iOS, the plugin opens the app's storepage in the App Store and focuses the Review tab, where the user can leave a review by pressing "Write a review".
* Assists in leaving user reviews/ratings in the App Stores.
* - Launches the platform's App Store page for the current app in order for the user to leave a review.
* - On iOS (10.3 and above) invokes the native in-app rating dialog which allows a user to rate your app without needing to open the App Store.
*
* @usage
* ```typescript
@ -17,9 +17,13 @@ import { Plugin, Cordova, IonicNativePlugin } from '@ionic-native/core';
*
* ...
*
* const appId: string = 'yourAppId';
* this.launchReview.launch(appId)
* this.launchReview.launch()
* .then(() => console.log('Successfully launched store app');
*
* if(this.launchReview.isRatingSupported()){
* this.launchReview.rating()
* .then(() => console.log('Successfully launched rating dialog');
* }
* ```
*/
@Plugin({
@ -33,10 +37,34 @@ import { Plugin, Cordova, IonicNativePlugin } from '@ionic-native/core';
export class LaunchReview extends IonicNativePlugin {
/**
* Launch store app using given app ID
* Launches App Store on current platform in order to leave a review for given app.
* @param appId {string} - (optional) the platform-specific app ID to use to open the page in the store app.
* If not specified, the plugin will use the app ID for the app in which the plugin is contained.
* On Android this is the full package name of the app. For example, for Google Maps: `com.google.android.apps.maps`
* On iOS this is the Apple ID of the app. For example, for Google Maps: `585027354`
* @returns {Promise<void>}
*/
@Cordova()
launch(appId: string): Promise<void> { return; }
@Cordova({ platforms: ['Android', 'iOS'], callbackOrder: 'reverse' })
launch(appId?: string): Promise<void> { return; }
/**
* Invokes the native in-app rating dialog which allows a user to rate your app without needing to open the App Store.
* Requires iOS 10.3 and above: Calling this on any platform/version other than iOS 10.3+ will result in the error callback.
* Success callback will be called up to 3 times:
* - First: after `LaunchReview.rating()` is called and the request to show the dialog is successful. Will be passed the value `requested`.
* - Second: if and when the Rating dialog is actually displayed. Will be passed the value `shown`.
* - Third: if and when the Rating dialog is dismissed. Will be passed the value `dismissed`.
* @returns {Promise<string>}
*/
@Cordova({ platforms: ['iOS'] })
rating(): Promise<string> { return; }
/**
* Indicates if the current platform/version supports in-app ratings dialog, i.e. calling LaunchReview.rating().
* Will return true if current platform is iOS 10.3 or above.
* @returns {boolean}
*/
@Cordova({ platforms: ['Android', 'iOS'], sync: true })
isRatingSupported(): boolean { return; }
}