How to pass optional data
bluelupin opened this issue · 4 comments
bluelupin commented
I want to send optional data like. ["url" => "https://www.google.com"]
I don't see any option.
Additionally, how can I get a downstream response for failed tokens?
gentritabazi commented
Hi @bluelupin,
- On next release you can pass optional/everything data you need.
- For response from firebase you just need to return or dump like this:
return Larafirebase::withTitle('Test Title')
->withBody('Test body')
->sendNotification($this->deviceTokens);
And you get response like this:
{
"multicast_id": 4457181225109722248,
"success": 0,
"failure": 1,
"canonical_ids": 0,
"results": [
{
"error": "InvalidRegistration"
}
]
}
alchalade commented
@bluelupin I had the same problem, you can use fromArray
on both methods(sendNotification and sendMessage) that will bypass the title, body ,... . Below is the part that builds the dataArray.
$fields = array(
'registration_ids' => $tokens,
'notification' => ($this->fromArray) ? $this->fromArray : [
'title' => $this->title,
'body' => $this->body,
'image' => $this->image,
'click_action' => $this->clickAction
],
'priority' => $this->priority
);
gentritabazi commented
@alchalade yes you can use fromArray
if you want to pass whatever you want for notification
or data
object.
bluelupin commented
Hi @bluelupin,
- On next release you can pass optional data.
- For response from firebase you just need to return or dump like this:
return Larafirebase::withTitle('Test Title') ->withBody('Test body') ->sendNotification($this->deviceTokens);
And you get response like this:
{ "multicast_id": 4457181225109722248, "success": 0, "failure": 1, "canonical_ids": 0, "results": [ { "error": "InvalidRegistration" } ] }
Is there any way we can know which were the failed tokens.