Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
showPopupRating() {
if (Platform.OS === 'ios') {
// This API is only available on iOS 10.3 or later
if (StoreReview.isAvailable) {
StoreReview.requestReview()
} else {
NavStore.popupCustom.show('Store review is not available')
}
} else {
Alert.alert(
constant.titleRatingApp,
constant.desRatingApp,
[
{ text: constant.ratingLater },
{ text: constant.cancel, onPress: () => { }, style: 'cancel' },
{
text: constant.rating,
onPress: () => {
Linking.openURL(PLAY_STORE_LINK)
.catch(err => console.error('An error occurred', err))
showPopupRating() {
if (Platform.OS === 'ios') {
// This API is only available on iOS 10.3 or later
if (StoreReview.isAvailable) {
StoreReview.requestReview()
}
} else {
Alert.alert(
constant.titleRatingApp,
constant.desRatingApp,
[
{ text: constant.ratingLater },
{ text: constant.cancel, onPress: () => { }, style: 'cancel' },
{
text: constant.rating,
onPress: () => {
Linking.openURL(PLAY_STORE_LINK)
.catch(err => console.error('An error occurred', err))
}
}
async function shouldShowRatingComponent() {
// Don't show if we literally can't on this device
if (Platform.OS === "ios" && !StoreReview.isAvailable) {
stats.log("Review isn't available");
return false;
}
if (
Platform.OS === "android" &&
!(await Linking.canOpenURL(PLAY_STORE_URL))
) {
return false;
}
// Don't show if they've rated before
const hasRatedBefore = await flagstore.get("has-rated", "false");
if (hasRatedBefore) {
stats.log("has rated before isn't available");
return false;
onPress: () => {
RatingsData.recordRated();
callback(true, "accept");
// This API is only available on iOS 10.3 or later
if (Platform.OS === 'ios' && StoreReview.isAvailable) {
StoreReview.requestReview();
} else {
Linking.openURL(this.storeUrl);
}
},
style: "default",
code: prevState.code + key,
};
});
if (this.state.code.length !== 4) {
return;
}
if (this.state.isSettingCode) {
userSetPincode();
await setPincode(this.state.code);
haptic.notification(Haptic.NotificationFeedbackType.Success);
this.props.navigation.navigate(MAIN_SCREEN);
// After they set a pincode, mayyyybe they like the app enough to give it a review?
if (Platform.OS === "ios" && StoreReview.isAvailable) {
userPromptedForReviewWhenSettingCode();
StoreReview.requestReview();
}
}
const isGood = await isCorrectPincode(this.state.code);
if (isGood) {
haptic.notification(Haptic.NotificationFeedbackType.Success);
this.props.navigation.navigate(MAIN_SCREEN);
this.setState({
code: "",
});
} else {
this.setState({
code: "",
});
onPressReview: ({ onCloseModal }) => async () => {
const maxRequestCount = 2;
const count = await getAppStoreReviewCount();
const shouldDeeplinkToAppStore =
count >= maxRequestCount || !StoreReview.isAvailable;
if (shouldDeeplinkToAppStore && !DeviceInfo.isEmulator()) {
Linking.openURL(SettingsExternalURLs.review);
} else {
onCloseModal();
InteractionManager.runAfterInteractions(StoreReview.requestReview);
}
return saveAppStoreReviewCount(count + 1);
},
onPressTwitter: () => async () => {
onPress={() => {
if (StoreReview.isAvailable) {
StoreReview.requestReview();
} else {
Linking.openURL(
"https://itunes.apple.com/us/app/moonwalk-rocket-launches/id1439376174"
);
}
}}
>