MinaSamir11 / react-native-in-app-review

The Google Play In-App Review API, App store rating API lets you prompt users to submit Play Store or App store ratings and reviews without the inconvenience of leaving your app or game.
MIT License
647 stars 57 forks source link

Has reviewed #124

Closed AlenToma closed 1 year ago

AlenToma commented 2 years ago

Hi, thx for the library, it's really great.

I was wondering is it possible to implement if the user has a review already for the app.

This is imported becouse when doing request the app goes in the background for a moment even though the dialog dose not necceray show upp.

It will be great if there is a method that says hasAction or something like that.

Would also be happy to help if you could point me to a right direction. I could do it my self and post it here.

Becouse as I checked there no such a method in com.google.android.play.core.review.ReviewManager I may be wrong though as I am not an expert in java.

jforaker commented 1 year ago

@AlenToma you should probably do that on the react-native side, with a simple value such as:

AsyncStorage.setItem(REVIEW_DONE_KEY, 'true');

And then check it later:

  const reviewDone = await AsyncStorage.getItem(REVIEW_DONE_KEY);
  if (reviewDone) {
    return;
  }
MinaSamir11 commented 1 year ago

Hello @AlenToma
sorry for the late,

please let me know if this code couldn't help you to answer your question:

useEffect(()=>{
  lanuchReview()
});

function lanuchReview(){
  const date_lanuched_review = await AsyncStorage.getItem('date_lanuched_review');
  if(date_lanuched_review){
        const lastDateLaunchedReview = moment(date_lanuched_review).toISOString();
      const today = moment();
      if (today.diff(lastDateLaunchedReview, 'days') > 8 && level >=3 ) {
          InAppReview.RequestInAppReview()
            .then((hasFlowFinishedSuccessfully: boolean) => {
              if (hasFlowFinishedSuccessfully) {
                AsyncStorage.setItem("date_lanuched_review", new Date());
               }
            })
            .catch((error: any) => {
              //we continue our app flow.
              // we have some errors that could happen while launching InAppReview,
              // Check the table for errors and code numbers that can return in the catch.
              console.log(error);
            });
         }
      } else if(level >= 3) {
             InAppReview.RequestInAppReview()
            .then((hasFlowFinishedSuccessfully: boolean) => {
              if (hasFlowFinishedSuccessfully) {
                AsyncStorage.setItem("date_lanuched_review", new Date());
               }
            })
            .catch((error: any) => {
              //we continue our app flow.
              // we have some errors that could happen while launching InAppReview,
              // Check the table for errors and code numbers that can return in the catch.
              console.log(error);
            });
      }
    }

Please note also to make sure that you have read readMe very well till the end to make sure that you cover all the requirements