2016-11-23 20 views

回答

1

不幸的是,您不能。你需要做的是

獲得通知到達時的歷史。歷史記錄返回json,如果添加新消息,它將包含'messagesAdded'

你可以保持predefined array of labels像下面

predefinedLabels = ['UNREAD', 'CATEGORY_PERSONAL', 'INBOX'] 

現在你可以檢查,(each is the history json)

if 'messagesAdded' in each: 
    labels = each["messagesAdded"][0]["message"]["labelIds"] 
    intersectionOfTwoArrays = list(set(predefinedLabels) & set(labels)) 

在這裏,你得到intersection of labels。現在,你必須檢查與predefined labels

if set(predefinedLabels) == set(intersectionOfTwoArrays): 
    #get the messageId and do what you want 

終於可以filter the notification只要你想!

最好存儲histroyId並更新它每 notification並使用它,當你得到history。它會幫助你 只獲取更新歷史記錄。

請注意我在建造我的服務器時使用了python。因此,上面的代碼使用python

0

寫入它看起來像history.list添加了一個新的參數「historyTypes」。如果將其設置爲「messageAdded」,則api將僅返回該類型的歷史記錄。

相關問題