react-native-background-fetch: react-native-background-fetch is not triggering in iOS and Android both.
Please let me know apart from javascript/typescript file anything else is required to make backgroundfetch working.
Your Environment
- Plugin version:
- Platform: iOS and Android
- OS version: iOS 15.0
- Device manufacturer / model: iPhone 13 Simulator
- React Native version (
react-native -v):0.71.11" - Plugin config
Expected Behavior
It should trigger background fetch call back method when simulating via Xcode.
Actual Behavior
It doesn’t trigger background fetch call back method when simulating via Xcode.
Steps to Reproduce
- Set up the background fetch in your React Native application.
- Call configureBackgroundFetch with the necessary parameters.
- Simulate a background fetch using Xcode.
- Observe that the fetch callback does not execute.
Context
Below is the sample code.
export const configureBackgroundFetch = async (
backgroundFunction: () => Promise<void>,
crlRevocationCheckTimeInterval: number
): Promise<void> => {
const onFetch = async (taskId: string) => {
try {
logger.info(`BackgroundFetch is executing backgroundFunction. (Task ID: ${taskId})`);
await backgroundFunction();
logger.info("BackgroundTaskExecuted: BackgroundFetch task completed");
} catch (error) {
logger.error(`Error executing backgroundFunction. (Task ID: ${taskId})`, error);
} finally {
BackgroundFetch.finish(taskId);
}
};
const onTimeout = (taskId: string) => {
logger.warn(`BackgroundFetch failed to start. (Task ID: ${taskId})`);
BackgroundFetch.finish(taskId);
};
await BackgroundFetch.configure(
{
minimumFetchInterval: crlRevocationCheckTimeInterval,
stopOnTerminate: true,
startOnBoot: false,
},
(taskId: string) => void onFetch(taskId),
onTimeout
);
};
Debug logs
Additional Information
Please provide any additional context or configuration that may help diagnose the issue, such as:
Permissions in Info.plist for iOS.
About this issue
- Original URL
- State: closed
- Created 2 years ago
- Comments: 17 (6 by maintainers)
Please learn to syntax highlight “fenced code blocks”:
https://docs.github.com/en/get-started/writing-on-github/working-with-advanced-formatting/creating-and-highlighting-code-blocks#fenced-code-blocks