feat: add persistent mobile notifications
CI / 🧪 Tests Laravel (push) Successful in 2m7s
CI / 🐳 Build & Push Image (push) Successful in 42s

This commit is contained in:
2026-08-11 16:46:05 +02:00
parent bd1b4bba20
commit df4f523089
24 changed files with 822 additions and 75 deletions
@@ -3,14 +3,10 @@
namespace App\Notifications;
use App\Services\MobileDeepLink;
use Illuminate\Bus\Queueable;
use Illuminate\Notifications\Notification;
use Illuminate\Support\Arr;
class EngagementReminderNotification extends Notification
class EngagementReminderNotification extends MobileNotification
{
use Queueable;
private const MESSAGE_KEYS = [
'publish_meal',
'meal_photo',
@@ -19,7 +15,10 @@ class EngagementReminderNotification extends Notification
'workout_checkin',
];
public function __construct(private readonly string $messageKey) {}
public function __construct(private readonly string $messageKey)
{
parent::__construct();
}
public static function randomMessageKey(): string
{
@@ -34,38 +33,22 @@ class EngagementReminderNotification extends Notification
return self::MESSAGE_KEYS;
}
/**
* Get the notification's delivery channels.
*
* @return array<int, string>
*/
public function via(object $notifiable): array
protected function category(): string
{
return ['expo'];
return self::CATEGORY_ENGAGEMENT;
}
/**
* @return array{
* title: string,
* body: string,
* sound: string,
* channelId: string,
* data: array{type: string, message_key: string, url: string}
* }
*/
public function toExpoPush(object $notifiable): array
protected function payload(object $notifiable): array
{
$message = $this->message();
return [
'type' => 'engagement_reminder',
'title' => $message['title'],
'body' => $message['body'],
'sound' => 'default',
'channelId' => 'default',
'url' => MobileDeepLink::to($this->path()),
'data' => [
'type' => 'engagement_reminder',
'message_key' => $this->messageKey,
'url' => MobileDeepLink::to($this->path()),
],
];
}