PHP code example of jp / firebase-notification-bundle

1. Go to this page and download the library: Download jp/firebase-notification-bundle 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/ */

    

jp / firebase-notification-bundle example snippets

 bash
$ php composer.phar update "jp/firebase-notification-Bundle"
 php

// app/AppKernel.php

public function registerBundles()
{
    $bundles = array(
        // ...
        new JP\FirebaseNotificationBundle\JPFirebaseNotificationBundle()
    );
}
 php

        $fcm = $this->get('firebase_fcm_client');
 php
 
    $fcm = $this->get('firebase_fcm_client');
    $fcm->createMessage(array(
        'to' => 'XXXXXXXX',
        'title' => 'New message',
        'body' => 'Hello World!',
        'badge' => 1,
        'data' => array(
            'action' => "new_message"
        )
    ));
    $data = $fcm->sendMessage();
 php
 
    $fcm = $this->get('firebase_fcm_client');
    $fcm->createMessage(array(
        'topic' => '/topics/TOPIC_NAME',
        'title' => 'New message',
        'body' => 'Hello World!',
        'badge' => 1,
        'data' => array(
            'action' => "new_message"
        )
    ));
    $data = $fcm->sendMessage();