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

Fix null token from routeNotificationFor #75

Closed write-programmer closed 2 years ago

write-programmer commented 3 years ago

The toFcm method is never called when using the Notification::route(FcmChannel::class, $user->notification_token)->notify(new ExampleNotify($object)); method. We don't get an error message.

dwightwatson commented 2 years ago

It's not clear to me why these changes would have an impact when using an anonymous notifiable. All it does it make an assumption that the notifiable would have the fcm_token property set which seems specific to your app.

It sounds like perhaps the via method of your notification isn't returning FcmChannel. You can inspect $notifiable in the via method and make decisions based upon whether it is an instance of AnonymousNotifiable or not.