PHP code example of digitalap / fcmhttpbundle

1. Go to this page and download the library: Download digitalap/fcmhttpbundle library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

digitalap / fcmhttpbundle example snippets



// app/AppKernel.php

// ...
class AppKernel extends Kernel
{
    public function registerBundles()
    {
        $bundles = array(
            // ...

            new DigitalAp\FcmHttpBundle\FcmHttpBundle(),
        );

        // ...
    }

    // ...
}


        //A MESSAGE MAY HAVE A NOTIFICATION OR NO
        $notification = new Notification('Text','Body');
        $notification->enableSound();
        
        //Put that one or more relations_id. Message expects an array as parameter
        //If it is greater than a thousand relations_ids the bundle will send the messages in a thousand
        $message = new Message(array(
            '0'
            '1'
        ));
        
        //A message may not have a notification or a data, but it must have one of the two.
        $message->setNotification($notification);
        
        $guzzle = $this->get('fcm_http.send')->send($message);
        
        // response for server 
        dump(guzzle)
        //Each index of the array returned by the response means a lot of one thousand messages
        dump($guzzle[0]->getBody()->getContents());