Can you please help me. I want to display notification after every 15 mins even when the app is terminated or closed. It works fine when the app is open but it doesn't work when the app is closed or terminated.
Your Environment
Plugin version:4.2.1
Platform: Android
OS version: Android 11
Device manufacturer / model: K20 Pro
React Native version (react-native -v): 0.72.6
Expected Behavior
It should work even when the app is closed or terminated.
Actual Behavior
It work only when the app is running is the foreground.
Context
I want to make an app that gives notification after every 15 mins in loop even when the app is closed or terminated.
My Code: (onDisplayNotification is used to just display notification).
`
const addEvent = (taskId) => {
const timestamp = new Date().toLocaleString();
setEvents((prevEvents) => [...prevEvents, { taskId, timestamp }]);
};
Can you please help me. I want to display notification after every 15 mins even when the app is terminated or closed. It works fine when the app is open but it doesn't work when the app is closed or terminated.
Your Environment
react-native -v
): 0.72.6Expected Behavior
It should work even when the app is closed or terminated.
Actual Behavior
It work only when the app is running is the foreground.
Context
I want to make an app that gives notification after every 15 mins in loop even when the app is closed or terminated.
My Code: (onDisplayNotification is used to just display notification). ` const addEvent = (taskId) => { const timestamp = new Date().toLocaleString(); setEvents((prevEvents) => [...prevEvents, { taskId, timestamp }]); };
const initBackgroundFetch = async () => { const onEvent = async (taskId) => { console.log('[BackgroundFetch] Task:', taskId); onDisplayNotification() await addEvent(taskId); BackgroundFetch.finish(taskId); };
};
useEffect(() => { initBackgroundFetch(); onDisplayNotification() }, []); `