Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- require 'vendor/autoload.php';
- use Google\Cloud\Core\ServiceBuilder;
- // Authenticate with Google Cloud
- $cloud = new ServiceBuilder([
- 'keyFilePath' => 'path-to-your-service-account-json-file',
- 'projectId' => 'your-project-id'
- ]);
- // Get an instance of the Firebase Cloud Messaging client
- $messaging = $cloud->messaging();
- // Create a message
- $message = [
- 'notification' => [
- 'title' => 'Notification title',
- 'body' => 'Notification body'
- ],
- 'android' => [
- 'ttl' => '3600s',
- 'priority' => 'normal',
- 'notification' => [
- 'icon' => 'stock_ticker_update',
- 'color' => '#f45342'
- ]
- ],
- 'token' => 'device-registration-token'
- ];
- // Send the message
- $response = $messaging->send($message);
- echo $response;
- ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement