Skip to content

juliangut/tify_example

Repository files navigation

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.

About

Push notification server example

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published