在另一个应用程序中执行操作会触发我自己的操作

Make action in another app trigger an action in my own

我研究过使用 Google 的日历 API 和提供程序,发现可以读取用户的日历。如果用户在更改其 Google 日历后打开应用程序,这可用于使我的应用程序的内部日历与 Google 日历保持同步。

我想知道是否可以在 Google 日历发生更改时通知我的应用程序,以便我的应用程序可以复制这些更改并在我的应用程序自己的在线数据库中保持同步。

这是因为我的应用程序的功能要求用户比较日历,但如果 Google 日历中发生更改,并且在用户再次打开我的应用程序之前无法看到,它就没有用了。

感谢所有想法并提前致谢。

是的,只要您的日历发生变化,就可以收到通知。 Notifications 让您可以了解日历中事件的变化。

Google 日历 API 提供推送通知,让您可以关注资源的变化。您可以使用此功能来提高应用程序的性能。它允许您消除轮询资源以确定它们是否已更改所涉及的额外网络和计算成本。每当监视的资源发生变化时,Google 日历 API 会通知您的应用程序。

request push notifications,您需要为每个要观看的资源设置一个通知通道。设置通知渠道后,Google 日历 API 将在任何已监视资源发生变化时通知您的应用程序。

POST https://www.googleapis.com/calendar/v3/calendars/my_calendar@gmail.com/events/watch
Authorization: Bearer auth_token_for_current_user
Content-Type: application/json

{
  "id": "01234567-89ab-cdef-0123456789ab", // Your channel ID.
  "type": "web_hook",
  "address": "https://exampledomain.com/notifications", // Your receiving URL.
  ...
  "token": "target=myApp-myCalendarChannelDest", // (Optional) Your channel token.
  "expiration": 1426325213000 // (Optional) Your requested channel expiration time.
  }
}