API 參考

Notifications

讀取活動通知。需要在設定中啟用 NotificationListenerService。

型別定義

bash
type Notification {
  id: ID!
  onlyOnce: Boolean!       # "persistent" notification flag
  isClearable: Boolean!
  appId: String!           # package name
  appName: String!
  time: String!            # ISO 8601
  silent: Boolean!
  title: String!
  body: String!
  actions: [String!]!      # action button labels
  replyActions: [String!]! # labels of inline-reply actions
}

操作

query

notifications

列出所有目前活動的通知。

bash
query GetNotifications {
  notifications {
    id onlyOnce isClearable appId appName time silent title body
    actions replyActions
  }
}
mutation

cancelNotifications

依 ID 駁回一個或多個通知。

bash
mutation CancelNotifications($ids: [ID!]!) {
  cancelNotifications(ids: $ids)
}
mutation

replyNotification

透過 inline-reply 動作向通知傳送回覆。actionIndex 在支援回覆的動作中以 0 為基準。

bash
mutation ReplyNotification($id: ID!, $actionIndex: Int!, $text: String!) {
  replyNotification(id: $id, actionIndex: $actionIndex, text: $text)
}