PHP code example of simplon / helium

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

    

simplon / helium example snippets


// API keys
$key = '12345';
$secret = '12345';

// device token entity
$deviceToken = \Simplon\Helium\DeviceToken::init()->setToken('111111222233344455AAABBBCCCDDDD');

// remote register device token
$response = \Simplon\Helium\Air::init()
     ->setApplicationKey($key)
     ->setApplicationSecret($secret)
     ->registerDeviceToken($deviceToken);

// API keys
$key = '12345';
$secret = '12345';
$master = '12345';

// push notification entity
$pushNotifications = array();
$pushNotifications[] = \Simplon\Helium\PushNotification::init()
     ->setDeviceTokens(array('111111222233344455AAABBBCCCDDDD'))
     ->setAlert("Howdy!")
     ->getData();

// send push to UA's API
$response = \Simplon\Helium\Air::init()
     ->setApplicationKey($key)
     ->setApplicationSecret($secret)
     ->setApplicationMasterSecret($master)
     ->setNotifications($pushNotifications)
     ->sendSinglePush();

$deviceToken = \Simplon\Helium\DeviceToken::init()
     ->setToken('111111222233344455AAABBBCCCDDDD')
     ->setAlias('USER_ID')
     ->setTags(array('tag1', 'tag2'))
     ->setBadge(5)
     ->setQuietTime('22:00', '8:00')
     ->setTimezone('Europe/Berlin');

// API keys
$key = '12345';
$secret = '12345';
$master = '12345';

// push notification entity
$pushNotifications = array();
$pushNotifications[] = \Simplon\Helium\PushNotification::init()
     ->setAliases(array('USER_ID'))
     ->setAlert("Howdy again!")
     ->setMetadata('type', 'fresh')
     ->setMetadata('smile', 'on')
     ->getData();

// send push to UA's API
$response = \Simplon\Helium\Air::init()
     ->setApplicationKey($key)
     ->setApplicationSecret($secret)
     ->setApplicationMasterSecret($master)
     ->setNotifications($pushNotifications)
     ->sendSinglePush();