forked from immobiliare/ApnsPHP
-
Notifications
You must be signed in to change notification settings - Fork 10
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
411c308
commit 1c73c22
Showing
4 changed files
with
144 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
# SPDX-FileCopyrightText: Copyright 2021 M2mobi B.V., Amsterdam, The Netherlands | ||
# SPDX-FileCopyrightText: Copyright 2022 Move Agency Group B.V., Zwolle, The Netherlands | ||
# SPDX-License-Identifier: CC0-1.0 | ||
|
||
name: Integration Tests | ||
on: [push, pull_request] | ||
|
||
jobs: | ||
phpunit: | ||
runs-on: ubuntu-latest | ||
continue-on-error: ${{ matrix.experimental }} | ||
name: "PHP-${{ matrix.php-versions }}: Integration" | ||
strategy: | ||
matrix: | ||
php-versions: ['8.3'] | ||
experimental: [false] | ||
include: | ||
- php-versions: 8.4 | ||
experimental: true | ||
steps: | ||
- name: Checkout | ||
uses: actions/checkout@v3 | ||
|
||
- name: Setup PHP | ||
uses: shivammathur/setup-php@v2 | ||
with: | ||
php-version: ${{ matrix.php-versions }} | ||
extensions: uopz | ||
tools: phpunit:9.5.x | ||
|
||
- name: Setup problem matchers for PHP | ||
run: echo "::add-matcher::${{ runner.tool_cache }}/php.json" | ||
|
||
- name: Setup problem matchers for PHPUnit | ||
run: echo "::add-matcher::${{ runner.tool_cache }}/phpunit.json" | ||
|
||
- name: Install dependencies | ||
run: composer update | ||
|
||
- name: Install JSONSchema | ||
run: pipx install check-jsonschema | ||
|
||
- name: Check payload | ||
run: | | ||
for type in "message"; do | ||
echo "Generate:" | ||
php ./get_payload.php "$type" | tee "payload.$type.json" | ||
echo "Validate:" | ||
check-jsonschema --schemafile "doc/schemas/$type.schema.json" "payload.$type.json" | ||
done | ||
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -30,3 +30,7 @@ Copyright: 2015 Luca Bruno ([email protected]) | |
2021 M2mobi B.V., Amsterdam, The Netherlands | ||
2022 Move Agency Group B.V., Zwolle, The Netherlands | ||
License: CC0-1.0 | ||
|
||
Files: doc/schemas/*.json | ||
Copyright: 2024 Move Agency Group B.V., Zwolle, The Netherlands | ||
License: CC0-1.0 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
{ | ||
"$schema": "https://json-schema.org/draft/2020-12/schema", | ||
"title": "APNS Push Message", | ||
"description": "A Push message for APNS", | ||
"type": "object", | ||
"properties": { | ||
"aps": { | ||
"type": "object", | ||
"properties": { | ||
"alert": { | ||
"type": ["object", "string"], | ||
"properties": { | ||
"title": { | ||
"type": "string" | ||
}, | ||
"body": { | ||
"type": "string" | ||
} | ||
} | ||
}, | ||
"badge": { | ||
"type": "number" | ||
}, | ||
"sound": { | ||
"type": "string" | ||
}, | ||
"content-available": { | ||
"type": "number" | ||
}, | ||
"mutable-content": { | ||
"type": "number" | ||
}, | ||
"category": { | ||
"type": "string" | ||
}, | ||
"thread-id": { | ||
"type": "string" | ||
} | ||
}, | ||
"required": ["alert"] | ||
} | ||
}, | ||
"required": ["aps"] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,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(); |