Closed rdp77 closed 1 year ago
Push Notification is not working when app is closed, is there something wrong with my code? because it doesn't work when the app is closed in recent apps.
public function toPushNotification($notifiable): PusherMessage { $interest = 'user-ali.' . $notifiable->id; $fcmPayload = [ 'notification' => [ 'title' => $this->adminNews->title, 'body' => $this->adminNews->notes, ], 'data' => [ 'click_action' => $this->adminNews->onclick_url, ], ]; $apnsPayload = [ 'aps' => [ 'alert' => [ 'title' => $this->adminNews->title, 'body' => $this->adminNews->notes, ], 'badge' => 1, 'sound' => '', ], ]; $message = PusherMessage::create() ->title($this->adminNews->title) ->body($this->adminNews->notes) ->icon(public_path('svg/symbol.svg')) ->link($this->adminNews->onclick_url) ->setOption('interests', [$interest]); $messageAndroid = $message->setOption('fcm', $fcmPayload); return PusherMessage::create() ->iOS() ->badge(1) ->withAndroid($messageAndroid) ->withWeb($message) ->sound('') ->setOption('interests', [$interest]) ->setOption('apns', $apnsPayload); }
This is solved based on this reference https://stackoverflow.com/questions/74460522/how-to-push-laravel-notification-via-pusher-beams-and-how-can-i-add-interests
Push Notification is not working when app is closed, is there something wrong with my code? because it doesn't work when the app is closed in recent apps.