当应用是更改的所有者时,请停用Google日历推送通知

时间:2017-10-10 17:27:10

标签: java push-notification google-calendar-api

当我使用java客户端从我的应用创建/更新Google事件时:

events
.insert(originalCalendarId, googleEvent)
.setSupportsAttachments(true)
.execute()

我仍然收到有关事件创建/更新的推送通知。 我不想得到它们,因为我是那些做过这些改变的人。更改以不同的方式应用于应用程序,在这种情况下,其他推送通知无效。

但是,我需要在其他地方(其他应用或Google Web UI)进行新的更改。

有办法处理这种情况吗?也许有一种方法可以让谷歌知道不需要特定查询的推送通知。

我也看到有一个属性:

com.google.api.services.calendar.Calendar.Events.Insert#sendNotifications

但是,无论我在此处设置什么,仍然会发送通知。

1 个答案:

答案 0 :(得分:1)

我认为您订阅了资源,如果您的应用程序刚刚进行了一些更改,您希望不会收到推送通知。所以你应该使用:

class Fruit:
    def __init__(self, colour):
        self.colour = colour

    def __hash__(self):
        return hash((self.__class__.__name__, self.colour))

    def __eq__(self, other):
        return type(self) == type(other) and self.colour == other.colour

    def __repr__(self):
        return '{} ({})'.format(self.__class__.__name__, self.colour)

class Apple(Fruit):
    pass

class Berry(Fruit):
    pass

from collections import Counter

fruits = [
    Apple('red'), Apple('green'), Berry('black'), Berry('red'),
    Berry('black'), Apple('red'), Berry('red'), Apple('green'),
    Berry('blue'), Apple('pink')
]
counts = Counter(fruits)
#Counter({Apple (green): 2,
#         Apple (pink): 1,
#         Apple (red): 2,
#         Berry (black): 2,
#         Berry (blue): 1,
#         Berry (red): 2})

如果您收到推送通知的任何方式,请与您自己一起检查推送通知.insert(originalCalendarId, googleEvent) .setSupportsAttachments(true) .setSendNotifications(false) .execute() ,以确定是X-Goog-Channel-ID问题。我相信您有一些未正确处理的旧订阅,这就是您收到Google更改的原因。