kreait / laravel-firebase

A Laravel package for the Firebase PHP Admin SDK

Home Page:https://github.com/kreait/firebase-php

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

The Created CFMs don't listed on the firebase console?

nakarimi opened this issue · comments

I sent the request to create notification with Firebase, it return success, but actually I can't receive the notification on the phone, also the notifications don't list on the table of notification on the console panel.

My code the the result that returns on success.

        $path = base_path('config/fooddelivery-firebase.json');
        $title = 'My Notification Title';
        $body = 'My Notification Body';
        $notification = Notification::create($title, $body);
        $factory = (new Factory)->withServiceAccount($path);
        $messaging = $factory->createMessaging();

        $message = CloudMessage::withTarget('topic', 'AsanFood')
            ->withNotification($notification);
        try {
            return $messaging->send($message);

            // Result:
            // {
            //     "name": "projects/fooddelivery-cc39b/messages/757376859954639368"
            // }
            
        } catch (InvalidMessage $e) {
            print_r($e->errors());
        }
        die;

Should it be listed on the table, or just should receive it on the phone? what is wrong with this?
image

Your message looks fine but I have to add that valid messages to topics always return success - if no device is subscribed to that topic, no message will be delivered.

You can check which topics a device is subscribed to with the AppInstance management API: https://firebase-php.readthedocs.io/en/5.x/cloud-messaging.html#app-instance-management

https://firebase.google.com/docs/reference/android/com/google/firebase/messaging/FirebaseMessaging#getToken()

Please note that only messages sent from the console will show up in the console - messages sent from an SDK will not.