首页指南参考教程

Expo StoreReview iconExpo StoreReview

GitHub

npm

一个库,提供对原生 API 的访问以进行应用内评论。

Android
iOS

expo-store-review 提供对 iOS 上的 SKStoreReviewController API 和 Android 5.0+ 中的 ReviewManager API 的访问,允许你要求用户对你的应用进行评分,而无需离开应用本身。

¥**expo-store-review** provides access to the SKStoreReviewController API on iOS, and ReviewManager API in Android 5.0+ allowing you to ask the user to rate your app without ever having to leave the app itself.

安装

¥Installation

Terminal
npx expo install expo-store-review

If you're installing this in a bare React Native app, you should also follow these additional installation instructions.

用法

¥Usage

使用此 API 时,请务必遵循 iOS 的 人机界面指南 和 Android 的 指南

¥It is important that you follow the Human Interface Guidelines for iOS and Guidelines for Android when using this API.

具体来说:

¥Specifically:

  • 不要通过按钮调用 StoreReview.requestReview() - 相反,请尝试在用户在应用中完成一些签名交互后调用它。

    ¥Don't call StoreReview.requestReview() from a button - instead try calling it after the user has finished some signature interaction in the app.

  • 不要向用户发送垃圾邮件。

    ¥Don't spam the user.

  • 当用户正在执行诸如导航之类的时间敏感操作时,请勿请求审核。

    ¥Don't request a review when the user is doing something time sensitive like navigating.

  • 在展示评级按钮或卡片之前或期间,请勿询问用户任何问题。

    ¥Don't ask the user any questions before or while presenting the rating button or card.

撰写评论

¥Write reviews

iOS 系统

¥iOS

你可以使用查询参数 action=write-review 将某人重定向到 iOS App Store 中应用的 "写评论" 屏幕。例如:

¥You can redirect someone to the "Write a Review" screen for an app in the iOS App Store by using the query parameter action=write-review. For example:

const itunesItemId = 982107779;
// Open the iOS App Store in the browser -> redirects to App Store on iOS
Linking.openURL(`https://apps.apple.com/app/apple-store/id${itunesItemId}?action=write-review`);
// Open the iOS App Store directly
Linking.openURL(
  `itms-apps://itunes.apple.com/app/viewContentsUserReviews/id${itunesItemId}?action=write-review`
);

安卓

¥Android

Android 上没有等效的重定向,你仍然可以使用查询参数 showAllReviews=true 打开 Play 商店到评论部分,如下所示:

¥There is no equivalent redirect on Android, you can still open the Play Store to the reviews sections using the query parameter showAllReviews=true like this:

const androidPackageName = 'host.exp.exponent';
// Open the Android Play Store in the browser -> redirects to Play Store on Android
Linking.openURL(
  `https://play.google.com/store/apps/details?id=${androidPackageName}&showAllReviews=true`
);
// Open the Android Play Store directly
Linking.openURL(`market://details?id=${androidPackageName}&showAllReviews=true`);

API

import * as StoreReview from 'expo-store-review';

Methods

StoreReview.hasAction()

Example

if (await StoreReview.hasAction()) {
  // you can call StoreReview.requestReview()
}

Returns

  • Promise<boolean>

This returns a promise that fulfills to true if StoreReview.requestReview() is capable directing the user to some kind of store review flow. If the app config (app.json) does not contain store URLs and native store review capabilities are not available then the promise will fulfill to false.

StoreReview.isAvailableAsync()

Determines if the platform has the capabilities to use StoreReview.requestReview().

Returns

  • Promise<boolean>

This returns a promise fulfills with boolean, depending on the platform:

  • On iOS, it will resolve to true unless the app is distributed through TestFlight.
  • On Android, it will resolve to true if the device is running Android 5.0+.
  • On Web, it will resolve to false.

StoreReview.requestReview()

In ideal circumstances this will open a native modal and allow the user to select a star rating that will then be applied to the App Store, without leaving the app. If the device is running a version of Android lower than 5.0, this will attempt to get the store URL and link the user to it.

Returns

  • Promise<void>

StoreReview.storeUrl()

This uses the Constants API to get the Constants.expoConfig.ios.appStoreUrl on iOS, or the Constants.expoConfig.android.playStoreUrl on Android.

On Web this will return null.

Returns

  • string | null

错误代码

¥Error codes

ERR_STORE_REVIEW_FAILED

当商店审核请求不成功时会出现此错误。

¥This error occurs when the store review request was not successful.

Expo 中文网 - 粤ICP备13048890号