dispatchEvent details are not passed to background args

Aperta
#100 0 commenti 1 reazione 1 assegnatario Vedi su GitHub

@theproducer ci sta già lavorando.

Dal 15/7/2024.

Valutazione

Questa issue non è ancora stata valutata.

Descrizione

As the title describes dispatchEvent details are not passed to background args so i cannot use any component data in my background proces for fetching stuff for example

Let's say i have a function triggered by a button:

  async activateBackgroundTask() {
    try {
      await BackgroundRunner.dispatchEvent({
        label: 'com.app.app.check',
        event: 'backgroundEventExecute',
        details: { hello: "Hello world"},
      })
    } catch (error) {
      console.error('Background task error:', error);
    }
  }

And a runner.js like this:

addEventListener('backgroundEventExecute', async (resolve, reject, args) => {
  try {
    // Notify that the background event was triggered
    console.log('backgroundEventExecute: ', args, args.hello);
    resolve();
  } catch (error) {
    console.error('Error in backgroundEvent:', error);
    reject(error);
  }
});

My args is always empty so the data i want to pass will never reach the background process. My console.log is reached and printed in the console. I've also tried to use CapacitorKV.get but i cannot use CapacitorKV.set in my angular/ionic component as it is not available there..

Specs:

    "@capacitor/background-runner": "^1.1.0",
    Angular: 17.x.x
    Capacitor: 6.x.x

Can someone please tell me how to solve this issue OR fix this so we can use this background-runner?

Thanks in advance!

Lingua principale
C
Stelle
57
Fork
36
Merge medio
3g 18h
PR unite (30g)
7

Preparare l'ambiente

Come iniziare

  1. Leggi tutta la issue e poi la guida ai contributi del progetto.
  2. Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
  3. Fai un fork del repository e lavora su un branch.
  4. Apri una pull request che faccia riferimento al numero della issue.

Altre issue di ionic-team/capacitor-background-runner

Tutte le issue di ionic-team/capacitor-background-runner

Issue simili

Altre issue su C

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.