Luego de indagar en diferentes repositorios y sitios webs al final dimos con la resolución que te mostraremos pronto.
Ejemplo: notificaciones de mensajería en la nube de laravel firebase
// Install this package
composer require laravel-notification-channels/fcm:~2.0// Create a notification for user and add the following codeclassAccountActivatedextendsNotificationpublicfunctionvia($notifiable)return[FcmChannel::class];publicfunctiontoFcm($notifiable)returnFcmMessage::create()->setData(['data1'=>'value','data2'=>'value2'])->setNotification(NotificationChannelsFcmResourcesNotification::create()->setTitle('Account Activated')->setBody('Your account has been activated.')->setImage('http://example.com/url-to-image-here.png'))->setAndroid(AndroidConfig::create()->setFcmOptions(AndroidFcmOptions::create()->setAnalyticsLabel('analytics'))->setNotification(AndroidNotification::create()->setColor('#0A0A0A')))->setApns(ApnsConfig::create()->setFcmOptions(ApnsFcmOptions::create()->setAnalyticsLabel('analytics_ios')));// Add Notifiable trait to user class// Add Method routeNotificationForFcm to return save token from firebase cloud messaging in database classUserextendsAuthenticatableuseNotifiable;/**
* Specifies the user's FCM token
*
* @returnstring
*/publicfunctionrouteNotificationForFcm()return$this->fcm_token;// Fire the notification to test it$user->notify(newAccountActivated);
¡Haz clic para puntuar esta entrada!
(Votos: 0 Promedio: 0)