Edujugon / PushNotification

PHP and Laravel Package to send push notifications to Android and IOS devices.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Call to undefined method - ERROR

vitormicillo opened this issue · comments

Hi Edu, great job.
I have a small problem and I can not solve.
The error message is:
Call to undefined method Edujugon\PushNotification\Facades\PushNotification::setMessage()

My Cod to try is
$push = new PushNotification('fcm'); $push->setMessage(['body'=>'This is the message','title'=>'This is the title']); $push->setDevicesToken(['ehsOBEniA6E:APA91bEogPTT0CiRZmsiI8s7CmvR-QybIgt1rD0Kark0K-L-_zllVmBsuC-JOLgyvnunqVSghKPJraE0A4MQ7d3BAA9P2oalhWyNZzBqoyw-l0jUV6M0sXKN5j1p4XpVzu3DFo--ZP4B']); $push->send();

app.conf
My Service Provider:
Edujugon\PushNotification\Providers\PushNotificationServiceProvider::class,
and
'PushNotification' => Edujugon\PushNotification\PushNotification::class,

pushnotification.php
'fcm' => [
'priority' => 'normal',
'dry_run' => false,
'apiKey' => 'XXXXXXXXXXXXXXXXXXXXXXXXXXXXXX,
]

I really do not know how to solve

Hi Victor,

I think the issue is the use statement you're using.
Have a look at the top of you file, and in the use statement of package class, make sure it's not the Facade but it's the main class itself.

So it should look like this:
use Edujugon\PushNotification\PushNotification;

Hi Edu thanks,
apparently it seems that the problem has been solved, but the push messages are not working, I set the devicetoken and api_key based on the data from the firebase.

Try to dd the feedback in order to see what's happening.

after sending the mail do this:

dd($push->getFeedback());
Client error: POST https://fcm.googleapis.com/fcm/send resulted in a 401 Unauthorized response:\n
    <HTML>\n
    <HEAD>\n
    <TITLE>Unauthorized</TITLE>\n
    </HEAD>\n
    <BODY BGCOLOR="#FFFFFF" TEXT="#000000">\n
    <H1>Unauthorized</H1>\n
    <H2>Erro (truncated...)\n
    """
}

Strange I'm using FCM non GCM

It seems you are unauthorized.
Make sure you set the correct API key. This link may be useful or this one

Thankyou Edu
Problem solved, good it gets recorded here that the correct tab to get the KEY API should be cloudmessaging.