Skip to content
This repository has been archived by the owner on Apr 14, 2022. It is now read-only.

Commit

Permalink
feat(api): show rate dialog
Browse files Browse the repository at this point in the history
  • Loading branch information
gogoout committed Dec 9, 2018
1 parent 2fff13b commit 6d75090
Show file tree
Hide file tree
Showing 7 changed files with 34 additions and 8 deletions.
7 changes: 7 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,12 @@ appRater
.setShowNeverButton(true)
.setDebugMode(true)
.appLaunched();

// check
appRater.showRateDialogIfMeetsConditions();

// show directly
appRater.showRateDialog();
```

## API
Expand All @@ -72,6 +78,7 @@ appRater
| setShowNeverButton(value: boolean): AppRaterBase | true | Show Never button in review request dialong. **Android only** |
| appLaunched():void | | Let rater know that your app is launched |
| showRateDialogIfMeetsConditions():void | | Show rating dialog if meets conditions |
| showRateDialog():void | | Show rating dialog|

## Custom dialog

Expand Down
16 changes: 10 additions & 6 deletions demo/app/main-page.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,18 +10,22 @@ export function pageLoaded(args: observable.EventData) {
page.bindingContext = new HelloWorldModel();

appRater
.setDaysUntilPrompt(7)
.setUsesUntilPrompt(3)
.setSignificantUsesUntilPrompt(2)
.setDaysUntilPrompt(1)
.setUsesUntilPrompt(1)
.setSignificantUsesUntilPrompt(1)
.setShowLaterButton(true)
.setShowNeverButton(true)
.setShowNeverButton(false)
// show every time when called `showRateDialogIfMeetsConditions`
.setDebugMode(true)
.setDebugMode(false)
.appLaunched();

}

export function onTap() {
export function onCheck() {
appRater.showRateDialogIfMeetsConditions();
}

export function onShow() {
appRater.showRateDialog();
}

3 changes: 2 additions & 1 deletion demo/app/main-page.xml
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
<Page xmlns="http://schemas.nativescript.org/tns.xsd" loaded="pageLoaded" class="page"
xmlns:ui="nativescript-rater">
<StackLayout class="p-20">
<Button class="btn btn-primary" text="Show Rate Dialog" tap="onTap"/>
<Button class="btn btn-primary" text="Check If Show Rate Dialog" tap="onCheck"/>
<Button class="btn btn-primary" text="Show Rate Dialog" tap="onShow"/>
</StackLayout>
</Page>
2 changes: 1 addition & 1 deletion src/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "nativescript-rater",
"version": "1.0.0",
"version": "1.0.1",
"description": "Reminds your app's users to review the app through PlayStore or AppStore. Love it, rate it!",
"main": "rater",
"typings": "index.d.ts",
Expand Down
8 changes: 8 additions & 0 deletions src/rater.android.ts
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,14 @@ export const appRater: AppRaterBase = {
},

showRateDialogIfMeetsConditions() {
getAppRater().then(rater => {
if (rater.isDebug() || rater.shouldShowRateDialog()) {
rater.showRateDialog(application.android.currentContext);
}
});
},

showRateDialog() {
getAppRater().then(rater => {
rater.showRateDialog(application.android.currentContext);
});
Expand Down
2 changes: 2 additions & 0 deletions src/rater.common.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,4 +22,6 @@ export interface AppRaterBase {
appLaunched();

showRateDialogIfMeetsConditions();

showRateDialog();
}
4 changes: 4 additions & 0 deletions src/rater.ios.ts
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,10 @@ export const appRater: AppRaterBase = {
SwiftRater.checkWithHost(this.currentViewController);
},

showRateDialog() {
SwiftRater.rateApp();
},

setShowLaterButton(value: boolean): AppRaterBase {
SwiftRater.setShowLaterButton(value);
return appRater;
Expand Down

0 comments on commit 6d75090

Please sign in to comment.