Pergunta

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.

Foi útil?

Solução

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

Outras dicas

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();
    
Licenciado em: CC-BY-SA com atribuição
Não afiliado a StackOverflow
scroll top