laravel-notification-channels / fcm

Firebase Cloud Messaging (FCM) notifications channel for Laravel
https://laravel-notification-channels.com/
MIT License
495 stars 127 forks source link

Call to a member function routeNotificationFor() on int #59

Closed pratamatama closed 4 years ago

pratamatama commented 4 years ago

Hi! I have problem when implementing this package. I'm sure I have followed the instruction properly. No idea what causing this.

stackTrace

{
    "message": "Call to a member function routeNotificationFor() on int",
    "exception": "Error",
    "file": "/Users/warmachine/Documents/Programming/Laravel/censoredprojectname/vendor/laravel-notification-channels/fcm/src/FcmChannel.php",
    "line": 33,
    "trace": [
        {
            "file": "/Users/warmachine/Documents/Programming/Laravel/censoredprojectname/vendor/laravel/framework/src/Illuminate/Notifications/NotificationSender.php",
            "line": 148,
            "function": "send",
            "class": "NotificationChannels\Fcm\FcmChannel",
            "type": "->"
        },
        {
            "file": "/Users/warmachine/Documents/Programming/Laravel/censoredprojectname/vendor/laravel/framework/src/Illuminate/Notifications/NotificationSender.php",
            "line": 106,
            "function": "sendToNotifiable",
            "class": "Illuminate\Notifications\NotificationSender",
            "type": "->"
        },
        {
            "file": "/Users/warmachine/Documents/Programming/Laravel/censoredprojectname/vendor/laravel/framework/src/Illuminate/Support/Traits/Localizable.php",
            "line": 19,
            "function": "Illuminate\Notifications\{closure}",
            "class": "Illuminate\Notifications\NotificationSender",
            "type": "->"
        },
        {
            "file": "/Users/warmachine/Documents/Programming/Laravel/censoredprojectname/vendor/laravel/framework/src/Illuminate/Notifications/NotificationSender.php",
            "line": 109,
            "function": "withLocale",
            "class": "Illuminate\Notifications\NotificationSender",
            "type": "->"
        },
        {
            "file": "/Users/warmachine/Documents/Programming/Laravel/censoredprojectname/vendor/laravel/framework/src/Illuminate/Notifications/NotificationSender.php",
            "line": 79,
            "function": "sendNow",
            "class": "Illuminate\Notifications\NotificationSender",
            "type": "->"
        },
        {
            "file": "/Users/warmachine/Documents/Programming/Laravel/censoredprojectname/vendor/laravel/framework/src/Illuminate/Notifications/ChannelManager.php",
            "line": 39,
            "function": "send",
            "class": "Illuminate\Notifications\NotificationSender",
            "type": "->"
        },
        {
            "file": "/Users/warmachine/Documents/Programming/Laravel/censoredprojectname/vendor/laravel/framework/src/Illuminate/Support/Facades/Facade.php",
            "line": 261,
            "function": "send",
            "class": "Illuminate\Notifications\ChannelManager",
            "type": "->"
        },
        {
            "file": "/Users/warmachine/Documents/Programming/Laravel/censoredprojectname/app/Http/Controllers/API/V1/AgendaController.php",
            "line": 74,
            "function": "__callStatic",
            "class": "Illuminate\Support\Facades\Facade",
            "type": "::"
        },
        {
            "function": "store",
            "class": "App\Http\Controllers\API\V1\AgendaController",
            "type": "->"
        },
        {
            "file": "/Users/warmachine/Documents/Programming/Laravel/censoredprojectname/vendor/laravel/framework/src/Illuminate/Routing/Controller.php",
            "line": 54,
            "function": "call_user_func_array"
        },
        {
            "file": "/Users/warmachine/Documents/Programming/Laravel/censoredprojectname/vendor/laravel/framework/src/Illuminate/Routing/ControllerDispatcher.php",
            "line": 45,
            "function": "callAction",
            "class": "Illuminate\Routing\Controller",
            "type": "->"
        },
        {
            "file": "/Users/warmachine/Documents/Programming/Laravel/censoredprojectname/vendor/laravel/framework/src/Illuminate/Routing/Route.php",
            "line": 255,
            "function": "dispatch",
            "class": "Illuminate\Routing\ControllerDispatcher",
            "type": "->"
        },
        {
            "file": "/Users/warmachine/Documents/Programming/Laravel/censoredprojectname/vendor/laravel/framework/src/Illuminate/Routing/Route.php",
            "line": 197,
            "function": "runController",
            "class": "Illuminate\Routing\Route",
            "type": "->"
        },
        {
            "file": "/Users/warmachine/Documents/Programming/Laravel/censoredprojectname/vendor/laravel/framework/src/Illuminate/Routing/Router.php",
            "line": 691,
            "function": "run",
            "class": "Illuminate\Routing\Route",
            "type": "->"
        },
        {
            "file": "/Users/warmachine/Documents/Programming/Laravel/censoredprojectname/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php",
            "line": 128,
            "function": "Illuminate\Routing\{closure}",
            "class": "Illuminate\Routing\Router",
            "type": "->"
        },
        {
            "file": "/Users/warmachine/Documents/Programming/Laravel/censoredprojectname/vendor/laravel/framework/src/Illuminate/Routing/Middleware/SubstituteBindings.php",
            "line": 41,
            "function": "Illuminate\Pipeline\{closure}",
            "class": "Illuminate\Pipeline\Pipeline",
            "type": "->"
        },
        {
            "file": "/Users/warmachine/Documents/Programming/Laravel/censoredprojectname/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php",
            "line": 167,
            "function": "handle",
            "class": "Illuminate\Routing\Middleware\SubstituteBindings",
            "type": "->"
        },
        {
            "file": "/Users/warmachine/Documents/Programming/Laravel/censoredprojectname/vendor/laravel/framework/src/Illuminate/Routing/Middleware/ThrottleRequests.php",
            "line": 127,
            "function": "Illuminate\Pipeline\{closure}",
            "class": "Illuminate\Pipeline\Pipeline",
            "type": "->"
        },
        {
            "file": "/Users/warmachine/Documents/Programming/Laravel/censoredprojectname/vendor/laravel/framework/src/Illuminate/Routing/Middleware/ThrottleRequests.php",
            "line": 103,
            "function": "handleRequest",
            "class": "Illuminate\Routing\Middleware\ThrottleRequests",
            "type": "->"
        },
        {
            "file": "/Users/warmachine/Documents/Programming/Laravel/censoredprojectname/vendor/laravel/framework/src/Illuminate/Routing/Middleware/ThrottleRequests.php",
            "line": 55,
            "function": "handleRequestUsingNamedLimiter",
            "class": "Illuminate\Routing\Middleware\ThrottleRequests",
            "type": "->"
        },
        {
            "file": "/Users/warmachine/Documents/Programming/Laravel/censoredprojectname/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php",
            "line": 167,
            "function": "handle",
            "class": "Illuminate\Routing\Middleware\ThrottleRequests",
            "type": "->"
        },
        {
            "file": "/Users/warmachine/Documents/Programming/Laravel/censoredprojectname/vendor/laravel/framework/src/Illuminate/Auth/Middleware/Authenticate.php",
            "line": 44,
            "function": "Illuminate\Pipeline\{closure}",
            "class": "Illuminate\Pipeline\Pipeline",
            "type": "->"
        },
        {
            "file": "/Users/warmachine/Documents/Programming/Laravel/censoredprojectname/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php",
            "line": 167,
            "function": "handle",
            "class": "Illuminate\Auth\Middleware\Authenticate",
            "type": "->"
        },
        {
            "file": "/Users/warmachine/Documents/Programming/Laravel/censoredprojectname/vendor/laravel/sanctum/src/Http/Middleware/EnsureFrontendRequestsAreStateful.php",
            "line": 33,
            "function": "Illuminate\Pipeline\{closure}",
            "class": "Illuminate\Pipeline\Pipeline",
            "type": "->"
        },
        {
            "file": "/Users/warmachine/Documents/Programming/Laravel/censoredprojectname/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php",
            "line": 128,
            "function": "Laravel\Sanctum\Http\Middleware\{closure}",
            "class": "Laravel\Sanctum\Http\Middleware\EnsureFrontendRequestsAreStateful",
            "type": "->"
        },
        {
            "file": "/Users/warmachine/Documents/Programming/Laravel/censoredprojectname/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php",
            "line": 103,
            "function": "Illuminate\Pipeline\{closure}",
            "class": "Illuminate\Pipeline\Pipeline",
            "type": "->"
        },
        {
            "file": "/Users/warmachine/Documents/Programming/Laravel/censoredprojectname/vendor/laravel/sanctum/src/Http/Middleware/EnsureFrontendRequestsAreStateful.php",
            "line": 34,
            "function": "then",
            "class": "Illuminate\Pipeline\Pipeline",
            "type": "->"
        },
        {
            "file": "/Users/warmachine/Documents/Programming/Laravel/censoredprojectname/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php",
            "line": 167,
            "function": "handle",
            "class": "Laravel\Sanctum\Http\Middleware\EnsureFrontendRequestsAreStateful",
            "type": "->"
        },
        {
            "file": "/Users/warmachine/Documents/Programming/Laravel/censoredprojectname/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php",
            "line": 103,
            "function": "Illuminate\Pipeline\{closure}",
            "class": "Illuminate\Pipeline\Pipeline",
            "type": "->"
        },
        {
            "file": "/Users/warmachine/Documents/Programming/Laravel/censoredprojectname/vendor/laravel/framework/src/Illuminate/Routing/Router.php",
            "line": 693,
            "function": "then",
            "class": "Illuminate\Pipeline\Pipeline",
            "type": "->"
        },
        {
            "file": "/Users/warmachine/Documents/Programming/Laravel/censoredprojectname/vendor/laravel/framework/src/Illuminate/Routing/Router.php",
            "line": 668,
            "function": "runRouteWithinStack",
            "class": "Illuminate\Routing\Router",
            "type": "->"
        },
        {
            "file": "/Users/warmachine/Documents/Programming/Laravel/censoredprojectname/vendor/laravel/framework/src/Illuminate/Routing/Router.php",
            "line": 634,
            "function": "runRoute",
            "class": "Illuminate\Routing\Router",
            "type": "->"
        },
        {
            "file": "/Users/warmachine/Documents/Programming/Laravel/censoredprojectname/vendor/laravel/framework/src/Illuminate/Routing/Router.php",
            "line": 623,
            "function": "dispatchToRoute",
            "class": "Illuminate\Routing\Router",
            "type": "->"
        },
        {
            "file": "/Users/warmachine/Documents/Programming/Laravel/censoredprojectname/vendor/laravel/framework/src/Illuminate/Foundation/Http/Kernel.php",
            "line": 166,
            "function": "dispatch",
            "class": "Illuminate\Routing\Router",
            "type": "->"
        },
        {
            "file": "/Users/warmachine/Documents/Programming/Laravel/censoredprojectname/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php",
            "line": 128,
            "function": "Illuminate\Foundation\Http\{closure}",
            "class": "Illuminate\Foundation\Http\Kernel",
            "type": "->"
        },
        {
            "file": "/Users/warmachine/Documents/Programming/Laravel/censoredprojectname/vendor/laravel/framework/src/Illuminate/Foundation/Http/Middleware/TransformsRequest.php",
            "line": 21,
            "function": "Illuminate\Pipeline\{closure}",
            "class": "Illuminate\Pipeline\Pipeline",
            "type": "->"
        },
        {
            "file": "/Users/warmachine/Documents/Programming/Laravel/censoredprojectname/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php",
            "line": 167,
            "function": "handle",
            "class": "Illuminate\Foundation\Http\Middleware\TransformsRequest",
            "type": "->"
        },
        {
            "file": "/Users/warmachine/Documents/Programming/Laravel/censoredprojectname/vendor/laravel/framework/src/Illuminate/Foundation/Http/Middleware/TransformsRequest.php",
            "line": 21,
            "function": "Illuminate\Pipeline\{closure}",
            "class": "Illuminate\Pipeline\Pipeline",
            "type": "->"
        },
        {
            "file": "/Users/warmachine/Documents/Programming/Laravel/censoredprojectname/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php",
            "line": 167,
            "function": "handle",
            "class": "Illuminate\Foundation\Http\Middleware\TransformsRequest",
            "type": "->"
        },
        {
            "file": "/Users/warmachine/Documents/Programming/Laravel/censoredprojectname/vendor/laravel/framework/src/Illuminate/Foundation/Http/Middleware/ValidatePostSize.php",
            "line": 27,
            "function": "Illuminate\Pipeline\{closure}",
            "class": "Illuminate\Pipeline\Pipeline",
            "type": "->"
        },
        {
            "file": "/Users/warmachine/Documents/Programming/Laravel/censoredprojectname/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php",
            "line": 167,
            "function": "handle",
            "class": "Illuminate\Foundation\Http\Middleware\ValidatePostSize",
            "type": "->"
        },
        {
            "file": "/Users/warmachine/Documents/Programming/Laravel/censoredprojectname/vendor/laravel/framework/src/Illuminate/Foundation/Http/Middleware/PreventRequestsDuringMaintenance.php",
            "line": 87,
            "function": "Illuminate\Pipeline\{closure}",
            "class": "Illuminate\Pipeline\Pipeline",
            "type": "->"
        },
        {
            "file": "/Users/warmachine/Documents/Programming/Laravel/censoredprojectname/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php",
            "line": 167,
            "function": "handle",
            "class": "Illuminate\Foundation\Http\Middleware\PreventRequestsDuringMaintenance",
            "type": "->"
        },
        {
            "file": "/Users/warmachine/Documents/Programming/Laravel/censoredprojectname/vendor/fruitcake/laravel-cors/src/HandleCors.php",
            "line": 57,
            "function": "Illuminate\Pipeline\{closure}",
            "class": "Illuminate\Pipeline\Pipeline",
            "type": "->"
        },
        {
            "file": "/Users/warmachine/Documents/Programming/Laravel/censoredprojectname/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php",
            "line": 167,
            "function": "handle",
            "class": "Fruitcake\Cors\HandleCors",
            "type": "->"
        },
        {
            "file": "/Users/warmachine/Documents/Programming/Laravel/censoredprojectname/vendor/fideloper/proxy/src/TrustProxies.php",
            "line": 57,
            "function": "Illuminate\Pipeline\{closure}",
            "class": "Illuminate\Pipeline\Pipeline",
            "type": "->"
        },
        {
            "file": "/Users/warmachine/Documents/Programming/Laravel/censoredprojectname/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php",
            "line": 167,
            "function": "handle",
            "class": "Fideloper\Proxy\TrustProxies",
            "type": "->"
        },
        {
            "file": "/Users/warmachine/Documents/Programming/Laravel/censoredprojectname/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php",
            "line": 103,
            "function": "Illuminate\Pipeline\{closure}",
            "class": "Illuminate\Pipeline\Pipeline",
            "type": "->"
        },
        {
            "file": "/Users/warmachine/Documents/Programming/Laravel/censoredprojectname/vendor/laravel/framework/src/Illuminate/Foundation/Http/Kernel.php",
            "line": 141,
            "function": "then",
            "class": "Illuminate\Pipeline\Pipeline",
            "type": "->"
        },
        {
            "file": "/Users/warmachine/Documents/Programming/Laravel/censoredprojectname/vendor/laravel/framework/src/Illuminate/Foundation/Http/Kernel.php",
            "line": 110,
            "function": "sendRequestThroughRouter",
            "class": "Illuminate\Foundation\Http\Kernel",
            "type": "->"
        },
        {
            "file": "/Users/warmachine/Documents/Programming/Laravel/censoredprojectname/public/index.php",
            "line": 66,
            "function": "handle",
            "class": "Illuminate\Foundation\Http\Kernel",
            "type": "->"
        },
        {
            "file": "/Users/warmachine/Documents/Programming/Laravel/censoredprojectname/server.php",
            "line": 21,
            "function": "require_once"
        }
    ]
}

implementation

<?php

namespace App\Notifications;

use App\Models\Agenda;
use Illuminate\Bus\Queueable;
use Illuminate\Contracts\Queue\ShouldQueue;
use Illuminate\Notifications\Messages\MailMessage;
use Illuminate\Notifications\Notification;
use NotificationChannels\Fcm\FcmChannel;
use NotificationChannels\Fcm\FcmMessage;
use NotificationChannels\Fcm\Resources\AndroidConfig;
use NotificationChannels\Fcm\Resources\AndroidFcmOptions;
use NotificationChannels\Fcm\Resources\AndroidNotification;
use NotificationChannels\Fcm\Resources\ApnsConfig;
use NotificationChannels\Fcm\Resources\ApnsFcmOptions;
use NotificationChannels\Fcm\Resources\Notification as ResourcesNotification;

class AgendaCreated extends Notification
{
    use Queueable;

    public $agenda;

    /**
     * Create a new notification instance.
     *
     * @return void
     */
    public function __construct(Agenda $agenda)
    {
        $this->agenda = $agenda;
    }

    /**
     * Get the notification's delivery channels.
     *
     * @param  mixed  $notifiable
     * @return array
     */
    public function via($notifiable)
    {
        return [FcmChannel::class];
    }

    /**
     * Get the fcm representation of the notification.
     *
     * @param  mixed  $notifiable
     * @return \NotificationChannels\Fcm\FcmMessage
     */
    public function toFcm($notifiable)
    {
        $author = $this->agenda->author->name;
        return FcmMessage::create()
            ->setToken($notifiable->fcm_token)
            ->setTopic('agenda')
            ->setNotification(
                ResourcesNotification::create()
                    ->setTitle('New agenda invitation!')
                    ->setBody('You\'ve been invited to participate in ' . $author . '\'s agenda. Tap here to see in details.')
            )
            ->setAndroid(
                AndroidConfig::create()
                    ->setFcmOptions(AndroidFcmOptions::create()->setAnalyticsLabel('analytics'))
                    ->setNotification(AndroidNotification::create()->setColor('#0A0A0A'))
            )
            ->setApns(
                ApnsConfig::create()
                    ->setFcmOptions(ApnsFcmOptions::create()->setAnalyticsLabel('analytics_ios'))
            );
    }

    /**
     * Get the array representation of the notification.
     *
     * @param  mixed  $notifiable
     * @return array
     */
    public function toArray($notifiable)
    {
        return [
            //
        ];
    }
}

model implementation

<?php

namespace App\Models;

use Illuminate\Contracts\Auth\MustVerifyEmail;
use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Foundation\Auth\User as Authenticatable;
use Illuminate\Notifications\Notifiable;
use Laravel\Sanctum\HasApiTokens;
use Spatie\Permission\Traits\HasRoles;

class User extends Authenticatable
{
    use HasFactory, HasApiTokens, Notifiable, HasRoles;

    /**
     * The attributes that are mass assignable.
     *
     * @var array
     */
    protected $fillable = [
        'avatar',
        'name',
        'email',
        'password',
        'fcm_token',
    ];

    /**
     * The attributes that should be hidden for arrays.
     *
     * @var array
     */
    protected $hidden = [
        'password', 'remember_token', // 'pivot',
    ];

    /**
     * The attributes that should be cast to native types.
     *
     * @var array
     */
    protected $casts = [
        'email_verified_at' => 'datetime',
    ];

    /**
     * Specifies the user's FCM token
     *
     * @return string
     */
    public function routeNotificationForFcm()
    {
        return $this->fcm_token;
    }
...
pratamatama commented 4 years ago

Finally got it works by changing the return statement to return an array instead of string. Please update the documation.

/**
 * Specifies the user's FCM token
 *
 * @return array
 */
public function routeNotificationForFcm()
{
    return $this->fcmToken()->pluck('token')->toArray();
}
ejlocop commented 3 years ago

@pratamatama did you make the FCMToken model and migration yourself? I couldn't find that on the docs.

also. the setToken method from the NotificationChannels\Fcm\FcmMessage is expecting a string type to be passed. when you changed the return of routeNotificationForFcm method, did it work?

pratamatama commented 3 years ago

Hi @ejlocop , I do make the model and migration myself to make it work. I don't know why using that $this->fcm_token doesn't work for me eventhough the column was defined & filled. Not sure about the setToken since I use this for my mobile app and the token was generated from their device.

I also modified some of the script for that agenda notification because for some reason my app can't get the information sent by the the example provided on the docs, so I put all of them on setData method.

You can see below if you curious about the implementation. I've tested it, work for me but not yet refactored. Hope it helps.

Models\FcmToken.php

class FcmToken extends Model
{
    use HasFactory;

    /**
     * The attributes that should mass assignable.
     *
     * @var array
     */
    protected $fillable = ['token'];

    /**
     * Each fcm token belongs to a user.
     *
     * @return \Illuminate\Database\Eloquent\Relationship\BelongsTo
     */
    public function user()
    {
        return $this->belongsTo(User::class);
    }
}

create_fcm_tokens_table_xxxxx.php

class CreateFcmTokensTable extends Migration
{
    /**
     * Run the migrations.
     *
     * @return void
     */
    public function up()
    {
        Schema::create('fcm_tokens', function (Blueprint $table) {
            $table->id();
            $table->bigInteger('user_id');
            $table->string('token');
            $table->timestamps();
        });
    }

    /**
     * Reverse the migrations.
     *
     * @return void
     */
    public function down()
    {
        Schema::dropIfExists('fcm_tokens');
    }
}

Models\User.php

class User extends Model
{
    ...

    /**
     * Each user has one fcmToken.
     *
     * @return \Illuminate\Database\Eloquent\Relationship\HasOne
     */
    public function fcmToken()
    {
        return $this->hasOne(FcmToken::class);
    }

    ...
}

Notifications\AgendaCreated.php

class AgendaCreated extends Notification implements ShouldQueue
{
    use Queueable;

    public $agenda;

    /**
     * Create a new notification instance.
     *
     * @return void
     */
    public function __construct(Agenda $agenda)
    {
        $this->agenda = $agenda;
    }

    /**
     * Get the notification's delivery channels.
     *
     * @param  mixed  $notifiable
     * @return array
     */
    public function via($notifiable)
    {
        return [FcmChannel::class];
    }

    /**
     * Get the fcm representation of the notification.
     *
     * @param  mixed  $notifiable
     * @return \NotificationChannels\Fcm\FcmMessage
     */
    public function toFcm($notifiable)
    {
        /**
         * NOTE REGARDING BACKGROUND NOTIFICATION ISSUE.
         *
         * see: https://github.com/FirebaseExtended/flutterfire/issues/130
         * see: https://github.com/FirebaseExtended/flutterfire/issues/130#issuecomment-594136200
         *
         * When this applied, it creates a `notification` object. This is interferring the
         * background processing on client's devices and make the `_onBackgroundMessage`
         * callback on client's program method not firing.
         *
         * Instead of sending notification from the server to show a notification on user's
         * notification's shade, consider processing it from the client side by making use
         * of the encoded json data sent from the `setData` method.
         *
         * !!DO NOT DO THIS!!
         * return FcmMessage::create()
         *     ->setNotification(ResourcesNotification::create()
         *         ->setTitle('Agenda Invitation')
         *         ->setBody('You\'ve been invited to participate in ' . $author . '\'s agenda.'));
         */
        $trim = Str::words($this->agenda->author->name, 1, '');
        $author = Str::ucfirst($trim);

        $androidConfig = AndroidConfig::create()
            ->setFcmOptions(AndroidFcmOptions::create()->setAnalyticsLabel('analytics'));

        $iosConfig = ApnsConfig::create()
            ->setFcmOptions(ApnsFcmOptions::create()->setAnalyticsLabel('analytics_ios'));

        return FcmMessage::create()
            ->setAndroid($androidConfig)
            ->setApns($iosConfig)
            ->setData([
                'category' => 'agenda',
                'title' => 'Agenda Invitation',
                'body' => 'You\'ve been invited to participate in ' . $author . '\'s agenda.',
                'data' => json_encode($this->agenda),
                'click_action' => 'FLUTTER_NOTIFICATION_CLICK',
            ]);
    }

    /**
     * Get the array representation of the notification.
     *
     * @param  mixed  $notifiable
     * @return array
     */
    public function toArray($notifiable)
    {
        return [
            //
        ];
    }
}