I trying to use foreground services from https://www.npmjs.com/package/@supersami/rn-foreground-service and the problem i have facing is when i start the service it creates a notification but i cannot handle the event when i press the buttons on the notification or the main area of the notification.
the package i use https://www.npmjs.com/package/@supersami/rn-foreground-service
const start =async()=>{
ReactNativeForegroundService.add_task(() => regularFunct(), {
delay: 1000,
onLoop: true,
taskId: "taskid",
onError: (e) => console.log(`Error logging:`, e),
});
//DeviceEventEmitter.addListener('notificationClickHandle',stop);
ReactNativeForegroundService.eventListener(()=>stop);
ReactNativeForegroundService.start({
id: 1244,
title: "Foreground Service",
message: "We are live World",
icon: "ic_launcher",
button: true,
buttonText: "Button",
buttonOnPress: "notificationClickHandle", //this line i thought it will call the function but it does nothing
mainOnPress:"notificationClickHandle", // same here
setOnlyAlertOnce: true,
color: "#000000",
progress: {
max: 100,
curr: 50,
},
});
}
const stop = async()=>{
ReactNativeForegroundService.stop();
so i need to let the users to turn off the foreground service without entering the app and pressing the stop service button but just by pressing the notification itself.
Domesan is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.