[expo-updates] No way to make alert

I’m trying to achieve an alert while the app will update, but no way, i can’t get any alert, or snackbar or nothing, the app just only update on restart app, and no alert is shown.

I tryied to make alert after checkForUpdates(); but nothing occurs, neither after fetchUpdateAsync();

Anyway to achieve this?

Hi @velcis

Can you show some sample code that you’re trying?

What I’ve done before is check for updates periodically. It’s a bit messy because you get warnings if you try to do something like check every 12 hours with useInterval(). So instead I keep track of the last time the check was done. Then every time the user presses one of the main buttons on the home screen of the app it checks if enough time has passed. If so, it calls checkForUpdatesAsync(). If there is an update it shows a FAB that the user can click on to fetchUpdateAsync(). Once the update has been fetched it shows a button to allow the user to restart the app to apply the update.

Someone else mentioned that they do the check when the app comes to the foreground. (But presumably only if it hasn’t checked recently.) That seems better than doing it as a side effect of the user clicking on a button.

But it doesn’t seem like the above is really the problem you’re having. If you show what code you have then maybe someone can see what’s going wrong or provide better suggestions.

First i run expo publish, to publish my update, than my sample code is like, when i open the app, i’m checking for updates with “const haveUpdate = await Updates.checkForUpdateAsync();”;
After it, showing some alert, but nothing occurs.

Trying after that “await Updates.fetchUpdateAsync();”
if (update.isNew) {
Alert.alert(‘Update availabel’);
}

Nothing appears… BUT, after i restart the app manually the update is done, with no alert.

Maybe try turning off the automatic update checks when the app starts:
"updates": { "checkAutomatically": "ON_ERROR_RECOVERY" }

I think that might be interfering with your testing.

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.