Differentiating between Accept and Delete Notifications from Microsoft Graph Events - microsoft-graph-api

I created a subscription to my Outlook calendar using the Microsoft graph SDK.
When I accept an event in Outlook, Outlook sends my server 3 notifications in succession:
Event Updated
Event Delete
Event Created
As far as I can tell, this means Outlook is:
Registering that the event has changed
Deleting the current instance of the event
Creating a brand new accepted event (with the same ICalUId as the deleted event)
When I look at the notifications sent by Outlook, the first two notifications (update and delete) have the same event id but the create notification has a different event id.
Is there any way to differentiate between the delete notification coming from this batch of notifications (after someone clicks "Accept") and the delete notification sent to me when an event is actually declined/removed from Outlook?
NOTE- Currently I am storing the iCalUId for the event in my database and when I receive a deleted notification, I get the iCalUId for the event and check Outlook to see if an event with the same ICalUId exists. If there is an event, I update my db and don't delete the event. However, this morning I noticed that it took Outlook nearly 10 seconds to go from steps 2 to 3 (deleting the instance to creating a new instance).
More specifically, I received the deleted notification, checked Outlook to see if an event with the same ICalUId was there and there was none. 10 seconds later (after I deleted the event from my db) I received an event created notification.
The only potential work-around I can think of is to continue checking for the event in Outlook for a period of time (30 seconds?).

Related

ios - Schedule unlimited number of local notifications

I have an app that allows users to create recurrent events. Each one of the events may or may not have reminder/alerts at a specific time of day. If they have so, the app sends a local notification at that time of day.
Events are stored in CoreData.
Event(name: "Go to London",
date: 2020-04-03 21:40:55.419925+0200,
reminders: [2020-04-03 20:00:00.419925+0200,
2020-04-03 10:00:00.419925+0200,
2020-04-03 12:00:00.419925+0200]
)
An event may occur on each day of the year or everyday for the next X years.
A user may create unlimited number of events per day. And hence, the total number of notifications to be sent can easily surpasses 64 (total number of local notification that you can schedule in iOS). So I can not schedule all the notifications while the app is in foreground.
I need a mechanism to periodically schedule notifications if there are less than 64 notifications pending. This should be done even if the app is in the background.
I would be happy if you provide a solution or guide me towards finding a solution for this scenario.
info
I tried to set up a Timer that periodically checks total number of pending notifications and their due dates. . But it did not work, because timers won’t fire once the app goes in background.
I am not sure if I understand your problem right. But my impression is the following:
Your users set up and update a database of events where each event has a certain date and time.
They do this simply be entering new events into the database.
It is easy then to fetch the first n (say, 10) events from the database.
It is required to fetch more than one, since the delivery of a local notification is not guaranteed, see the docs:
Every attempt is made to deliver local and remote notifications in a
timely manner, but delivery isn't guaranteed.
Register these n local notifications with the notification center, and cancel any notification for events that are no longer among the n next ones. The docs say:
Typically, you cancel a request when conditions change and you no
longer need to notify the user. For example, if the user completes a
reminder, you would cancel any active requests associated with that
reminder. To cancel an active notification request, call the
removePendingNotificationRequests(withIdentifiers:) or
removePendingNotificationRequests(withIdentifiers:) method of
UNUserNotificationCenter.
So, even if your app is in the background or suspended, the local notification will wake it up, handle the event, remove it from the database, and update the n next events. Even if a notification could not be delivered (which is not probably, but possible), you could handle the missed event, and schedule the next ones.
I hope this meets your requirements!
Have you tried the background fetch feature? Official document link here.
And in my opinion, it would be better to use remote notification, just setup a simple server to store the users' data.

MSGraph Calendar Events Multiple Notifications

Noticed that I am receiving multiple notifications when a calendar event is created or updated. For example, I created an event on Outlook calendar web client and invited some attendees. I received one notification with changeType as "created", followed by 4 notifications with changeType as "updated". What is the logic behind the notifications? There were no updates made to this event. All the notifications came within 1 or 2 seconds after the first "created" notification.
The number of notifications depends on the number of objects your event action affects. For example creating a new meeting results in an update of the calendar folder object. Remember that you are not subscribed only to the event but the calendar, so your requirement from the API maybe a subset of what the API does
IMHO it is a redundant feature carried forward from EWS

microsoft notification webhook

I have application who is getting notifications from Outlook, it is subscribed for update,create changes in users mailboxes. I am getting notifications all day long even if the users are not active (It is their sleep time). Can I know how notifications are sent to me?
There are all sorts of background tasks (assistants), both time based and event based that wake up and do work on the system. In addition, there may be apps that the user has given permissions to operate on their mailbox that may be doing something behind the scenes. Exchange doesn't differentiate. When a change is made that matches the criteria in the subscription, a notification will be generated.

Is there a way to get outlook push notification, only when a specific field of calendar item is updated?

I followed the Outlook push notification documentation to subscribe for calendar notifications. And I am able to receive push notification whenever calendar item is changed or deleted. Now I want to receive push notification only when specific properties(example: To, Start time and End time properties) of calendar item are updated or calendar item itself is deleted.
Is there any API available to implement above scenario?
This isn't supported, the hooks are scoped at the object level (event, user, etc). You cannot subscribe to an individual property.

Google calendar API push notifications - update from API creates unnecessary notification

I have a rails app using Google calendar API with push notifications for each calendar the user shares with my app.
when user updates an event from app, it creates an updatedEvent request to API.
because the calendar is listed to push notification, it pushes a notification about some update to the calendar events (the same event of course ).
am i missing an attribute that can silent the notify?
when i get notify about changes and get the changed items from response, i compare the etag of the event with the one that i get from the API response so i manged to avoid another update.
but it's still an unnecessary update.

Resources