This documentation is available as Markdown for AI agents and LLMs. See the full Markdown index or append .md to any documentation URL.
Expo StoreReview
一个提供访问原生 API 以实现应用内评论的库。
expo-store-review 是一个提供在 Android 5+ 上访问 ReviewManager API、以及在 iOS 上访问 SKStoreReviewController API 的库。它允许你在不离开应用本身的情况下,邀请用户为你的应用评分。
安装
- npx expo install expo-store-reviewIf you are installing this in an existing React Native app, make sure to install expo in your project.
用法
在使用此 API 时,请务必遵循 iOS 的 人机界面指南 以及 Android 的 指南。
具体来说:
- 不要从按钮中调用
StoreReview.requestReview()- 而应尝试在用户完成应用中的某个标志性交互之后再调用。 - 不要刷屏式地频繁打扰用户。
- 当用户正在进行有时间敏感性的操作(例如导航)时,不要请求评价。
- 在展示评分按钮或卡片之前或展示过程中,不要先向用户提任何问题。
写评价
Android
Android 上没有对应的重定向,但你仍然可以使用查询参数 showAllReviews=true 打开 Play 商店的评价页面,如下所示:
const androidPackageName = 'host.exp.exponent'; // 在浏览器中打开 Android Play 商店 -> 在 Android 上重定向到 Play 商店 Linking.openURL( `https://play.google.com/store/apps/details?id=${androidPackageName}&showAllReviews=true` ); // 直接打开 Android Play 商店 Linking.openURL(`market://details?id=${androidPackageName}&showAllReviews=true`);
iOS
你可以通过使用查询参数 action=write-review,将应用用户重定向到 iOS App Store 中某个应用的 “撰写评价” 界面。例如:
const itunesItemId = 982107779; // 在浏览器中打开 iOS App Store -> 在 iOS 上重定向到 App Store Linking.openURL(`https://apps.apple.com/app/apple-store/id${itunesItemId}?action=write-review`); // 直接打开 iOS App Store Linking.openURL( `itms-apps://itunes.apple.com/app/viewContentsUserReviews/id${itunesItemId}?action=write-review` );
API
import * as StoreReview from 'expo-store-review';
Methods
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.
Example
if (await StoreReview.hasAction()) { // you can call StoreReview.requestReview() }
Determines if the platform has the capabilities to use StoreReview.requestReview().
Promise<boolean>This returns a promise fulfills with boolean, depending on the platform:
- On iOS, it will resolve to
trueunless the app is distributed through TestFlight. - On Android, it will resolve to
trueif the device is running Android 5.0+. - On Web, it will resolve to
false.
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.
Promise<void>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.
string | null错误代码
ERR_STORE_REVIEW_FAILED
当商店审核请求未成功时,会发生此错误。