PHP code example of cmnty / push-bundle

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

    

cmnty / push-bundle example snippets


public function registerBundles()
{
    $bundles = [
        // ...
        new Cmnty\PushBundle\CmntyPushBundle(),
        // ...
    ];

    return $bundles;
}



use Cmnty\Push\Crypto\AuthenticationSecret;
use Cmnty\Push\Crypto\PublicKey;
use Cmnty\Push\EndPoint;
use Cmnty\Push\Notification;
use Cmnty\Push\Subscription;

$notification = new Notification('Hello', 'Symfony!');
$subscription = new Subscription(
    new Endpoint('...'),
    new PublicKey::createFromBase64UrlEncodedString('...'),
    new AuthenticationSecret::createFromBase64UrlEncodedString('...')
);

$client = $this->get('cmnty_push.client');
$client->pushNotification($notification, $subscription);