expo: Notification deep linking on standalone app often fails when app is closed

I’m using push notifications on my app, and handling selected notifications by navigating to a certain screen. This works great in the non-standalone version of my app, but I’ve encountered some potentially significant issues on the standalone version.

The issues only seem to occur when the app is entirely closed (not backgrounded, but closed), and the notification is received. On the iOS version this just results in the deep linking failing, basically with props.exp.notification being null or undefined, so that the app doesn’t handle the notification.

On android it’s a little more ominous–the entire screen goes black and the app is unresponsive. The issue is sticky, in that it will likely continue to happen when I try to open the app again afterward; even if I’ve forced quit the app.

That said, this doesn’t happen all the time. At times it works as expected as well.

I have an e-mail chain going regarding the Android issue with @quinlanj, but I’m just now starting to suspect that these issues are related and I wanted to document it in in an issue.

About this issue

  • Original URL
  • State: closed
  • Created 7 years ago
  • Reactions: 3
  • Comments: 24 (8 by maintainers)

Most upvoted comments

Fixed the android side of this in SDK 23!

Ah sorry for being unclear - my fix only addresses the iOS side. The Android issue is actually a different issue with similar symptoms.

There’s no straightforward way for you to use this fix before we release SDK 23, because the native code for standalone apps is built on Expo’s servers, and we won’t deploy the latest code until SDK 23 comes out. We’re hoping to ship SDK 23 soon.

iOS side is tentatively fixed here: https://github.com/expo/expo/commit/9f3eefca1506ccbced610a001cbe9cc4526c9b4b

Will ship with SDK 23. (but will be fixed for projects running any SDK version.)

I’m on SDK version 25 and in iOS 11.3 my handleNotification callback is never called if the app is closed.

By closed I mean force closing the app or after an iPhone reboot.

If the app is simply in background (for example, opening app and then switching to Safari or springboard) it works.

Here’s the code:

static handleNotification(notification, navigation) { if (notification.origin === ‘selected’) { navigation.navigate(notification.data.screen); } }

If the app is in background, as soon as I click on the notification the app opens and navigates to the screen name passed on data.screen. But if I force close the app and send the exact same notification, when I click on the notification the app will simply open but no navigation will happen.

@terribleben Hey I’m having the same issue as @aniltirola on SDK v26 on iOS, notifications work generally, but not when the app is closed – neither exp.props.notification nor Notification.addListener is working. I’ve tried v23, v24, and v26 with no luck – any advice?

I’m adding the listener on componentDidMount() – could this be a reason?

componentDidMount()  {
        this._pushListener = Notifications.addListener(
                this.handleNotification.bind(this));
    }

@nitish-deckspire yes I found props.exp.notification did not add any cases not already picked up by the listener, implying it is obsolete. Keeping it around would be a matter of preference if you don’t need the listener.

I found it to be true for 25+

FYI I opened a reflective issue in the docs: [https://github.com/expo/expo-docs/issues/275]

Just want to acknowledge that we are aware of this issue but don’t have any updates.

here is the gist from my app; I put everything in one file for easier debugging; https://gist.github.com/aniltirola/df68c33f12f4028fe162fca658c3c5c8

and here ist the app for the expo-client (no problems): https://expo.io/@anil_from_the_alps/debugpush24oct

and here is the video: https://drive.google.com/open?id=0B_6CA3rBcoEUdTJqbGxWR281bjA