1. 程式人生 > >app 通知類介面設計

app 通知類介面設計

獲取Notification列表

Request { // 獲取未處理的訊息, 最多返回 limit 條
    "notifications": {
    "version": int  // 最初版本號為1
    "after": long   // notification id.  用於確認客戶端已收取訊息
    "not_in": [ last_id,1,1,1,...  ]  // 再把這幾個條目標記為已處理, 一般 after 比 last_id 對應的條目早 10 分鐘
    }
}
Response {
    "notifications": [ {
    "id": long
    "type": string
    "message": string
    "url": string
    "created_time": long
    }, ... ] 
}
  • after: 是本地獲取到的通知最後一條前十分鐘的那條通知的id,
  • last_id是最後一條通知的id, 並且把這十分鐘之間的通知的id與最後一條通知的id傳給伺服器 伺服器把得到的這些id的通知標記為已傳送,以後將不再發送這些通知,並查詢資料庫 把中間可能漏發的通知重寫傳送,以及有limit(100) 未傳送的通知傳送.