feat: add persistent mobile notifications
This commit is contained in:
@@ -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()),
|
||||
],
|
||||
];
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user