lunchclass / absolute

Absolute is a web-based O2O(Online to Offline) platform like Siren-Order for Starbucks. We are focused on creating the platform that is portable, cheaper, easier, decentralized and appless.
Apache License 2.0
103 stars 31 forks source link

Designing REST API for push-notification #500

Open GarlicB opened 7 years ago

GarlicB commented 7 years ago

I referenced kakao developers.

Default Setting Host: https://api.absolute.com/v1.0 Authorization: FCM Server Key Data Format : application/json

We use web-pushlib, and the push server key is fcm (firebase clouding message).

Detail 2-1. Registration URL: /push/register Method: POST Params (all string type) Endpoint: The id to receive the push. p256dh: The public key that encrypts the payload between client and server. auth: The authorization code.

On the client side, the user sends his own token (endpoint, p256dh, auth) generated from the subscription to the server and stores it in database.

2-2. Unregistration POST /push/unregister Method: POST Params:endpoint,p256dh,auth (same 2-1) Response: 200 OK 'deleted tokens' <-log msg (example)

Delete the push token for a specific user.

2-3. Show tokens URL: /push/tokens Method: GET Params: querystring 'auth' auth: user's auth code(default value is null)

If the value of the params is 'null', the entire token list is displayed. (/push/tokens) Or if you enter a specific auth value, it prints only the corresponding tokens.(/push/tokens?auth='***')

2-4. Send payload to user URL: /push/send Method: POST Params: for_fcm "for_fcm":{ "comment": "yay, it works", "delay_while_idle":false, "time_to_live":17200, "priority":"high" }

@romandev. Sorry for being late. I have redesigned it with more information.

romandev commented 6 years ago

@GarlicB Thank you for this. But you missed some parameter information. Please add the info in more details. Also, I'm not sure if we need /push/event API in server side.

/cc @daehyunjimmy @JayChl