Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

dispatchEvent details are not passed to background args #100

Open
Rdevc opened this issue Jul 12, 2024 · 0 comments
Open

dispatchEvent details are not passed to background args #100

Rdevc opened this issue Jul 12, 2024 · 0 comments
Assignees

Comments

@Rdevc
Copy link

Rdevc commented Jul 12, 2024

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!

@theproducer theproducer self-assigned this Jul 15, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants