feat: add persistent mobile notifications
This commit is contained in:
@@ -4,25 +4,21 @@ namespace App\Notifications;
|
||||
|
||||
use App\Models\PostReviews;
|
||||
use App\Services\MobileDeepLink;
|
||||
use Illuminate\Bus\Queueable;
|
||||
use Illuminate\Notifications\Notification;
|
||||
use Illuminate\Support\Str;
|
||||
|
||||
class MealPostCommentedNotification extends Notification
|
||||
class MealPostCommentedNotification extends MobileNotification
|
||||
{
|
||||
use Queueable;
|
||||
|
||||
public function __construct(private readonly PostReviews $postReview) {}
|
||||
|
||||
/**
|
||||
* @return array<int, string>
|
||||
*/
|
||||
public function via(object $notifiable): array
|
||||
public function __construct(private readonly PostReviews $postReview)
|
||||
{
|
||||
return ['expo'];
|
||||
parent::__construct();
|
||||
}
|
||||
|
||||
public function toExpoPush(object $notifiable): array
|
||||
protected function category(): string
|
||||
{
|
||||
return self::CATEGORY_SOCIAL;
|
||||
}
|
||||
|
||||
protected function payload(object $notifiable): array
|
||||
{
|
||||
$this->postReview->loadMissing(
|
||||
'mealPost:id,title,user_id',
|
||||
@@ -35,16 +31,13 @@ class MealPostCommentedNotification extends Notification
|
||||
$commenterName = $this->postReview->user?->name ?: __('api.notifications.someone');
|
||||
|
||||
return [
|
||||
'type' => 'meal_commented',
|
||||
'title' => __('api.notifications.meal_post_commented_title'),
|
||||
'body' => __('api.notifications.meal_post_commented_body', [
|
||||
'meal' => $mealTitle,
|
||||
'name' => $commenterName,
|
||||
]),
|
||||
'sound' => 'default',
|
||||
'channelId' => 'default',
|
||||
'data' => [
|
||||
'url' => MobileDeepLink::to("meals/{$mealPostId}"),
|
||||
],
|
||||
'url' => MobileDeepLink::to("meals/{$mealPostId}"),
|
||||
];
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user