Giter Site home page Giter Site logo

FCM/GCM Usage about pushnotification HOT 5 CLOSED

edujugon avatar edujugon commented on August 14, 2024
FCM/GCM Usage

from pushnotification.

Comments (5)

zanechua avatar zanechua commented on August 14, 2024 1

ah I see. Thanks @Edujugon !

I'll stick with the Pure Facade Method. Cheers!

from pushnotification.

Edujugon avatar Edujugon commented on August 14, 2024

@zanechua

Notice that the above code is not using the facade so kindly confirm your use statement at the head of your class is something like this:

use Edujugon\PushNotification\PushNotification;

And no like this:

use Edujugon\PushNotification\Facades\PushNotification;

from pushnotification.

Edujugon avatar Edujugon commented on August 14, 2024

@zanechua

If you prefer using Facade, you could do something like this:

PushNotification::setService('fcm')
                            ->setMessage([
                                 'notification' => [
                                         'title'=>'This is the title',
                                         'body'=>'This is the message',
                                         'sound' => 'default'
                                         ],
                                 'data' => [
                                         'extraPayLoad1' => 'value1',
                                         'extraPayLoad2' => 'value2'
                                         ]
                                 ])
                            ->setApiKey('Server-API-Key')
                            ->setDevicesToken(['deviceToken1','deviceToken2','deviceToken3'...])
                            ->send()
                            ->getFeedback();

In that case, yeah, you should use the follow statement:
use Edujugon\PushNotification\Facades\PushNotification;

from pushnotification.

zanechua avatar zanechua commented on August 14, 2024

ah. It needs to import the class directly?

Usually when i import packages, I usually just do

use PushNotification;

Does this not work here?

from pushnotification.

Edujugon avatar Edujugon commented on August 14, 2024

If you want to use Facade, you should set this statement:

use Edujugon\PushNotification\Facades\PushNotification;

As you already know, Facade provides a "static" interface to the class that is available in the application's service container.

Otherwise, if you prefer no to use Facade, then you have to set the below statement:

use Edujugon\PushNotification\PushNotification;

Let me know if the change made it works

from pushnotification.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.