PHP code example of canerdogan / laravel-notification-channel-fcm

1. Go to this page and download the library: Download canerdogan/laravel-notification-channel-fcm library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

canerdogan / laravel-notification-channel-fcm example snippets


class AccountActivated extends Notification
{
    public function via($notifiable)
    {
        return [FcmChannel::class];
    }

    public function toFcm($notifiable)
    {
        // The FcmNotification holds the notification parameters
        $fcmNotification = FcmNotification::create()
            ->setTitle('Your account has been activated')
            ->setBody('Thank you for activating your account.');
            
        // The FcmMessage contains other options for the notification
        return FcmMessage::create()
            ->setPriority(FcmMessage::PRIORITY_HIGH)
            ->setTimeToLive(86400)
            ->setFcmKey('xxxx') // (Optional) Use this to override the FCM key from broadcasting.php
            ->setNotification($fcmNotification);
    }
}

setFcmKey(string $fcmKey)

setCondition(string $condition)

setCollapseKey(string $collapseKey)

setContentAvailable(bool $contentAvailable)

setMutableContent(bool $mutableContent)

setPriority(string $priority)

setTimeToLive($timeToLive)

setDryRun(bool $dryRun)

setData(string $data)

setNotification(FcmNotification $notification)

setTitle(string $title)

setBody(string $body)

setClickAction(string $clickAction)

setAndroidChannelId(string $androidChannelId)

setIcon(string $icon)

setBadge(string $badge)

setSound(string $sound)

setTag(string $tag)

setColor(string $color)

setBodyLocKey(string $bodyLocKey)

setBodyLocArgs(array $bodyLocArgs)

setTitleLocKey(string $titleLocKey)

setTitleLocArgs(array $titleLocArgs)