UNPKG

702 BJavaScriptView Raw
1import { NativeModules } from 'react-native';
2
3const { RNStoreReview } = NativeModules;
4
5/**
6 * Whether or not the requestReview() function is available.
7 */
8export const isAvailable = !!RNStoreReview && RNStoreReview.isAvailable;
9
10/**
11 * Asks the user to rate the app in the iOS App Store.
12 * @throws Will throw an Error if native module is not present or not supported by the iOS version.
13 */
14export function requestReview() {
15 if (!RNStoreReview) {
16 throw new Error('StoreReview native module not available, did you forget to link the library?');
17 }
18 if (!isAvailable) {
19 throw new Error('StoreReview is not available on this version of iOS');
20 }
21 return RNStoreReview.requestReview();
22}