-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathapns-token.php
More file actions
34 lines (26 loc) · 771 Bytes
/
Copy pathapns-token.php
File metadata and controls
34 lines (26 loc) · 771 Bytes
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
<?php
require_once dirname(__DIR__) . '/vendor/autoload.php';
use Sunaoka\PushNotifications\Drivers\APNs;
use Sunaoka\PushNotifications\Pusher;
$deviceToken = 'Device token';
$payload = [
'aps' => [
'alert' => [
'title' => 'Game Request',
'body' => 'Bob wants to play poker',
],
],
];
$options = new APNs\Token\Option();
$options->payload = $payload;
$options->authKey = '/path/to/key.p8';
$options->keyId = 'ABCDE12345';
$options->teamId = 'ABCDE12345';
$options->topic = 'com.example.app';
$driver = new APNs\Token($options);
$pusher = new Pusher();
$feedback = $pusher->to($deviceToken)->send($driver);
$result = $feedback->isSuccess($deviceToken);
if (! $result) {
echo $feedback->failure($deviceToken);
}