문제

I'm using the Google Calendar API push notifications and I'm successfully receiving the notifications when changes are made to the calendar. However, how can I tell what kind of change it is? When I use my sync token to pull the changes from Google after getting a notification, how do I know whether the event was added, modified, or removed? I don't see any kind of field that specifies this. All I know is which event it is.

도움이 되었습니까?

해결책

I figured it out - all the fields for a deleted event will be null except its ID (you need some way to identify it).

다른 팁

event.status == 'cancelled'

"cancelled" - The event is cancelled (deleted). The list method returns cancelled events only on incremental sync (when syncToken or updatedMin are specified) or if the showDeleted flag is set to true. The get method always returns them

https://developers.google.com/calendar/v3/reference/events

You have two ways to get deleted events:

In your request :

  1. Specify updatedMin or syncToken.

  2. Or set showDeleted flag to true.

    
    ...

    var request = calendarService.Events.List("Primary");
    
    request.UpdatedMin = DateTime.UtcNow.Date;
    
    //Show deleted events
    request.ShowDeleted = true;
    
    string synchToken = null;
    
    if (string.IsNullOrEmpty(synchToken))
    {
        request.TimeMin = DateTime.UtcNow.Date.AddDays(-1);
    }
    else
    {
        request.SyncToken = calendarStuff.SyncToken;
    }
    
    Events events = request.Execute();
    
라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top