laravel-notification-channels / fcm

Firebase Cloud Messaging (FCM) notifications channel for Laravel
https://laravel-notification-channels.com/
MIT License
495 stars 127 forks source link

iOS not receiving notification #156

Closed seunsekoni closed 1 year ago

seunsekoni commented 1 year ago

Hi there. Good job with what was done with this package. It's been working fine for me. However, we recently built an iOS mobile app and iOS devices do not receive notification while trying to use this package. I don't want to have to stop using the package. I might be doing something wrong.

Version: 2.7 What was done

Here's the snippet...

public function toFcm($notifiable)
    {
        $title = $this->title;
        $message = $this->message;
        return FcmMessage::create()
            ->setData([
                'title' => $title,
                'body' => $message?->content,
                'image' => config('firebase.icon_url'),
                'conversation_id' => $message->conversation->id
            ])
            ->setAndroid(
                AndroidConfig::create()
                    ->setFcmOptions(AndroidFcmOptions::create()->setAnalyticsLabel('analytics'))
                    ->setData([
                        'title' => $title,
                        'body' => $message?->content,
                        'conversation_id' => $message->conversation?->id
                    ])
                ->setNotification(
                    AndroidNotification::create()
                        ->setColor('#0A0A0A')
                        ->setTitle($title)
                        ->setBody($message?->content)
                )
                ->setPriority(AndroidMessagePriority::HIGH())
            )->setApns(
                ApnsConfig::create()
                    ->setPayload([
                        'title' => $title,
                        'body' => $message?->content,
                        'conversation_id' => $message->conversation?->id
                    ])
                    ->setFcmOptions(
                        ApnsFcmOptions::create()
                            ->setAnalyticsLabel('analytics_ios')
                    )
            );
    }
dwightwatson commented 1 year ago

Please debug further. See if you can get it working directly with the Firebase package we use under the hood. You may be able to narrow down where the error is occurring.

seunsekoni commented 1 year ago

Oh... I checked with firebase test notification. Notification drops while sending it directly from firebase. However, using the package doesn't make the notification drop on ios devices.