laravel-notification-channels / fcm

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

how to Subscribe token to topic #103

Closed yunoos321 closed 2 years ago

yunoos321 commented 2 years ago

how to Subscribe token to topic add send notification large number of users

I'am using for setTopic

public function toFcm($notifiable)
    {
        return FcmMessage::create()
            ->setData(['type' => $this->screen, 'user_id' => (string)$notifiable->id])
            ->setTopic('promotion')
            ->setNotification(\NotificationChannels\Fcm\Resources\Notification::create()
                ->setTitle($this->title)
                ->setBody($this->messages)
                ->setImage('http://example.com/url-to-image-here.png'))
            ->setAndroid(
                AndroidConfig::create()
                    ->setFcmOptions(AndroidFcmOptions::create()->setAnalyticsLabel('analytics'))
                    ->setNotification(AndroidNotification::create()->setColor('#0A0A0A'))
            )->setApns(
                ApnsConfig::create()
                    ->setFcmOptions(ApnsFcmOptions::create()->setAnalyticsLabel('analytics_ios'))
            );
    }
ankurk91 commented 2 years ago

https://firebase-php.readthedocs.io/en/stable/cloud-messaging.html#topic-management