This repository was archived by the owner on Dec 25, 2018. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathexample.php
More file actions
46 lines (33 loc) · 1.22 KB
/
example.php
File metadata and controls
46 lines (33 loc) · 1.22 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
<?php
// Include PHPush
require_once 'vendor/autoload.php';
use PHPush\PHPush;
// Setting environment
PHPush::Environment(PHPush::ENVIRONMENT_PRODUCTION);
// Adding Android key
PHPush::Provider(\PHPush\Provider::PROVIDER_ANDROID)->setAccessKey('test');
// Adding iOS certificate
PHPush::Provider(\PHPush\Provider::PROVIDER_IOS)->setCertificate('ck.pem');
// Creating new queue
$queue = PHPush::Queue();
// Adding some devices
$queue->add(new \PHPush\providers\android\Device('android_registration_id'));
$queue->add(new \PHPush\providers\ios\Device('ios_device_token'));
// Setting message
$queue->message('Hello World!');
// Send message. You can provide custom fields to this method.
// Also you can pass sound and passphrase with this custom fields
$queue->send(array(
'custom' => 'field',
'sound' => 'popup.aif',
'passphase' => 'phpush',
));
// Creating another queue
$another_queue = PHPush::Queue();
// Adding only one device
$another_queue->add(new \PHPush\providers\ios\Device('another_or_the_same_ios_device_token'));
// Setting message
$another_queue->message('Hello World! I\'m second queue!');
// This will not open a connection to APNS server again.
// It will use the old connection
$another_queue->send();