Please provide the following:
- SDK Version:
~41.0.0
- Platforms(Android/iOS/web/all): Android
I’m trying to use Updates.addListener
to download and install updates without the user needing to close the app but my listener
callback is never called. I’m testing with Expo Go and a published release channel on an Android phone. My app.json
is has the updates configuration set as follows:
updates: {
fallbackToCacheTimeout: 0,
checkAutomatically: 'ON_LOAD'
}
Here is the code in App.tsx
:
useEffect(() => {
const eventListener = async (event: Updates.UpdateEvent) => {
Alert.alert('Callback');
if (event.type === Updates.UpdateEventType.UPDATE_AVAILABLE) {
try {
const { isNew } = await Updates.fetchUpdateAsync();
if (isNew) {
Updates.reloadAsync();
}
} catch (error) {
console.log('Unable to feth the update and reload');
}
}
};
const subscription = Updates.addListener(eventListener);
return () => {
subscription.remove();
};
}, []);