- Issue created by @drupalfan2
- 🇯🇵Japan ptmkenny
Basically, this module is a wrapper around kreait/firebase-php, so its documentation can be helpful.
The API for this module is in https://git.drupalcode.org/project/firebase_php/-/blob/7.0.x/src/FirebasePhpMessagingApiInterface.php?ref_type=heads.
Here's an actual example of how I send notifications to users. Note that I am using Push Notifications Registration Tokens → to store the push tokens.
if ($unread_message_count) { $registration_tokens_service = \Drupal::service('push_notifications_registration_tokens.process_tokens'); $push_tokens = $registration_tokens_service->getAllTokensForUser($current_user); /** @var \Drupal\firebase_php\Service\FirebasePhpMessagingApi $messageService */ $messageService = \Drupal::service('firebase_php.messaging_drupal_api'); // Send push notifications for all registered devices. $notification_title = 'You have new messages'; $notification_body = 'You have' . $unread_message_count. ' unread messages.'; $messageService->sendMessageMultipleDevices( $push_tokens, $notification_title, $notification_body, NULL, NULL, NULL, $unread_message_count, ); }
- 🇯🇵Japan ptmkenny
I'm going to mark this as fixed. Feel free to re-open if you're still having issues.
Automatically closed - issue fixed for 2 weeks with no activity.