API 参考

SMS

读取和发送 SMS/MMS 消息。需要 SMS 权限。Google Play 版本不可用。

类型定义

bash
type Message {
  id: ID!
  body: String!
  address: String!       # phone number
  date: String!          # ISO 8601
  serviceCenter: String!
  read: Boolean!
  threadId: String!
  type: Int!             # 1=inbox 2=sent 3=draft 5=failed
  subscriptionId: Int!
  isMms: Boolean!
  attachments: [MessageAttachment!]!
}

type MessageAttachment {
  path: String!
  contentType: String!
  name: String!
}

type SmsConversation {
  id: String!
  address: String!
  snippet: String!
  date: String!
  messageCount: Int!
  read: Boolean!
}

type SmsCounts {
  inbox: Int!
  sent: Int!
  draft: Int!
  failed: Int!
}

操作

query

sms

搜索 SMS 消息。查询使用空字符串可列出全部。

bash
query GetSms($offset: Int!, $limit: Int!, $query: String!) {
  sms(offset: $offset, limit: $limit, query: $query) {
    id body address date read threadId type subscriptionId isMms
    attachments { path contentType name }
  }
}
query

smsCount

统计匹配查询的 SMS 消息数量。

bash
query GetSmsCount($query: String!) {
  smsCount(query: $query)
}
query

smsConversations

列出 SMS 会话(线程),支持分页。

bash
query GetSmsConversations($offset: Int!, $limit: Int!, $query: String!) {
  smsConversations(offset: $offset, limit: $limit, query: $query) {
    id address snippet date messageCount read
  }
}
query

smsConversationCount

统计匹配查询的 SMS 会话数量。

bash
query GetSmsConversationCount($query: String!) {
  smsConversationCount(query: $query)
}
query

smsAllCounts

返回所有 SMS 分类的计数。

bash
query GetSmsAllCounts {
  smsAllCounts { inbox sent draft failed }
}
query

archivedConversations

列出已归档(隐藏)的会话。

bash
query GetArchivedConversations {
  archivedConversations { id address snippet date messageCount read }
}
mutation

sendSms

发送 SMS。传入 subscriptionId=-1 可使用默认 SIM。

bash
mutation SendSms($number: String!, $body: String!, $subscriptionId: Int!) {
  sendSms(number: $number, body: $body, subscriptionId: $subscriptionId)
}
mutation

sendMms

启动默认 SMS 应用并预填一个 MMS(一个或多个附件)。返回一个待处理的 MMS id;PlainApp 轮询发送状态并通过 WebSocket 事件报告成功。attachmentPaths 必须指向 PlainApp AppFile 存储中的文件(fid: URI)。

bash
mutation SendMms($number: String!, $body: String!, $attachmentPaths: [String!]!, $threadId: String!) {
  sendMms(number: $number, body: $body, attachmentPaths: $attachmentPaths, threadId: $threadId)
}
mutation

archiveSmsConversation

Archive a conversation by thread id; the server derives the snapshot date.

bash
mutation ArchiveSmsConversation($id: String!) {
  archiveSmsConversation(id: $id)
}
mutation

unarchiveSmsConversation

Remove a conversation from the archive.

bash
mutation UnarchiveSmsConversation($id: String!) {
  unarchiveSmsConversation(id: $id)
}