Справочник API

Уведомления

Поддержку функций проверяйте через app.capabilities, доступ — через app.access и разрешения хоста. Замените тестовые значения перед вызовом.

Определения типов

graphql
type Subscription {
  notificationCreated: Notification!
  notificationUpdated: Notification!
  notificationDeleted: Notification!
  notificationRefreshed: Boolean!
}

type Mutation {
  deleteNotifications(ids: [ID!]!): ActionResult!
  replyNotification(id: ID!, actionIndex: Int!, text: String!): Boolean!
}

type Query {
  notificationCount(query: String!): Int!
  notifications(query: String!, offset: Int!, limit: Int!): [Notification!]!
}

type ActionResult {
	affectedCount: Int!
}

scalar Instant

type Notification {
	id: ID!
	
	onlyOnce: Boolean!
	isClearable: Boolean!
	appId: ID!
	appName: String!
	postedAt: Instant!
	silent: Boolean!
	title: String!
	body: String!
	actions: [String!]!
	
	replyActions: [String!]!
}

Операции

subscription

notificationCreated

Получает новое обнаруженное уведомление устройства.

graphql
subscription notificationCreated {
  notificationCreated { id onlyOnce isClearable appId appName postedAt silent title }
}
subscription

notificationUpdated

Получает обновлённое уведомление устройства.

graphql
subscription notificationUpdated {
  notificationUpdated { id onlyOnce isClearable appId appName postedAt silent title }
}
subscription

notificationDeleted

Получает удалённое уведомление устройства.

graphql
subscription notificationDeleted {
  notificationDeleted { id onlyOnce isClearable appId appName postedAt silent title }
}
subscription

notificationRefreshed

Получает сигнал для обновления текущего списка уведомлений устройства.

graphql
subscription notificationRefreshed {
  notificationRefreshed
}
mutation

deleteNotifications

Удаляет указанные записи уведомлений и сообщает их количество.

graphql
mutation deleteNotifications($ids: [ID!]!) {
  deleteNotifications(ids: $ids) { affectedCount }
}
mutation

replyNotification

Отправляет ответ на уведомление через встроенное действие ответа. actionIndex отсчитывается с 0 среди действий с поддержкой ответа.

graphql
# `actionIndex` indexes [`Notification::reply_actions`], the
# reply-capable subset — not the plain action list.
mutation replyNotification($id: ID!, $actionIndex: Int!, $text: String!) {
  replyNotification(id: $id, actionIndex: $actionIndex, text: $text)
}
query

notificationCount

Подсчитывает сохранённые уведомления по запросу.

graphql
query notificationCount($query: String!) {
  notificationCount(query: $query)
}
query

notifications

Читает страницу сохранённых уведомлений устройства по запросу.

graphql
query notifications($query: String!, $offset: Int!, $limit: Int!) {
  notifications(query: $query, offset: $offset, limit: $limit) { id onlyOnce isClearable appId appName postedAt silent title }
}