Answers for "how to element firebase cloud messaging in laravel"

PHP
0

how to element firebase cloud messaging in laravel

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);
    }
}
Posted by: Guest on March-17-2021

Code answers related to "how to element firebase cloud messaging in laravel"

Browse Popular Code Answers by Language