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

How to add payload data? #25

Open
nutella opened this issue Jun 24, 2024 · 1 comment
Open

How to add payload data? #25

nutella opened this issue Jun 24, 2024 · 1 comment

Comments

@nutella
Copy link

nutella commented Jun 24, 2024

I've tried with something like:

$data = [];
$data['id'] = 10;
$data['link'] = 'https://www.github.com';
$client -> build($recipient, $notification, $data);

But got this error: "Got error 'PHP message: PHP Fatal error: Uncaught TypeError: Argument 3 passed to phpFCMv1\Client::build() must be an instance of phpFCMv1\Data or null, array given"

...but $data is an array...

What's wrong?

Thanks.

@nutella
Copy link
Author

nutella commented Jun 25, 2024

This seems to work:

$data = new Data();
$foo['id'] = 10;
$foo['link'] = 'https://www.github.com';
$bar['data'] = $foo;
$data->setPayload($bar);
$client -> build($recipient, $notification, $data);

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

1 participant