Race condition in Expo app initialization

We’re calling Notifications.addListener() at the top of our app’s main saga (using redux-saga) which gets run right when our app is first launched. After some investigation, it appears this listener will never get called (e.g. when the user cold-starts the app by tapping on a notification) unless we ensure it gets run after the point where Expo logs “Running application “main” with appParams…” to the console. Similarly, we get the same behavior if we instead call Notifications.addListener() right at the top of App.js. We’re also calling Updates.addListener() at the top of App.js and that appears to work properly.

Interestingly, if we register a second notification listener at a later time, such as inside our root App componentDidMount() (which reliably runs after the initialization console log line), both notification listeners get called. If the line is removed, neither will.

Is this behavior known/expected? Would love to understand if this is a bug or if we should simply be initializing our app differently.

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