I have integrated FCM (Firebase Cloud Messaging) notification with my laravel project.
I have added the method routeNotificationForFcm
in the User
model.
The notification system is working fine when the firebase device token is specified directly in the method, but not working when the token is accessed from database.
The working code added is given below.
public function routeNotificationForFcm()
{
return ['dJQqgKlETpqCB3uxHtfUbL:APA91bFdrcXZMNH0iMjkXMoop_b_nI3xF92DU0P1nrHVQsTDK4w-OH5QR6BsnWIV-wSxSV7avzuBmLVizNyrRcKfAQz6H66JEP9rWKUeIi7m7wEZwRiuW_WdCW_LaZajdFZlxfCUonCL'];
}
The code that is not working is as follows (database query)
public function routeNotificationForFcm()
{
return $this->from('fcm_tokens')->where('user_id', $user->id)->pluck('device_token');
}
The error message showing is The registration token is not a valid FCM registration token