Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

143
Views
react-native app update alert code fails to update app

I've developed a react-native app tht is currently working (and in both the Apple and Google play stores). Last night I implemented a long overdue feature, update alert and updater using the react-native-version-check, Alert, backHandler and Linking. From this Medium blog link I adapted the function into my app and tested on Android. I testted forst my advancing my local version code/version name ahead of my store release and it works by not triggering -- works. But, when I roll back my version lower than the store's and re-build, it triggers properly with an alert box and 'update' button, when clicking the button the app closes and nothing else happens. So I do see the proper trigger happened but the update function did not. Repeating this multiple times (clicking on the app, hitting update button, app closing, I gert an error message that says 'Your Americana Radio keeps stopping' error. 'Your Americana Radio' is my app name.

The medium article/blog: https://medium.com/@kinley.tshering/force-update-react-native-apps-a9c1f22c0701

My code from my app.android.js specifically on this function as follows:

import {Alert, BackHandler, Linking} from 'react-native';
import VersionCheck from 'react-native-version-check';

const checkVersion = async () => {
    try {
        let updateNeeded = await VersionCheck.needUpdate();
        if(updateNeeded && updateNeeded.isNeeded) {
            Alert.alert (
              'Please update',
              'You will have to update this app to the latest version to continue using it.',
              [
                {
                   text: 'Update',
                   onPress: () => {
                                    BackHandler.exitApp();
                                    console.log("-I-: Doing the Update App functions");
                                    Linking.openURL(updateNeeded.storeURL);
                   },
                  },
               ],
               {cancelable: false},
            );
       }
    } catch (error) {};
};
export default function App() {

// React Native Splash Screen
// Ref: https://dev.to/cmcodes/how-to-add-splash-screen-in-a-react-native-android-app-287l
//
// useEffect(() => {
//     SplashScreen.hide();
// }, []); // Splash

const [hideSplash, setHideSplash] = useState(false);

useEffect(() => {
  setTimeout(() => {
    setHideSplash(true);
  }, 2500); // amount of time the splash is shown from the time component is rendered
}, []);

useEffect(() => {
  hideSplash && SplashScreen.hide();
}, [hideSplash]);  // Splash with timer

useEffect(() => {
    checkVersion();
}, []);

  return(
      <SocketContext.Provider value={socket}>
          <AppContainer />
       </SocketContext.Provider >
  )
}
about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

This is a case of 'cockpit error'.
I fixed this once I realized

  • I had updateNeeded.storeURL
  • instead of updateNeeded.storeUrl.

With the change, the code worked as expected.

about 4 years ago · Juan Pablo Isaza Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!