nativescript-ratings
提示用户对 Telerik NativeScript 应用进行评分
npm i --save nativescript-ratings

NativeScript 应用评分

此 Telerik NativeScript 插件将在定义的调用次数或更好的情况下,在应用打开一定次数后提示用户对您的应用进行评分。

NativeScript Ratings

安装

此插件适用于 Android 和 iOS。要将它安装到您的项目中,请在命令提示符(Windows)或终端(Mac 和 Linux)中执行以下操作,确保项目是当前工作目录:

tns plugin add nativescript-ratings

使用示例项目

此插件包含一个示例项目。要尝试而不创建新项目,请使用 插件目录 作为 当前工作目录 执行以下操作:

npm run setup
npm run demo.ios
npm run demo.android

运行 demo.iosdemo.android 将在适当的平台上运行。

使用评分插件(TypeScript)

此插件非常基本。首先,必须在项目中包含它,如下所示:

import { Ratings } from "nativescript-ratings";

导入插件后,可以按如下方式初始化:

let ratings = new Ratings({
id: "appname-1.0.0",
showOnCount: 5,
title: "Please rate",
text: "Will you please rate my app?",
agreeButtonText: "Rate Now",
remindButtonText: "Remind Me Later",
declineButtonText: "No Thanks",
androidPackageId: "com.nativescript.demo",
iTunesAppId: "12345"
});

在上面的配置属性中,只有 titletext 是必需的。所有其他属性都有默认值,您可以选择包括自己的来覆盖它们。

要增加显示计数器,必须按如下方式调用 init() 函数:

ratings.init();

最后,如果显示计数器与配置属性中定义的相匹配,则可以显示提示。

ratings.prompt();

如果按下提醒按钮,计数器将重置,并在值匹配时再次显示。

资源

NativeScript - https://www.nativescript.org

多语言开发者 - https://www.thepolyglotdeveloper.com