HI,
i am done push notification but if the app is closed they did came .is there any option when app is closed show notification.
HI,
i am done push notification but if the app is closed they did came .is there any option when app is closed show notification.
Know the answer? Post it — somebody with the same question will find it here.
Sign in to answer this question
It is the same account you read, post and publish with — and you will come straight back to this page.
Brad SmithPosted May 25, 2022, 5:33 AM
Firebase cloud messaging is available even if your app is closed. However, if someone changes data, it is not possible because the program terminates all activity when it is closed. To call your task in the background, you must utilize Headless JavaScript. However, you should try react-native-background-fetch for app optimization. Then set your job to run in the background.
Here's how to go about it:
step 1: install the react-native npm background package
step 2: develop a headless js
step 3: insert your task inside it ( as shown below)
...
const ref = firestore().collection('players');
return ref.onSnapshot(querySnapshot => {
querySnapshot.forEach(doc => {
....
// called push notification
PushNotification.localNotification({
channelId,
title,
message,
bigText,
});
});
});
...
Santosh KaranamPosted May 13, 2022, 4:22 PM