how do I implement the "remind me later" button using async storage?

510 views Asked by At

there are modulke in my project that is called after a successful operation of money transfer. After a successful operation, I suggest that the user evaluate the app. And the app evaluation is called after each successful operation, which is a bit annoying. How do I add a "remind me later" button and implement it using async storage? thank you in advance!

import React, { Component } from 'react';
import { View } from 'react-native';
import RateModal from 'react-native-store-rating';

export default class RateAppModal extends Component {
  state = {
    isModalOpen: true,
  };

  render() {
    return (
      <View>
        <RateModal
          modalTitle="Оцените наше приложение"
          rateBtnText="Оценить"
          cancelBtnText="Отмена"
          totalStarCount={5}
          defaultStars={0}
          isVisible
          sendBtnText="Отправить"
          commentPlaceholderText="Оставьте комментарий..."
          emptyCommentErrorMessage="Empty comment error message"
          playStoreUrl="market://details?id=com.smb.client.mobile"
          iTunesStoreUrl="itms-apps://itunes.apple.com/app/id1497101549"
          isModalOpen={this.state.isModalOpen}
          storeRedirectThreshold={0}
          style={{
            paddingHorizontal: 30,
          }}
          onStarSelected={(e) => {
            console.log('change rating', e);
          }}
          onClosed={() => {
            console.log('pressed cancel button...');
            this.setState({
              isModalOpen: false,
            });
          }}
          sendContactUsForm={(state) => {
            alert(JSON.stringify(state));
          }}
        />
      </View>
    );
  }
}

2

There are 2 answers

3
Akino Archilles On BEST ANSWER

First initialized the storage key you would use and set it to false AsyncStorage.getItem('RemindMeLater', (err, result) => !result && AsyncStorage.setItem('RemindMeLater', false))

When the remind me later button is pressed, you can set the storage to true by AsyncStorage.setItem('RemindMeLater', true)

Then check for the storage when u needed to display the modal again by AsyncStorage.getItem('RemindMeLater', (err, result) => result ? this.setState({isModalOpen:true}) : null)

0
Atiq Ur Rehman On

yes, async storge is the answer you can place a flag in storge and remember about the user selection or another way is to store it on the back end but not recommended