AppMage

Push Notifications

This endpoint group provides methods for managing push notification subscriptions and retrieving necessary client-side configuration.

Endpoints

POST /api/rpc (Method: PushNotificationRpc.getVapidPublicKey)

  • Description: Retrieves the VAPID public key required for the client to subscribe to push notifications.

  • Request Body:

    {
      "method": "PushNotificationRpc.getVapidPublicKey",
      "params": {}
    }
  • Parameters:

    Name Type Required Description
  • Response:

    {
      "success": true,
      "data": {
        "publicKey": "YOUR_VAPID_PUBLIC_KEY"
      }
    }
  • Example (cURL):

    curl -X POST https://api.example.com/api/rpc \
      -H "Content-Type: application/json" \
      -H "X-API-Key: YOUR_API_KEY" \
      -d '{
        "method": "PushNotificationRpc.getVapidPublicKey",
        "params": {}
      }'

POST /api/rpc (Method: PushNotificationRpc.subscribe)

  • Description: Subscribes a user's device to receive push notifications. Delegates to PushNotificationService.

  • Request Body:

    {
      "method": "PushNotificationRpc.subscribe",
      "params": {
        "subscriptionObject": {
          "endpoint": "https://example.com/push",
          "keys": {
            "p256dh": "BASE64_ENCODED_P256DH_KEY",
            "auth": "BASE64_ENCODED_AUTH_SECRET"
          }
        },
        "channels": ["default", "news"]
      }
    }
  • Parameters:

    Name Type Required Description
    subscriptionObject Object Yes The PushSubscription object obtained from the client-side Web Push API.
    subscriptionObject.endpoint String Yes The URL endpoint for the push subscription.
    subscriptionObject.keys Object Yes An object containing the encryption keys for the subscription.
    subscriptionObject.keys.p256dh String Yes The P256dh key.
    subscriptionObject.keys.auth String Yes The authentication secret.
    channels Array<String> No An array of channel names to which the user wishes to subscribe. Defaults to ['default'].
  • Response:

    {
      "success": true,
      "data": {
        "success": true
      }
    }
  • Example (cURL):

    curl -X POST https://api.example.com/api/rpc \
      -H "Content-Type: application/json" \
      -H "X-API-Key: YOUR_API_KEY" \
      -d '{
        "method": "PushNotificationRpc.subscribe",
        "params": {
          "subscriptionObject": {
            "endpoint": "https://example.com/push",
            "keys": {
              "p256dh": "YOUR_P256DH_KEY",
              "auth": "YOUR_AUTH_SECRET"
            }
          },
          "channels": ["default"]
        }
      }'

POST /api/rpc (Method: PushNotificationRpc.unsubscribe)

  • Description: Unsubscribes a user's device from push notifications. Delegates to PushNotificationService.

  • Request Body:

    {
      "method": "PushNotificationRpc.unsubscribe",
      "params": {
        "subscriptionObject": {
          "endpoint": "https://example.com/push",
          "keys": {
            "p256dh": "BASE64_ENCODED_P256DH_KEY",
            "auth": "BASE64_ENCODED_AUTH_SECRET"
          }
        }
      }
    }
  • Parameters:

    Name Type Required Description
    subscriptionObject Object Yes The PushSubscription object to unsubscribe. Only the endpoint is strictly used for unsubscription.
    subscriptionObject.endpoint String Yes The URL endpoint of the push subscription to unsubscribe.
    subscriptionObject.keys Object Yes An object containing the encryption keys (not used for unsubscription, but part of the schema).
    subscriptionObject.keys.p256dh String Yes The P256dh key (not used for unsubscription).
    subscriptionObject.keys.auth String Yes The authentication secret (not used for unsubscription).
  • Response:

    {
      "success": true,
      "data": {
        "success": true
      }
    }
  • Example (cURL):

    curl -X POST https://api.example.com/api/rpc \
      -H "Content-Type: application/json" \
      -H "X-API-Key: YOUR_API_KEY" \
      -d '{
        "method": "PushNotificationRpc.unsubscribe",
        "params": {
          "subscriptionObject": {
            "endpoint": "https://example.com/push",
            "keys": {
              "p256dh": "YOUR_P256DH_KEY",
              "auth": "YOUR_AUTH_SECRET"
            }
          }
        }
      }'