push
Subscribe to and receive push notifications when a server-side notification is received, via the Web Push API
Last updated
Was this helpful?
Subscribe to and receive push notifications when a server-side notification is received, via the Web Push API
Last updated
Was this helpful?
Mastodon natively supports the . You can utilize the same mechanisms for your native app. It requires running a proxy server that connects to Android’s and Apple’s proprietary notification gateways. However, the proxy server does not have access to the contents of the notifications. For a reference, see , or more practically, see:
POST
https://mastodon.example/api/v1/push/subscription
Add a Web Push API subscription to receive notifications. Each access token can have one push subscription. If you create a new subscription, the old subscription is deleted.
Returns: PushSubscription
OAuth: User token + push
Version history:
2.4.0 - added
Authorization
string
Bearer <user token>
subscription[endpoint]
string
Endpoint URL that is called when a notification event occurs.
subscription[keys][p256dh]
string
User agent public key. Base64 encoded string of public key of ECDH key using prime256v1
curve.
subscription[keys][auth]
string
Auth secret. Base64 encoded string of 16 bytes of random data.
data[alerts][follow]
boolean
Receive follow notifications?
data[alerts][favourite]
boolean
Receive favourite notifications?
data[alerts][reblog]
boolean
Receive reblog notifications?
data[alerts][mention]
boolean
Receive mention notifications?
data[alerts][poll]
boolean
Receive poll notifications?
GET
https://mastodon.example/api/v1/push/subscription
View the PushSubscription currently associated with this access token.
Returns: PushSubscription
OAuth: User token + push
Version history:
2.4.0 - added
Authorization
string
Bearer <user token>
PUT
https://mastodon.example/api/v1/push/subscription
Updates the current push subscription. Only the data part can be updated. To change fundamentals, a new subscription must be created instead.
Returns: PushSubscription
OAuth: User token + push
Version history:
2.4.0 - added
Authorization
string
Bearer <user token>
data[alerts][follow]
boolean
Receive follow notifications?
data[alerts][favourite]
boolean
Receive favourite notifications?
data[alerts][reblog]
boolean
Receive reblog notifications?
data[alerts][mention]
boolean
Receive mention notifications?
data[alerts][poll]
boolean
Receive poll notifications?
DELETE
https://mastodon.example/api/v1/push/subscription
Removes the current Web Push API subscription.
Returns: none
OAuth: User token + push
Version history:
2.4.0 - added
Authorization
string
Bearer <user token>