Push on Ios doesn't show

I suceffuly registered the token and received the push notifications on Android, but it doesn’t show on IOS
Im using a real device, to receive.
How can i show the notification on IOS when the app is on background ?
I’ve the the event listener, but i didn’t understand how to do it well
Here’s the code:

import React, { Component } from 'react';
import {
  Notifications,
} from 'expo';
import AppNavigator from './AppNavigator';
import {
  Text,
  View,
} from 'react-native';

class App extends Component {
  constructor(props) {
    super(props);
    this.state = {
      notification: {},
    };
  }

  componentWillMount() {
    this._notificationSubscription = Notifications.addListener(this._handleNotification);
  }

  _handleNotification = (notification) => {
    this.setState({notification: notification});
  };

  render() {
    return (
      <AppNavigator></AppNavigator>
    );
  }
}

export default App;

I would say the only thing you’re lacking here is calling registerForPushNotificationsAsync() from componentWillMount, as shown in the example here: https://docs.expo.io/versions/latest/guides/push-notifications.html#3-handle-receiving-andor-selecting-the-notification

An example for that function is found here: https://docs.expo.io/versions/latest/guides/push-notifications.html#1-save-the-users-expo-push-token-on-your-server

Thank you Dave, but it was a mistake from my part, it’s working now, i just didn’t understando how things were working…
I put an alert on the listener, and the push worked, foregrounded and backgrounded

1 Like