evollu / evollu/react-native-fcm

How to pop up Push Notification when app is killed? (iOS)

Open
#695 1 comment 0 reactions 0 assignees View on GitHub
question
Dominant language
Java
Stars
1.7k
Forks
661
PR merge metrics
No merged PRs in 30d

Description

1. What version of RN and react-native-fcm are you running? RN 48 FB 9.6.2
2. What device are you using? (e.g iOS9 emulator, Android 6 device)? iOS11 iPhone SE
3. Is your app running in foreground, background or not running?

I am trying to pop up Push Notification when I get a message from my server when the app is killed. Below code is what I tried, but it doesn't pop up the Notification even if the event is triggered. Instead, when I open the app, it vibrate continuously. (I saw that you mentioned not to use the FCM.presentLocalNotification inside the event, but I have no idea how to pop up the notification except here when I get a message )

```
export function registerKilledListener(){
// these callback will be triggered even when app is killed
FCM.on(FCMEvent.Notification, async (notif) => {
console.log('app is killed1');

FCM.presentLocalNotification({
vibrate: 500,
title: 'Hello',
body: 'Test Notification',
big_text: 'i am large',
priority: "high",
sound: "bell.mp3",
large_icon: "https://image.freepik.com/free-icon/small-boy-cartoon_318-38077.jpg",
show_in_foreground: true,
number: 10
});

AsyncStorage.setItem('lastNotification', JSON.stringify(notif));
});
}
```

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.