PHP code example of juliangut / tify

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

    

juliangut / tify example snippets




new \Jgut\Tify\Receiver\ApnsReceiver('device_token');
new \Jgut\Tify\Receiver\GcmReceiver('device_token');

$apnsService = new \Jgut\Tify\Service\ApnsService(['certificate' => 'path_to_certificate.pem']);
$gcmService = new \Jgut\Tify\Service\GcmService(['api_key' => 'google_api_key']);

use Jgut\Tify\Adapter\Apns\ApnsAdapter;
use Jgut\Tify\Adapter\Gcm\GcmAdapter;
use Jgut\Tify\Message;
use Jgut\Tify\Notification;
use Jgut\Tify\Receiver\ApnsReceiver;
use Jgut\Tify\Receiver\GcmReceiver;
use Jgut\Tify\Service;

$adapters = [
    new GcmAdapter(['api_key' => '00000']),
    new ApnsAdapter(['certificate' => 'path_to_certificate']),
];

$message = new Message([
    'title' => 'title',
    'body' => 'body',
]);

$receivers = [
    new GcmReceiver('aaaaaaaaaaa'),
    new GcmReceiver('bbbbbbbbbbb'),
    new ApnsReceiver('ccccccccccc'),
    new ApnsReceiver('ddddddddddd'),
];

$service = new Service($adapters, new Notification($message, $receivers));

$results = $service->push();

use Jgut\Tify\Adapter\Gcm\GcmAdapter;
use Jgut\Tify\Message;
use Jgut\Tify\Notification;
use Jgut\Tify\Receiver\GcmReceiver;
use Jgut\Tify\Service;

$adapters = [
    new GcmAdapter(['api_key' => '00000']),
    new GcmAdapter(['api_key' => '11111']),
];

$service = new Service($adapters);

$service->addNotification(new Notification(
    new Message([
        'title' => 'title_one',
        'body' => 'body_one',
    ]),
    [
        new GcmReceiver('aaaaaaaaaaa'),
        new GcmReceiver('bbbbbbbbbbb'),
    ]
));

$service->addNotification(new Notification(
    new Message([
        'title' => 'title_two',
        'body' => 'body_two',
    ]),
    [
        new GcmReceiver('xxxxxxxxxxx'),
        new GcmReceiver('zzzzzzzzzzz'),
    ]
));

$results = $service->push();

use Jgut\Tify\Adapter\Gcm\ApnsAdapter;
use Jgut\Tify\Service;

$adapters = [
    new ApnsAdapter(['certificate' => 'path_to_certificate_one']),
    new ApnsAdapter(['certificate' => 'path_to_certificate_two']),
];

$service = new Service($adapters);

$results = $service->feedback();