|
|
@@ -22,6 +22,10 @@ class PushNotificationService
|
|
|
*/
|
|
|
public function sendToUser(User $user, BasePushNotification $notification): void
|
|
|
{
|
|
|
+ if (! $user->push_notifications_enabled) {
|
|
|
+ return;
|
|
|
+ }
|
|
|
+
|
|
|
$tokens = DeviceToken::where('user_id', $user->id)
|
|
|
->where('app_type', $notification->target()->value)
|
|
|
->where('active', true)
|
|
|
@@ -33,10 +37,15 @@ class PushNotificationService
|
|
|
}
|
|
|
|
|
|
$message = CloudMessage::new()
|
|
|
- ->withNotification(Notification::create($notification->title(), $notification->body()))
|
|
|
+ ->withNotification(
|
|
|
+ Notification::create(
|
|
|
+ $notification->title(),
|
|
|
+ $notification->body()
|
|
|
+ )
|
|
|
+ )
|
|
|
->withAndroidConfig(AndroidConfig::fromArray([
|
|
|
'notification' => ['channel_id' => 'diaria'],
|
|
|
- 'priority' => 'high',
|
|
|
+ 'priority' => 'high',
|
|
|
]));
|
|
|
|
|
|
$report = $this->messaging->sendMulticast($message, $tokens);
|