我将向应用程序发送推送通知,我也想发送带有如下所示的推送通知的徽章,但是通知徽章无法正常工作,所以请帮助我弄清楚
公共函数addLike(Post $ post) { $ authUser = JWTAuth :: parseToken()-> toUser();
$ authUser-> like($ post);
if ($post->user_id != $authUser->id) {
$user = User::where('id', $post->user_id)->first();
$badgeNotification = $user->unreadNotifications->count();
// dd($badgeNotification);
$push = new PushNotification('apn');
$push->setMessage([
'aps' => [
'alert' => $authUser->username.' like your post "'.$post->post_content.'"',
'sound' => 'default',
'badge' => $badgeNotification
],
'extraPayLoad' => [
'custom' => 'My custom data',
]
]);
$push->setDevicesToken($user->deviceToken);
$push->send();
$feedback = $push->getFeedback();
$user->notify(new LikePost($authUser, $post));
}