Skip to content
This repository has been archived by the owner on Feb 2, 2022. It is now read-only.

Latest commit

History

History

web

Folders and files

NameName
Last commit message
Last commit date

parent directory

..

PushTower web

Development

  • Core(Library)
    • Server(Application)
    • Desktop(Application)
npm install -g lerna
lerna bootstrap

Usage

Basic

Before launching server, we need to set env-var.

export __P8_FILE_PATH=
export __KEY_ID=
export __TEAM_ID=
export __IS_PRODUCTION=true or false

And then, build server application and launch.

cd packages/server
yarn run dev

Finally, send a request.

curl -X POST \
  http://localhost:9000/send \
  -H 'Content-Type: application/json' \
  -H 'X-target-device-token: <#TARGET DEVICE TOKEN#>' \
  -H 'x-topic: <#TARGET APP BUNDLE ID#>' \
  -d '{
  "aps" : {
    "badge" : 0,
    "alert" : "Hello"
  }
}'

In addition to export __IS_PRODUCTION=true you can set production mode by the following HTTP header

  -H 'x-is-production: 1' \

Using device_token key-value store and lookup

Storing device token

curl -X PUT \
  http://localhost:9000/device_token \
  -H 'Content-Type: application/json' \
  -d '{
  "key" : "John Appleseed's iPhone",
  "device_token" : <#TARGET DEVICE TOKEN#>
}'

This can be sent from an iOS app, if you install the iOS library

Sending push notification

curl -X POST \
  http://localhost:9000/send \
  -H 'Content-Type: application/json' \
  -H 'X-target-device-token-lookup-key: John Appleseed's iPhone' \
  -H 'x-topic: <#TARGET APP BUNDLE ID#>' \
  -d '{
  "aps" : {
    "badge" : 0,
    "alert" : "Hello"
  }
}'