Laravel Firebase Cloud Messaging Pack

Larafirebase is a package that allows push notifications and sending private messages. 

Firebase uses Firebase Cloud Messaging, a cross-platform messaging solution, to send notifications to client-side users in laravel apps.

toFirebase()special firebasea sample notification class that provides the method of sending notifications through the channel:

use Illuminate\Notifications\Notification;
use Kutia\Larafirebase\Messages\FirebaseMessage;

class SendBirthdayReminder extends Notification
{
/**
* Get the notification's delivery channels.
*/
public function via($notifiable)
{
return ['firebase'];
}

/**
* Get the firebase representation of the notification.
*/
public function toFirebase($notifiable)
{
$deviceTokens = [
'{TOKEN_1}',
'{TOKEN_2}'
];

return (new FirebaseMessage)
->withTitle('Hey, ', $notifiable->first_name)
->withBody('Happy Birthday!')
->asNotification($deviceTokens); // OR ->asMessage($deviceTokens);
}
}

You must also type client code to use this package. For an example of how to use this package on the client side, see the project's javascript-client folder.

You can check the source code to learn more about this package and get complete installation instructions.

  Quote

KARABAY A, 2021 . Laravel Firebase Cloud Messaging Pack,

https://www.karabayyazilim.com/blog/php/framework/laravel/laravel-firebase-cloud-messaging-paketi-2021-02-10-172749

(Accessed February 10, 2021).


  Share this post

Comments (0)

Comment

Subscribe
Sign up for the email newsletter to be the first to know about my blog posts