about summary refs log tree commit diff
diff options
context:
space:
mode:
-rw-r--r--docs/Using-the-API/API.md24
-rw-r--r--docs/Using-the-API/Push-notifications.md17
2 files changed, 41 insertions, 0 deletions
diff --git a/docs/Using-the-API/API.md b/docs/Using-the-API/API.md
index 5d0c27ee8..470310417 100644
--- a/docs/Using-the-API/API.md
+++ b/docs/Using-the-API/API.md
@@ -81,6 +81,14 @@ Query parameters:
 
 Returns notifications for the authenticated user. Each notification has an `id`, a `type` (mention, reblog, favourite, follow), an `account` which it came *from*, and in case of mention, reblog and favourite also a `status`.
 
+**GET /api/v1/notifications/:id**
+
+Returns single notification.
+
+**POST /api/v1/notifications/clear**
+
+Clears all of user's notifications.
+
 ### Following a remote user
 
 **POST /api/v1/follows**
@@ -214,6 +222,22 @@ Creates a new OAuth app. Returns `id`, `client_id` and `client_secret` which can
 
 These values should be requested in the app itself from the API for each new app install + mastodon domain combo, and stored in the app for future requests.
 
+**POST /api/v1/devices/register**
+
+Form data:
+
+- `registration_id`: Device token (also called registration token/registration ID)
+
+Apps can use Firebase Cloud Messaging to receive push notifications from the instances, given that the instance admin has acquired a Firebase API key. More in [push notifications](Push-notifications.md). This method requires a user context, i.e. your app will receive notifications for the authorized user.
+
+**POST /api/v1/devices/unregister**
+
+Form data:
+
+- `registration_id`: Device token (also called registration token/registration ID)
+
+To remove the device from receiving push notifications for the user.
+
 ___
 
 ## Entities
diff --git a/docs/Using-the-API/Push-notifications.md b/docs/Using-the-API/Push-notifications.md
new file mode 100644
index 000000000..3ce3e36e2
--- /dev/null
+++ b/docs/Using-the-API/Push-notifications.md
@@ -0,0 +1,17 @@
+Push notifications
+==================
+
+Mastodon can communicate with the Firebase Cloud Messaging API to send push notifications to apps on users' devices. For this to work, these conditions must be met:
+
+* Responsibility of an instance owner: `FCM_API_KEY` set on the instance. This can be obtained on the Firebase dashboard, in project settings, under Cloud Messaging, as "server key"
+* Responsibility of the app developer: Firebase added/enabled in the Android/iOS app. [See Guide](https://firebase.google.com/docs/cloud-messaging/)
+
+When the app obtains/refreshes a registration ID from Firebase, it needs to send that ID to the `/api/v1/devices/register` endpoint of the authorized user's instance via a POST request. The app can opt out of notifications by sending a similiar request with `unregister` instead of `register`.
+
+The push notifications will be triggered by the notifications of the type you can normally find in `/api/v1/notifications`. However, the push notifications will not contain any inline content. They will contain JSON data of this format ("12" is an example value):
+
+```json
+{ notification_id: 12 }
+```
+
+Your app can then retrieve the actual content of the notification from the `/api/v1/notifications/12` API endpoint.