I added the feature of syncing google calendar with events of my application. But the issue was, the event organizer/creator was receiving emails from google whenever the event attendee responds to the google calendar event. I wanted to receive the email notification for only creation/updation of events. I added the notification_settings and kept event_response method to blank but it didn't work.
CALENDAR_ID = 'primary'
CALENDAR_NOTIFIER = 'externalOnly'
gcal_event = client.insert_event(
CALENDAR_ID,
Google::Apis::CalendarV3::Event.new(gcal_event_params(gcal_event_attendees)),
send_updates: CALENDAR_NOTIFIER
)
-----------------------
// added notification_settings later so that the organizer should not receive event response, but no luck so far.
def gcal_event_params(gcal_event_attendees)
{
summary: event.name,
description: event.description,
location: event.location,
start: { date_time: event.start.to_datetime.to_s, time_zone: org_timezone },
end: { date_time: event.ends.to_datetime.to_s, time_zone: org_timezone },
attendees: gcal_event_attendees,
reminders: { use_default: true },
notification_settings: {
notifications: [
{type: 'event_creation', method: 'email'},
{type: 'event_change', method: 'email'},
{type: 'event_cancellation', method: 'email'},
{type: 'event_response', method: ''}
]
} }
end
Answer:
The notification settings for event creation, change, cancellation and response are settings of the Calendar itself, not the individual events of the Calendar. The notification_settings parameter of Events: insert does not exist, which is why this is not working.
More Information:
I'm not really sure where the writer of the blog that you linked is getting the information, but the Events: insert method of the Calendar API does not have this parameter.
In the user interface at calendar.google.com, you can see the notification settings you are referring to in the settings page for the whole calendar, not for individual events:
For individual events, when the event is created, you can use the sendUpdates parameter to specify who, if anyone, should be notified when the event is created. The same parameter exists as a part of the Events: update method, which lets you set who gets notified of that specific change.
If you want to have notifications set up for the creation, changing and cancellation of events, but not of event responses, then this needs to be set up for the Calendar itself. Unfortunately however, this isn't something that can be done with the API and needs to be set in the User Interface itself.
This does unfortunately mean that what you're looking at doing isn't something that is possible through the Calendar API.
Feature Request:
If this is of interest to you, you can however let Google know that this is a feature that is important for the Calendar API and that you would like to request they implement it. Google's Issue Tracker is a place for developers to report issues and make feature requests for their development services. The page to file a Feature Request for the Calendar API is here.
References:
Google Calendar API - Events: insert
Google Calendar API - Events: insert Parameters
Google Calendar API - Events: update
Google Calendar User Inferface
Google Calendar API - Calendars: insert
Google Calendar API - Calendars: update
Google Issue Tracker - Create a Calendar API Feature Request
Related
In my project, I have created Rest API project to create subscription and to listen notification from Microsoft Graph API.
I want subscription for following things:
When I create meeting room event then I want to get notification if any attendees accept/reject that meeting room event.
If whole meeting event is cancelled or moves to another time slot or added any new attendees.
I was expecting all above gets covered by following code but it is not :
var subscription = new Subscription
{
ChangeType = "updated,deleted",
NotificationUrl = $"{_notificationHost}/listen",
Resource = "me/events",
ClientState = Guid.NewGuid().ToString(),
IncludeResourceData = false,
// Subscription only lasts for one hour
ExpirationDateTime = DateTimeOffset.UtcNow.AddHours(1)
};
It does not send notification when accept or reject done by attendee with 'Do not send a response'. How I can get notification for this?
I managed both scenarios :
I am getting notification for attendees's reject/approve response on my listen api : NotificationUrl = $"{_notificationHost}/listen",
If new attendess added/removed or meeting time change or meeting cancelled then also we can get notification in Listen api.
We are experiencing inconsistencies with calendar ID's.
When sending a POST to https://graph.mircrosoft.com/v1.0/me/calendars with the following payload
{ name: 'Calendar' }
We receive this reponse from which we store the id
{
:"#odata.context"=>"https://graph.microsoft.com/v1.0/$metadata#users('user%40outlook.com')/calendars/$entity",
:id=>"AQMkADAwATMwMAItMjE5ZC01YjYyLTAwAi0wMAoARgAAA1D6u4KwtRdMm1rAZoOEKvAHAMf0BP7S_89KmnrxCgze9tcAAAIBBgAAAMf0BP7S_89KmnrxCgze9tcAAAEBKdoAAAA=",
:name=>"Calendar",
:color=>"auto",
:changeKey=>"x/QE/tL7z0qaevEKDN721wAAAAAOFQ==",
:canShare=>true,
:canViewPrivateItems=>true,
:canEdit=>true,
:owner=>{:name=>"User", :address=>"user#outlook.com"}
}
When we attempt to create events into this calendar errors are being thrown as that ID does not exist. Looking into it further and making a GET request to https://graph.mircrosoft.com/v1.0/me/calendars we receive this payload (truncated for brevity)
{
:id=>"AQMkADAwATMwMAItMjE5ZC01YjYyLTAwAi0wMAoARgAAA1D6u4KwtRdMm1rAZoOEKvAHAMf0BP7S_89KmnrxCgze9tcAAAIBBgAAAMf0BP7S_89KmnrxCgze9tcAAAIjxAAAAA==",
:name=>"Calendar",
:color=>"auto",
:changeKey=>"I8E7t/aNjEqDHtJJL1UC6AAADFI=",
:canShare=>true,
:canViewPrivateItems=>true,
:canEdit=>true,
:owner=>{:name=>"User", :address=>"user#outlook.com"}}]
}
After diffing both ID's, we notice they differ. The interesting part of this is that this only happens with a handful of users and isn't an issue with most accounts. Is there a better way to keep track of specific calendars that we can continue to sync into? I'd hate to have to ping for calendars every time we'd like to fire off a CRUD action.
I'm listening to the optin event fired by Facebook Messenger. The docs say I should receive an object with { 'sender': { 'id': 'USER_ID' } } in it. However, the data I get is missing this information. I do receive the optin event, and I get the rest of the data, but I'm missing the sender.
The response I get looks like this:
"messaging"=>[{
"recipient"=>{"id"=>"MY_PAGE_ID"},
"timestamp"=>1503480281655,
"optin"=>{"ref"=>"PASS_THROUGH_PARAM", "user_ref"=>"5019"}
}]
I'm using the facebook-messenger gem to handle the webhook events. However I decided to intercept the request directly to check the data I was getting, which is what I used to generate the above response. The object the gem gives me looks like this:
#<Facebook::Messenger::Incoming::Optin:0x007fe2829a4928
#messaging={ "recipient"=>{"id"=>"MY_PAGE_ID"},
"timestamp"=>1503480091027,
"optin"=>{"ref"=>"PASS_THROUGH_PARAM", "user_ref"=>"58326"}
}>
Here's where I listen to the optin event.
Finally the click handler to fire the optin event is exactly per Facebook's documentation:
FB.AppEvents.logEvent('MessengerCheckboxUserConfirmation', null, {
'app_id':'<%= Figaro.env.facebook_app_id %>',
'page_id':'<%= Figaro.env.facebook_page_id %>',
'ref':'PASS_THROUGH_PARAM',
'user_ref':'<%= #uniq_user_ref %>'
});
Here's the rest of that file in case it's valuable.
Is there anything else I need to set up or pass through to tell Facebook I want this information?
Is it possible you're using the Checkbox plugin instead of the Send to Messenger plugin? On the Checkbox documentation, they mention the following (emphasis mine):
Callback
After the opt-in event, we will post a webhook event to your server if
the checkbox state was checked. This callback has the same format as
the opt-in callback, but instead of a sender field, it has an optin
object with a user_ref field.
In my App there is PubNub used for Chat function,and for delete chat history,there is Web service,In app chat history clear successfully,but when application in background state and another user send message to me,notification is received and if I open that notification, it redirect to Chat Controller, but my problem is that when chat history clear successfully,still on my chat page all deleted message are present,is there is solution to delete message from pub-nub?
PubNub Message Update & Delete Features - NEW
Update Published Messages using the Message Actions feature.
pubnub.addMessageAction(
{
channel: 'chats.room123'
messageTimetoken: '15610547826970040',
action: {
type: 'updated',
value: 'Hello World! (edited)',
},
},
function(status, response) {
}
);
Delete Messages using the deleteMessages API.
There is a setting to accept delete from history requests for a key, which you must enable by checking the Enable Delete-From-History checkbox in the key settings for your key in the Admin Portal.
Requires Initialization with the secret key.
pubnub.deleteMessages(
{
channels: 'chats.room1',
start: "15526611838554309",
end: "15526611838554310",
},
function (status, response) {
console.log(status, response);
}
);
Soft Delete a Message, using the Message Actions feature.
"action": {
"type": "deleted",
"value": "."
}
UPDATE: THIS DESIGN PATTERN IS STILL LEGITIMATE BUT IS OUTDATED. PLEASE REFER TO THE ABOVE FOR BEST PRACTICES.
PubNub Storage/History Update & Delete Design Pattern
Although PubNub's API does not directly support the editing of stored messages, you can use a design pattern authored by one of our very own Solution Architects.
Message Updates and Deletes Design Pattern
I just played around with the Google Calendar Java API within my Scala Webframework and managed to create a new calendar programatically. After that, I create a new event within that calendar.
My problem is, that the event in the new calendar does not seem to be synced with my client devices (my tablet). However, if I create an event in my "primary" calendar, I immediately see the event on all of my devices.
If I go to https://www.google.com/calendar/syncselect, the recently created calendar is checked. So actually I would expect all events to be synced on my devices.
I'm using the JAVA API within a Scala context:
def addCalendar(serviceCalendar: com.google.api.services.calendar.Calendar): com.google.api.services.calendar.model.Calendar = {
val calendar = new Calendar()
calendar.setSummary("test calendar")
serviceCalendar.calendars().insert(calendar).execute()
}
//...
//code fragment where a new event is inserted into an existing calendar
val credential = new GoogleCredential().setAccessToken(token.get.value)
val calendar = Auth.getCalendarService(credential)
//create a new test calendar
val testCalendar = addCalendar(calendar)
val event = createEvent
//insert new event into "primary" calendar.
calendar.events().insert("primary", event).execute()
//insert event into the new calendar
calendar.events().insert(testCalendar.getId(), event).execute()
Both events appear in the Google Calendar web interface. However only the event in the "primary" calendar is synced.
If I look into the "calendar list" of my Android (Samsung S Planner, Android 4.3.) application, I don't see the recently created calendar as "in sync". (The primary calendar is marked as in sync!).
So I guess this is the reason why I see the "primary event" but not the other one. But actually I would expect Google to send some kind of push notification that a new calendar has been added to the account.
Can I enforce that programatically? Or is it simply a matter of time?
Syncselect only influences iCalendar, iOS and other CalDAV clients. It's not used for Android. In there the toggle for calendar syncing is on the device and AFAIK needs to be done manually.