🇧🇷Brazil @leopaccanaro

Account created on 13 April 2012, almost 13 years ago
  • Senior Developer at CI&T 
#

Recent comments

🇧🇷Brazil leopaccanaro

Hello @ptmkenny.

Unfortunately I am focused more on Java projects and with a special daughter. Sorry to hear @thalles and @renatog are not active around here.
I know Renato and I will talk to him later. I think is on vacation right now.
In the mean time, any of you want to maintain the module? Let me know.

🇧🇷Brazil leopaccanaro

Hello octaviosch.
FCM with websites is not my specialty. Additionally, the SDK is mainly used in Javascript/Typescript websites not PHP.

That been said, have you read https://firebase.google.com/docs/cloud-messaging/js/client and https://dev.to/thisdotmedia/pwa-push-notifications-with-firebase-cloud-m...?

This second link in particular covers an example, with Javascript. You'll have to do lots of adaptations, but I guess it's possible to achieve what you want.

If you are unable to do it, please have a Github repository available (or similar) so we can look into the codes and help you, when we have the time.
Your question is not really about this module and Drupal community.

🇧🇷Brazil leopaccanaro

Hello.

I suggest you reading
https://firebase.google.com/docs/ios/setup
https://firebase.google.com/docs/android/setup

After you've added the SDK into your mobile app, you need to receive the token. I would recommend having an endpoint in Drupal that will receive Firebase token and store it in your database.
Then you can use it to send notifications.

At the homepage of this module we added a guideline. Have you read it?

Module Setup
These are the steps to get the notifications working:

Create a Firebase account
Add Firebase to your iOS project OR Android project
Enable this module
Add your firebase Server Key into /admin/config/system/firebase
Each device has a token. Store that token on Drupal
Call Firebase service passing the device's token and message
// Token is generated by app. You'll have to send the token to Drupal.
$fakeToken = 'e3vUiwcvkpY:APA91bEDZzKTIkaL0e-UTwiV6EGi1m5J5PrDMxejm6-d85vdwAgd';
$messageService = \Drupal::service('firebase.message');
$messageService->setRecipients($fakeToken);
$messageService->setNotification([
  'title' => 'Title goes here',
  'body' => 'Body goes here',
  'badge' => 1,
  'icon' => 'optional-icon',
  'sound' => 'optional-sound',
  'click_action' => 'optional-action',
]);
$messageService->setData([
  'score' => '3x1',
  'date' => '2017-10-10',
  'optional' => 'Data is used to send silent pushes. Otherwise, optional.',
]);
$messageService->setOptions(['priority' => 'normal']);
$messageService->send();
Production build 0.71.5 2024