Geolocation - background tasks

Hi
Im trying to implement background tasks in my ionic-capacitor-angular app but i am not able to.
my goal is to get user location every x minutes and then return that.

i have followed this official guide create-background-tasks-in-ionic-with-capacitor for android but doesnt work.

function that save and resolve CapacitorKV works well but when I dispatch a function that uses fetch, app closes. runners/runner.js

right now, im making tests by clicking buttons to dispatch background tasks, in fact it should be automatically when app is in background but it doesnt works (setInterval 1min at capacitor.config.ts, capacitor.config.json)

  async performBackgroundFetch() {
    const result = await BackgroundRunner.dispatchEvent({
      label: 'com.company.appName.check',
      event: 'fetchTest',
      details: {},
    });
    this.user = result;
  }
addEventListener("fetchTest", async (resolve, reject, args) => {
  try {
    const res = await fetch("https://randomuser.me/api/");
    console.log("fetchTest res", res);
    if (!res.ok) {
      throw new Error("Could not fetch user");
    }

    const result = await res.json();
    resolve(result["results"][0]);
  } catch (err) {
    console.error(err);
    reject(err);
    console.log("efrrrrr");
  }
});

image


other error exaple. dont get coordinates


  loadCheckins = async () => {
    console.log('loadCheckins bef');
    const result = (await BackgroundRunner.dispatchEvent({
      label: 'com.companyName.appName.check',
      event: 'loadCheckins',
      details: {},
    })) as any;
    console.log('loadCheckins aft result', result);
    console.log('loadCheckins this.checkins', this.checkins);

    if (result) {
      this.checkins = [];
      Object.keys(result).forEach((key) => {
        this.checkins.push(result[key]);
      });
      this.addMarkers();
    }
  };

runner.js

addEventListener("loadCheckins", (resolve, reject, args) => {
  console.log("loadCheckinsloadCheckinsloadCheckins ");
  try {
    const { value } = CapacitorKV.get("CHECKINS");
    try {
      const arr = JSON.parse(value);
      console.log("loadCheckins arr", arr);
      resolve(arr);
    } catch (e) {
      console.log("loadCheckins error", error);
      resolve([]);
    }
  } catch (err) {
    console.log("err laodchecking");
    console.error(err);
    reject([]);
  }

what i am doing wrong? i have setting config in android manifest

show your Background Runner config…