forked from immobiliare/ApnsPHP
-
Notifications
You must be signed in to change notification settings - Fork 10
/
Copy pathget_payload.php
44 lines (32 loc) · 1.18 KB
/
get_payload.php
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
<?php
/**
* Get the payload
*
* phpcs:disable PSR1.Files.SideEffects.FoundWithSymbols, PSR1.Classes.ClassDeclaration.MissingNamespace
*
* SPDX-FileCopyrightText: Copyright 2024 Move Agency Group B.V., Zwolle, The Netherlands
* SPDX-License-Identifier: BSD-3-Clause
*/
// Using Composer autoload all classes are loaded on-demand
require_once 'vendor/autoload.php';
$type = $argv[1] ?? 'message';
// Instantiate a new Message with a single recipient
$message = match ($type) {
'message' => new \ApnsPHP\Message(),
};
// Set a custom identifier. To get back this identifier use the getCustomIdentifier() method
// over a ApnsPHP_Message object retrieved with the getErrors() message.
$message->setCustomIdentifier('7530A828-E58E-433E-A38F-D8042208CF96');
// Set badge icon to "3"
$message->setBadge(3);
// Set a simple welcome text
$message->setText('Hello APNs-enabled device!');
// Play the default sound
$message->setSound();
// Set a custom property
$message->setCustomProperty('acme2', ['bang', 'whiz']);
// Set another custom property
$message->setCustomProperty('acme3', ['bing', 'bong']);
// Set the expiry value to 30 seconds
$message->setExpiry(30);
echo $message->getPayload();