kreait / laravel-firebase

A Laravel package for the Firebase PHP Admin SDK
https://github.com/kreait/firebase-php
MIT License
992 stars 163 forks source link

may any one help my the notification didn't work :" #140

Closed mohamedhussieen closed 2 years ago

mohamedhussieen commented 2 years ago

public function sendNotificationToDevices($textMessage, $data, $token) { try { $messaging = app('firebase.messaging'); $message = CloudMessage::withTarget('token', $token) ->withNotification(Notification::create($data, $textMessage)) ->withData($data); $messaging->send($message); return true; } catch (\Throwable $th) { return $th->getMessage(); } }

this is my trait and i use this function in function on my controller 
the function return success but dont reach any thing on my phone 
i test it on firebase sender test with my token and it work thier 
jeromegamez commented 2 years ago

If the SDK doesn't report any errors and your method returns successfully (= no exception has been thrown), it means that Firebase has received the message, so the work of the PHP SDK is done, and there's nothing it can do going further.

I don't know what "Firebase sender test" is, but it has been often reported by users that sending messages is delayed or doesn't work at all. If the message doesn't arrive at its destination even with a delay, please open an issue directly with Firebase.

PS: In the future, please create just one issue, and give it a short descriptive title like "FCM messages don't arrive at target". Please also care for the formatting of the issue description to make it easier to read - GitHub provides Markdown tools for that.