kreait / laravel-firebase

A Laravel package for the Firebase PHP Admin SDK

Home Page:https://github.com/kreait/firebase-php

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Large Image Support

aleemb opened this issue · comments

I have tried the below snippets on Android-Chrome versus Mac-Chrome, so using browser-push here and not native-app push notifications. I have also tried combining both the below into a single message.

$message = new RawMessageFromArray([
  'token' => $iid,
  'webpush' => [
	// https://firebase.google.com/docs/reference/fcm/rest/v1/projects.messages#webpushconfig
	'notification' => [
	  'title' => 'Test title lorem ipsum',
	  'body' => 'Body test lorem ipsum dolor amet',
	  'image' => 'https://via.placeholder.com/800x400/fb0/000.png',
	  'icon' => 'https://via.placeholder.com/100x100/ac0/000.png',
	  'badge' => 'https://via.placeholder.com/100x100/ca0/000.png',
	],
];
$messaging = $this->firebase->createMessaging();
$response = $messaging->send($message);


$message = new RawMessageFromArray([
  'token' => $iid,
  'notification' => [
	  'title' => 'Test title lorem ipsum',
	  'body' => 'Body test lorem ipsum dolor amet',
	  'icon' => 'https://via.placeholder.com/800x400/fb0/000.png',
  ]);

$messaging = $this->firebase->createMessaging();
$response = $messaging->send($message);

The issue I am facing is that with the webpush I see a large 800x400 image and a 100x100 icon on Android-Chrome. However, on Mac-Chrome, the 100x100 icon is the main image and I can't get an icon to show. If I change the icon to 800x800 I get the larger image on Mac-Chrome but that breaks Android-Chrome which still shows it as the icon.

I have tried various permutations of icon/image/badge and notification/webpush but not sure what I'm missing. There are sites which send the correct notification across all (large Image + Icon on Android-Chrome and on Mac-Chrome).

Am I missing something here? Are services like OneSignal managing to accomplish this by tracking the device types and sending different payloads to the various device groups?

I'm sorry, but how to configure a message so that it is handled by the clients in a certain way is out of the scope of this package so I can't provide support here. I think this question is better suited on StackOverflow. 🤞