background Push notifications

At first I was worried that expo had a custom notification system (had me thinking “coulda had a p8”, if you know the commercial like that, haha). In the end, I was impressed with how direct and easy sending messages with expo’s push notification service is. The only problem I ran into was in coming to realize that this will never work on a simulator. Otherwise, it’s pretty spiffy really, even easier than a p8.

But I’m noticing a different pattern of behavior when I try to send a background notification. In that instance, nothing seems to be happening.

My platform is iOS, and my App component has an extension that it binds to this and then fires off only once:


import { Alert } from 'react-native'
import { Permissions, Notifications } from 'expo'
import AsyncStorage from '@callstack/async-storage'

import { handleNotification } from '@src/lib/APNs'

export async function registerForPushNotifications () {
  const { status } = await Permissions.getAsync(Permissions.NOTIFICATIONS)

  if (status !== 'granted') {
    const { status } = await Permissions.askAsync(Permissions.NOTIFICATIONS)
    if (status !== 'granted') {
      Alert.alert('received no permission to listen to APNs')

  const expoToken = await Notifications.getExpoPushTokenAsync()
  Alert.alert('recieved permission to listen to APNs with token ' + expoToken)

  this.subscription = Notifications.addListener(handleNotification)

  this.setState({ expoToken })
  AsyncStorage.setItem('expoToken', expoToken)
import { Alert } from 'react-native'

export async function handleNotification () {
  console.log('arguments', arguments)

Elsewhere, I share that token so I can message it. I noticed it wasnt working when my server sent its background message, although it does register as a success from the POST (didn’t open the app, didn’t add the Alert popup… even if the app was in the foreground, no popup). So I went to the PN tool and sure enough, the first “hello world” that I did worked. Immediately, it works, too.

But if I configure it like my own message, with json data, category, and content available – and nothing else, nothing happens. Not in the foreground, not in the background. Not when closed. :frowning:

1 Like

bumping – this is definitely real, is effecting purely expo-written software that I literally cannot configure, and has all appearances of being broken.

I think maybe the documentation could be improved. It is completely reasonable to believe that “content-available” being explicitly an option means that your app can specify a listener to run without the app being foregrounded. This does not appear to be the case, even though the express purpose of that flag in an iOS push notification according to Apple is to allow that behavior.

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