Review validation fails in react-native

谁说胖子不能爱 提交于 2021-02-10 14:15:26

问题


I am new to react native. I have used the package react-native-rate for rate my application in ios store/google playstore. but it ignores in the below cases.

CASE 1: 1) While showing Rating prompt, when the user press the OK Button to add a review, Application will redirect to ios store/google playstore. 2) If the user exit without adding review, then application considering as review added. 3) Could you please let me know how to validate the added the review or not.

CASE 2 : 1) Currently, I have implemented based on AsyncStorage. so if the user accessing the app more than one device, then the review alert will be asked in each device. 2) Could you please let me know, how to identify the user has added the review in any of the device or not.

import Rate, { AndroidMarket } from 'react-native-rate';
import AsyncStorage from '@react-native-community/async-storage';
const ratingApp = async () => {
    const isAlreadyRate = await AsyncStorage.getItem('isAlreadyRate');
    const countStartApp = await AsyncStorage.getItem('countStartApp');
    const count = countStartApp ? parseInt(countStartApp) : 1;
    if (!isAlreadyRate && count % 10 === 0) {
      Alert.alert('App Rating', 'Please give us your opinion!', [
        {
          text: 'Later',
          onPress: () => console.log('Cancel Pressed'),
          style: 'cancel',
        },
        {
          text: 'OK',
          onPress: () => {
            setTimeout(() => {
              let options = {
                AppleAppID: '************',
                GooglePackageName: '***************',
                preferredAndroidMarket: AndroidMarket.Google,
                preferInApp: false,
                openAppStoreIfInAppFails: true,
              };
              Rate.rate(options, success => {
                if (success) {
                   AsyncStorage.setItem('isAlreadyRate', 'true');                 
                }
              });
            }, 1000);
          },
        },
      ]);
    }
    await AsyncStorage.setItem('countStartApp', `${count + 1}`);
  }

来源:https://stackoverflow.com/questions/65591352/review-validation-fails-in-react-native

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!