Reputation: 1188
I'm trying to use PushNotificationIOS
in react-native, but nothing happens.
I have the following code:
PushNotificationIOS.requestPermissions();
PushNotificationIOS.presentLocalNotification(
{
alertBody: 'Hello world!!!'
}
);
I'm running on a device and I did enable notifications for my app.
Moreover, when I run
PushNotificationIOS.checkPermissions((permissions) => {
console.log(permissions);
});
It returns me
{ badge: 1, sound: 1, alert: 1 }
Indicating that the notifications have indeed been enabled.
However, I still cannot see anything on the screen.
Upvotes: 4
Views: 3097
Reputation: 1188
Solved! I was trying to display a push notifications while still having the app in the foreground. Of course, that wouldn't work. An app has to be in the background for a push notification to work.
Upvotes: 2