Push notification server example
Switch branches/tags
Nothing to show
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Failed to load latest commit information.
config
grunt
public
src
tests
.coveralls.yml
.editorconfig
.gitattributes
.gitignore
.scrutinizer.yml
.styleci.yml
.travis.yml
CONTRIBUTING.md
Gruntfile.js
LICENSE
README.md
composer.json
package.json
phpmd.xml
phpunit.xml

README.md

PHP version License

Build status Style Code Quality Code Coverage

Simple notification server implementation

Implementation of notification service to which devices can register to receive push notifications.

Uses Tify a Push notification services abstraction layer.

Installation

clone https://github.com/juliangut/tify_example
cd tify_example
composer install

Usage

Configuration

Create api.key and/or certificate.pem files in config directory to store your GCM api key and APNS certificate.

Run PHP builtin server

grunt serve

Or if you don't have grunt installed

php -S localhost:9000 -t public

Registering a device

curl -X PUT -H "Host: localhost:9000" -H "Accept: application/json" -H "Content-Type: application/json" -d '{"token": "device_token"}' "http://localhost:9000/register"
Request parameters
  • token: device token
  • platform: device platform (ios/android)

Updating a device registration

Device tokens can and should be changed from time to time, and then updated into the server to correctly receive push notifications.

curl -X PUT -H "Host: localhost:9000" -H "Accept: application/json" -H "Content-Type: application/json" -d '{"token": "device_token","previous_token":"previous_device_token"}' "http://localhost:9000/register"
Request parameters
  • token: device token
  • previous_token: previously saved device token to be replaced

Sending push notification to registered devices

curl -X POST -H "Host: localhost:9000" -H "Accept: application/json" -H "Content-Type: application/json" -d '{"title": "Push_title","body": "push_body","platform": "android"}' "http://localhost:9000/send"
Request parameters
  • title: notification title
  • body: notification content body
  • platform: (optional) platform to send to, all if not provided
  • data: (optional) key/value array of extra data to be appended to the notification

Contributing

Found a bug or have a feature request? Please open a new issue. Have a look at existing issues before.

See file CONTRIBUTING.md

License

See file LICENSE included with the source code for a copy of the license terms.