How can I show the progress when an update comes with react native code push?

121 views Asked by At
const AppRoot = () => {
  const [progress, setProgress] = useState(false);

  const checkForUpdate = async () => {
    try {
      const update = await CodePush.checkForUpdate();
      if (update) {
        setProgress(true);

    CodePush.sync(
      {
        deploymentKey: 'M8_hdiay-n8fu3sIJ-o8VW7a7P9rqYHQf3YlG',
        updateDialog: false,
        installMode: CodePush.InstallMode.IMMEDIATE,
      },
      syncStatus => {
        switch (syncStatus) {
          case CodePush.SyncStatus.CHECKING_FOR_UPDATE:
            break;
          case CodePush.SyncStatus.DOWNLOADING_PACKAGE:
            break;
          case CodePush.SyncStatus.INSTALLING_UPDATE:
            break;
          case CodePush.SyncStatus.UPDATE_INSTALLED:
            break;
        }
      },
    );
     }
    } catch (error) {
     console.error('CodePush update error:', error);
    } finally {
     setProgress(false)
    }
    };

How can I show the loading modal when an update comes with code push? How can I show the modal when the codepush update comes with React Native? The method in this code did not work.

      useEffect(() => {
        checkForUpdate();
      }, []);
    {!!progress ? (
                <Modal visible={true} transparent>
                  <View
                    style={{
                      backgroundColor: 'rgba(0,0,0,0.8)',
                      flex: 1,
                      justifyContent: 'center',
                      alignItems: 'center',
                    }}>
                    <Text style={styles.text}>Güncellemeler Yükleniyor...</Text>
                    <View style={{alignItems: 'center'}}>
                      <ActivityIndicator
                        size={'large'}
                        style={{marginVertical: 8}}
                        color={'#004880'}
                      />
                    </View>
                  </View>
                </Modal>
              ) : null}

How can I show the progress when an update comes with react native code push? I want to show my loading modal when the update comes.

0

There are 0 answers