push
Subscribe to and receive push notifications when a server-side notification is received, via the Web Push API
Web Push API
Mastodon natively supports the Web Push API. 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 Mozilla’s web push server, or more practically, see:
post
Subscribe to push notifications
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.
戻り値: PushSubscription
OAuth: User token + push
実装履歴:
- 2.4.0 - 追加
リクエスト
ヘッダ
string
フォームのパラメータ
string
string
prime256v1
curve.
string
boolean
boolean
boolean
boolean
boolean
レスポンス
200: Success
A new PushSubscription has been generated, which will send the requested alerts to your endpoint.
{
"id": 328183,
"endpoint": "https://yourdomain.example/listener",
"alerts": {
"follow": true,
"favourite": true,
"reblog": true,
"mention": true,
"poll": true
},
"server_key": "BCk-QqERU0q-CfYZjcuB6lnyyOYfJ2AifKqfeGIm7Z-HiTU5T9eTG5GxVA0_OH5mMlI4UkkDTpaZwozy0TzdZ2M="
}
get
Get current subscription
View the PushSubscription currently associated with this access token.
戻り値: PushSubscription
OAuth: User token + push
実装履歴:
- 2.4.0 - 追加
リクエスト
ヘッダ
string
レスポンス
200: Success
{
"id": 328183,
"endpoint": "https://yourdomain.example/listener",
"alerts": {
"follow": true,
"favourite": true,
"reblog": true,
"mention": true,
"poll": true
},
"server_key": "BCk-QqERU0q-CfYZjcuB6lnyyOYfJ2AifKqfeGIm7Z-HiTU5T9eTG5GxVA0_OH5mMlI4UkkDTpaZwozy0TzdZ2M="
}
404: Not Found
A PushSubscription does not exist for this token.
{
"error": "Record not found"
}
put
Change types of notifications
Updates the current push subscription. Only the data part can be updated. To change fundamentals, a new subscription must be created instead.
戻り値: PushSubscription
OAuth: User token + push
実装履歴:
- 2.4.0 - 追加
リクエスト
ヘッダ
string
フォームのパラメータ
boolean
boolean
boolean
boolean
boolean
レスポンス
200: Success
Updating a PushSubscription to only receive mention alerts
{
"id": 328183,
"endpoint": "https://yourdomain.example/listener",
"alerts": {
"follow": false,
"favourite": false,
"reblog": false,
"mention": true,
"poll": false
},
"server_key": "BCk-QqERU0q-CfYZjcuB6lnyyOYfJ2AifKqfeGIm7Z-HiTU5T9eTG5GxVA0_OH5mMlI4UkkDTpaZwozy0TzdZ2M="
}
404: Not Found
No existing PushSubscription for this token
{
"error": "Record not found"
}
delete
Remove current subscription
Removes the current Web Push API subscription.
戻り値: none
OAuth: User token + push
実装履歴:
- 2.4.0 - 追加
リクエスト
ヘッダ
string
レスポンス
200: Success
PushSubscription successfully deleted or did not exist previously
{}
最終更新 May 17, 2020 · このページを改善する
他の言語:
English