Closed kivancguncavdi closed 6 years ago
I just solved the problem by using the following code right above the component in index.js file:
const clearFunc = () =>{
PushNotification.cancelAllLocalNotifications();
}
const notif = (msg) => {
PushNotification.localNotification({
//title: notification['gcm.notification.title'],
message: msg// (required)
//subText: notification['gcm.notification.subText'],
//tag: notification['gcm.notification.tag'],
//group: notification['gcm.notification.group'],
});
}
BackgroundTask.define(async () => {
clearFunc();
notif("Hello World!");
BackgroundTask.finish();
});
Hi all! I'm new in React Native and I'm working on building a forecast application. Right now, I can fetch some data from a forecast API when the app is in background. It works fine. On the other hand, I'm also using react-native-push-notification in the app. All I want to do is to create a local notification whenever a new data fetched in the background and set the notficiation's message property as the fetched data. To do this, I'm calling
PushNotification.configure
andPushNotification.localNotification
functions insideBackgroundTask.define
but it's not working. I need to make a connection between these two but I have no idea how to do.Can anybody help me or give me some advices?