Edujugon / PushNotification

PHP and Laravel Package to send push notifications to Android and IOS devices.
MIT License
478 stars 159 forks source link

Call to undefined method - ERROR #34

Closed vitormicillo closed 6 years ago

vitormicillo commented 6 years ago

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

Edujugon commented 6 years ago

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;

vitormicillo commented 6 years ago

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.

Edujugon commented 6 years ago

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

after sending the mail do this:

dd($push->getFeedback());
vitormicillo commented 6 years ago
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

Edujugon commented 6 years ago

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

vitormicillo commented 6 years ago

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