Browse Source

fix push notification

Gustavo Zanatta 1 tuần trước cách đây
mục cha
commit
b1b0ba4d62
1 tập tin đã thay đổi với 7 bổ sung3 xóa
  1. 7 3
      app/Services/PushNotificationService.php

+ 7 - 3
app/Services/PushNotificationService.php

@@ -8,6 +8,7 @@ use App\Models\User;
 use App\Notifications\Push\BasePushNotification;
 use Illuminate\Support\Collection;
 use Kreait\Firebase\Contract\Messaging;
+use Kreait\Firebase\Messaging\AndroidConfig;
 use Kreait\Firebase\Messaging\CloudMessage;
 use Kreait\Firebase\Messaging\Notification;
 use Throwable;
@@ -32,9 +33,12 @@ class PushNotificationService
             return;
         }
 
-        $message = CloudMessage::new()->withNotification(
-            Notification::create($notification->title(), $notification->body())
-        );
+        $message = CloudMessage::new()
+            ->withNotification(Notification::create($notification->title(), $notification->body()))
+            ->withAndroidConfig(AndroidConfig::fromArray([
+                'notification' => ['channel_id' => 'default'],
+                'priority' => 'high',
+            ]));
 
         $report = $this->messaging->sendMulticast($message, $tokens);