php-firebase-cloud-messaging
php-firebase-cloud-messaging copied to clipboard
How to send an Image through notification or data message type?
I have tried the following code.
$message = new Message(); $message->setPriority('high'); $message->addRecipient(new Device('DEVICE_TOKEN')); $message ->setNotification(new Notification('Notification Title', 'Notification Body',"Image_URL")); //->setData(['key' => 'value']); $response = $client->send($message);
You can use this method to set the icon of the notification:
// android only, set the name of your drawable resource as string
$message->setIcon('name');
Or if you just want to send an image url and then capture it on client side you can send it as Data.
$notification->setData(['image_url' => 'absolute_path_of_image'])