Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- $serviceAccount = ServiceAccount::fromJsonFile(__DIR__.'/google.json');
- $firebase = (new Factory)
- ->withServiceAccount($serviceAccount)
- // The following line is optional if the project id in your credentials file
- // is identical to the subdomain of your Firebase project. If you need it,
- // make sure to replace the URL with the URL of your project.
- //->withDatabaseUri('https://my-project.firebaseio.com')
- ->create();
- $messaging = $firebase->getMessaging();
- $deviceToken = 'token';
- $notification = Notification::create("test", "body");
- $data = [
- 'first_key' => 'First Value',
- 'second_key' => 'Second Value',
- ];
- $message = CloudMessage::withTarget('token', $deviceToken)
- ->withNotification($notification) // optional
- ->withData($data);
- // error here
- // 404 Client error: `POST https://fcm.googleapis.com/v1/projects/projectid/messages:send` resulted in a `404 Not Found
- $messaging->send($message);
Add Comment
Please, Sign In to add comment