PHP code example of wrep / notificato-symfony

1. Go to this page and download the library: Download wrep/notificato-symfony 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/ */

    

wrep / notificato-symfony example snippets


public function registerBundles()
{
    $bundles = array(
        ...
        new Wrep\Bundle\NotificatoBundle\NotificatoBundle(),
        ...
    );
}

class PushController extends Controller
{
    public function indexAction()
    {
        // First we get a Notificato instance
        $notificato = $this->get('notificato');

        // Now let us get a fresh message from Notificato
        //  This message will be send to device with pushtoken 'fffff...'
        //  it will automaticly be associated with the default certificate
        $message = $notificato->createMessage('ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff');

        // Let's set App icon badge with this push to 1
        $message->setBadge(1);

        // The message is ready, let's send it!
        //  Be aware that this method is blocking and on failure Notificato will retry a few times
        $messageEnvelope = $notificato->send($message);

        // The returned envelope contains usefull information about how many retries where needed and if sending succeeded
        echo $messageEnvelope->getFinalStatusDescription();

        // Of course you should return a nice Response here!
    }
}