Hello everyone i'm trying to make a styled updating in code push. i want the application to follow these steps:
- when the update start i want to show a loading ;
- when the update is updating i want to show a screen with a text (" Updating ") and under it a progress bar with the percentage of update;
In my code i insert codepush update in App.tsx and tryied to dysplay with console logs only if the switch state was working but it didn't .
thank you in avance for your help i'm sorry but i dindn't fully undestand the codepush's documentation.
here is my code:
import React, {useEffect} from 'react';
import Navigation from './navigation';
import codePush from 'react-native-code-push';
import {StatusBar} from 'react-native';
export default function App() {
useEffect(() => {
const codePushStatusDidChange = (status: any) => {
switch (status) {
case codePush.SyncStatus.CHECKING_FOR_UPDATE:
console.log('Checking for updates.');
break;
case codePush.SyncStatus.DOWNLOADING_PACKAGE:
console.log('Downloading package.');
break;
case codePush.SyncStatus.INSTALLING_UPDATE:
console.log('Installing update.');
break;
case codePush.SyncStatus.UP_TO_DATE:
console.log('Up-to-date.');
break;
case codePush.SyncStatus.UPDATE_INSTALLED:
console.log('Update installed.');
break;
}
};
const codePushDownloadDidProgress = (progress: {
receivedBytes: string;
totalBytes: string;
}) => {
console.log(
progress.receivedBytes + ' of ' + progress.totalBytes + ' received.',
);
};
const syncImmediate = () => {
console.log('synced');
codePush.sync(
{
checkFrequency: codePush.CheckFrequency.ON_APP_START,
installMode: codePush.InstallMode.IMMEDIATE,
updateDialog: {
appendReleaseDescription: true,
optionalUpdateMessage: 'Updates here..',
title: 'New Updates',
optionalInstallButtonLabel: 'Yes',
optionalIgnoreButtonLabel: 'No',
},
},
codePushStatusDidChange,
codePushDownloadDidProgress,
);
};
syncImmediate();
});
return (
<>
<Navigation />
</>
);
}
App = codePush(App);