Hacktoberfest 2026: the issues maintainers tagged for October, open and beginner-friendly. Browse Hacktoberfest issues

dispatchEvent details are not passed to background args

Open
#100 0 comments 1 reaction 1 assignee View on GitHub

@theproducer is already working on this.

Since Jul 15, 2024.

Assessment

This issue has not been assessed yet.

Description

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!

Dominant language
C
Stars
56
Forks
36
Avg merge
3d 17h
Merged PRs (30d)
3

Getting set up

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from ionic-team/capacitor-background-runner

All issues in ionic-team/capacitor-background-runner

Similar issues

More C issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.