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

Laravel Android Priority Error #88

Closed ismatBabirli closed 2 years ago

ismatBabirli commented 3 years ago

When I add setPriority to fcm laravel throw error.

 production.ERROR: syntax error, unexpected 'string' (T_STRING), expecting function (T_FUNCTION) or const (T_CONST) {"userId":1,"exception":"[object] (Symfony\\Component\\Debug\\Exception\\FatalThrowableError(code: 0): syntax error, unexpected 'string' (T_STRING), expecting function (T_FUNCTION) or const (T_CONST) at /var/www/exmaple.com/vendor/spatie/enum/src/Enum.php:31)
[stacktrace]

My code example

 return FcmMessage::create()
            ->setData([
                "content_available" => "true",
                "mutable_content" => "true",
                "faq_id" => (string)$this->faq->id,
                'type' => (string)config('options.notification_type.question.answered'),
                "created_at" => $this->faq->created_at
            ])
            ->setNotification(\NotificationChannels\Fcm\Resources\Notification::create()
                ->setTitle(trans('notifications.doctor_answered_question_title'))
                ->setBody(trans('notifications.doctor_answered_question_body', ["Name" => $this->user->name]))
            )
            ->setAndroid(
                AndroidConfig::create()
                    ->setFcmOptions(AndroidFcmOptions::create()->setAnalyticsLabel('analytics'))
                    ->setNotification(AndroidNotification::create()->setColor('#0A0A0A'))
                    ->setPriority(AndroidMessagePriority::HIGH())
                    ->setData([
                        "content_available" => "true",
                        "mutable_content" => "true",
                    ])
            )->setApns(
                ApnsConfig::create()
                    ->setFcmOptions(ApnsFcmOptions::create()->setAnalyticsLabel('analytics_ios')));
dwightwatson commented 2 years ago

Closing as this is over a year old now with no new info.