one
Version:
One is a React framework for web, iOS, and Android apps.
24 lines (19 loc) • 968 B
text/typescript
import { Platform } from 'react-native'
import { NitroModules } from 'react-native-nitro-modules'
import { rethrowNativeError } from '../nativeError'
import type { OneStoreReview } from '../specs/OneStoreReview.nitro'
import { StoreReview as unavailableStoreReview } from './unavailable'
let hybrid: OneStoreReview | undefined
function requestReview(): Promise<void> {
if (Platform.OS !== 'ios' && Platform.OS !== 'android')
throw new Error('StoreReview requires a native build')
hybrid ??= NitroModules.createHybridObject<OneStoreReview>('OneStoreReview')
return hybrid.requestReview().catch(rethrowNativeError)
}
const nativeStoreReview = Object.freeze({ requestReview })
// iOS reviews through StoreKit and Android through Play In-App Review; other
// platforms keep the unavailable contract
export const StoreReview: typeof nativeStoreReview =
Platform.OS === 'ios' || Platform.OS === 'android'
? nativeStoreReview
: unavailableStoreReview