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

Stopped Working All together #131

Closed doubleprincez closed 1 year ago

doubleprincez commented 1 year ago

I have been using FCM for testing for some time before pushing out...... Just don't know why it stopped working altogether for like a month now. Had to change the key and try again but still isn't working.... Has there been a change in the service account key that is needed for connecting? because I guess that's usually where my challenge lies. Please I need to understand which JSON file is now required for usage. Fullscreen capture 132023 121311 AM bmp

dwightwatson commented 1 year ago

The last tagged release was November 2022, I presume you're still running that, so we probably haven't shipped something that broke. Can you debug further on your end to see what is going on? Remember that this channel is a thin wrapper around kreait/laravel-firebase so you might need to dig a little deeper.

You're also welcome to give our develop branch a go and see if that makes any difference for you.

doubleprincez commented 1 year ago

I was still able to test last month till last 2 weeks when I revisited the project and I wasn't getting any response Fullscreen capture 132023 84238 AM bmp

doubleprincez commented 1 year ago

Testing Data

$user= User::find(1);
  $notify = ['title'=>'Testing', 'body'=>'You are working right?','data'=>['click_action'=>'dashboard','url'=>url('dashboard')]]; 
$user->notify(new InAppNotification($notify );
class InAppNotification extends Notification
{
    use Queueable;

    public $data;
    protected $site_logo;

    /**
     * Create a new notification instance.
     *
     * @return void
     */
    public function __construct($data)
    {
        $this->data = $data;
        $this->site_logo = asset('storage/page/law-light-logo.png');
    }

    /**
     * Get the notification's delivery channels.
     *
     * @param mixed $notifiable
     * @return array
     */

    public function via($notifiable)
    {
        return [FcmChannel::class];
    }

    public function toFcm($notifiable)
    {
        return FcmMessage::create()
            ->setData($this->data['data'] ?? [])
            ->setNotification(\NotificationChannels\Fcm\Resources\Notification::create()
                ->setTitle($this->data['title'] ?? '')
                ->setBody($this->data['body'] ?? '')
                ->setImage($this->data['image'] ?? $this->site_logo))
            ->setAndroid(
                AndroidConfig::create()
                    ->setFcmOptions(AndroidFcmOptions::create()->setAnalyticsLabel('analytics'))
                    ->setNotification(AndroidNotification::create()->setColor(config('laravelpwa.manifest.background_color')))
            )
            ->setApns(
                ApnsConfig::create()
                    ->setFcmOptions(ApnsFcmOptions::create()->setAnalyticsLabel('analytics_ios')));
    }

}
doubleprincez commented 1 year ago

I mistakenly configured its restriction in my google cloud thereby preventing http:// requests. I just got to know that the cloud API configuration also can limit its usage while testing when using the same API