Testing Background Fetch when App Terminates (Xiaomi MIUI 12)


I am developing an android app which basically needs to pull data from REST API every one minute and run in the background even when in background, terminated and on reboot. Currently, i am using the managed workflow and expo-background-fetch and expo-task-manager. All is working fine when app is in the background, i am getting the log statements. However, when i terminate the app, i stop to get any notifications and on startup again i get all of the ones which have missed. What am i missing?

I am using the Expo Client on android to test the app.

I have given the Expo Client all permissions as per Xiaomi | Don’t kill my app!

That is my sample code.

import * as BackgroundFetch from 'expo-background-fetch';
import * as TaskManager from "expo-task-manager"
import { BACKGROUND_FETCH_PRICE_TASK } from './Constants'

TaskManager.defineTask(BACKGROUND_FETCH_PRICE_TASK, async () => {
    const now = new Date();
    console.log(`Got background fetch call at: ${now.toISOString()}`)
    try {
        return BackgroundFetch.Result.NewData;
    } catch (error) {
        return BackgroundFetch.Result.Failed;

export const initBackgroundTasks = async () => {

    await BackgroundFetch.registerTaskAsync(BACKGROUND_FETCH_PRICE_TASK, {
        minimumInterval: 60, //1 minute
        stopOnTerminate: false,
        startOnBoot: true

        .then(tasks => {
            console.log(`Registered tasks: ${JSON.stringify(tasks)}`)


I have a same problem. I need this function. How did you solve it?

Hi, I ended up ejecting and using GitHub - transistorsoft/react-native-background-fetch: Periodic callbacks in the background for both IOS and Android