[F/OS/EXP] 📅 Google Calendar Extension! (60+ Blocks)

:computer: Introduction

This took me :calendar: 9 weeks to make. Hope it saved some of your time!

Please note that I am in a rush publishing this extension, and I did not cover the topic about permissions and the AIA file. It will be published in a week. Thanks!

Here is the first App Inventor extension for Google Calendars, with 60+ blocks.

Google Calendars is a complicated tool for App Inventor, unlike Google Drive, and you need to set up things like permissions for Apps Script and calendar IDs. It also has 5 different permissions, unlike 4 in Google Drive, but fear not, I'll walk you through the whole process. It will only take around 5 to 10 minutes to implement this into your project.

We all know that there was a tutorial about Google Calendars at the old forum, but it is 8 years old, Google has changed, and of course, we need a new method.

First, you have to obtain a few things - a calendar ID and a Google Apps Script. Go to the :bookmark_tabs: Instructions before using section after the documentation.

:open_book: Documentation

Event blocks

AddedGuestToEvent

image

This event is fired when you have added a guest to this calendar event.

Parameters: calendarId = text, eventId = text, guestEmail = text

AfterCalendarColorSet

image

This event is fired when you have set the color of this calendar.

Parameters: calendarId = text, color = color

AfterCalendarDescriptionSet

image

This event is fired when you have set the description of this calendar.

Parameters: calendarId = text, description = text

AfterCalendarDescriptionSet

image

This event is fired when you have set the description of this calendar.

Parameters: calendarId = text, description = text

AfterCalendarSetIfHidden

image

This event is fired you have set if the calendar should be hidden in your dashboard.

Parameters: calendarId = text, isHidden = boolean

AfterCalendarSetIfSelected

image

This event is fired you have set if the calendar should be selected in your dashboard. If it is unselected, it also means that the events of this calendar will not be shown in the main dashboard.

Parameters: calendarId = text, isSelected = boolean

AfterCalendarTimezoneSet

image

This event is fired when you have set the timezone of this calendar.

Parameters: calendarId = text, newTimezone = text

CheckedIfCalendarIsHidden

image

This event is fired after the extension has checked if the calendar is hidden in your dashboard.

Parameters: calendarId = text, isHidden = boolean

CheckedIfCalendarIsPrimary

image

This event is fired after the extension has checked if the calendar is your primary calendar.

Parameters: calendarId = text, isPrimary = boolean

CheckedIfCalendarIsSelected

image

This event is fired after the extension has checked if the calendar is selected in your dashboard.

Parameters: calendarId = text, isSelected = boolean

CheckedIfCalendarIsYours

image

This event is fired after the extension has checked if the calendar is owned by you. This also means that you have the power to do anything to this calendar (except unsubscribing).

Parameters: calendarId = text, isOwnedByYou = boolean

CreatedCalendar

image

This event is fired when the extension has created a new calendar in your account.

Parameters: calendarId = text, calendarName = text

CreatedMultipleWholeDaysEvent

image

This event is fired when the extension has created a multiple-whole-day event in your calendar.

Parameters: title = text, eventId = text

CreatedSingleWholeDayEvent

image

This event is fired when the extension has created a single-whole-day event in your calendar.

Parameters: title = text, eventId = text

DeletedCalendar

image

This event is fired when the extension has deleted a calendar in your account.

Parameters: calendarId = text

DeletedEvent

image

This event is fired when the extension has deleted an event in your calendar.

Parameters: calendarId = text, eventId = text

Error

image

This event is fired when an error has occurred.

Parameters: message = text

GotCalendarColor

image

This event is fired when the extension has received the color of the calendar.

Parameters: calendarId = text, color = number (int)

GotCalendarDescription

image

This event is fired when the extension has received the description of the calendar.

Parameters: calendarId = text, description = text

GotCalendarName

image

This event is fired when the extension has received the name of the calendar.

Parameters: calendarId = text, name = text

GotCalendarTimeZone

image

This event is fired when the extension has received the time zone of the calendar.

Parameters: calendarId = text, timezone = text

GotDefaultCalendarId

image

This event is fired when the extension has received the ID of your default calendar.

Parameters: id = text

ListedCalendars

image

This event is fired when the extension has received a list of your calendars.

Parameters: calendarId = text, calendars = list

ListedEventCreators

image

This event is fired when the extension has listed a series of creators of this event.

Parameters: calendarId = text, eventId = text, creators = list

ListedOwnedCalendars

image

This event is fired when the extension has received a list of your calendars that you solely own.

Parameters: calendarId = text, calendars = list

UnsubscribedFromCalendar

image

This event is fired when the extension has unsubscribed you from the calendar. You may not unsubscribe if you are the owner.

Parameters: calendarId = text

Method blocks

AddGuestToEvent

image

Adds a guest to this event.

Parameters: eventId = text, guestEmail = text

CreateCalendar

image

Creates a calendar in your account.

Parameters: calendarName = text

CreateMultipleWholeDaysEvent

image

Creates an event in the calendar that lasts for multiple days.

Parameters: title = text, startDate = instant, endDate = instant

CreateMultipleWholeDaysEventWithOptions

image

Creates an event in the calendar that lasts for multiple days with options. The description and location can be anything you like (such as "Cologne", "HK", etc.). The guests parameter indicates the list of guests you want to add, and sendInvites if you want to send them an email to notify them.

Parameters: title = text, startDate = instant, endDate = instant, description = text, location = text, guests = list, sendInvites = boolean

CreateSingleWholeDayEvent

image

Creates a single day event in your calendar.

Parameters: title = text, date = instant

CreateSingleDayEventWithOptions

image

Creates an event in the calendar that lasts for one day with options. The description and location can be anything you like (such as "Cologne", "HK", etc.). The guests parameter indicates the list of guests you want to add, and sendInvites if you want to send them an email to notify them.

Parameters: title = text, date = instant, description = text, location = text, guests = list, sendInvites = boolean

DeleteCalendar

image

Deletes this calendar permanently.

DeleteEvent

image

Deletes this event in the calendar.

Parameters: eventId = text

GetCalendarColor

image

Gets the theme color of the calendar.

GetCalendarDescription

image

Attempts to get the description of the calendar.

GetCalendarName

image

Attempts to get the name, or the title, of the calendar.

GetCalendarTimezone

image

Attempts to get the timezone of the calendar. A sample response may be "Asia/Hong_Kong".

GetDefaultCalendarId

image

Attempts to get the calendar ID of your default calendar. The CalendarId property will not affect this method, because all users, no matter their permissions, have their default calendars.

IsCalendarHidden

image

Checks if this calendar is hidden, or unlisted, in the list of your calendars in your Google Calendar dashboard.

IsCalendarOwnedByYou

image

Checks if this calendar is owned by you, i.e. if you are the owner of this calendar.

IsCalendarSelected

image

Checks if this calendar is selected in your Google Calendar dashboard. A calendar's events will be hidden in the main dashboard if it is unselected, but the calendar will still appear in the list of calendars.

IsMyPrimaryCalendar

image

Checks if this calendar is your primary calendar.

ListAllCalendars

image

Attempts to get a list of all of your calendars. The CalendarId property does not affect this method.

ListAllOwnedCalendars

image

Attempts to get a list of all of your owned calendars. The CalendarId property does not affect this method.

ListEventCreators

image

Attempts to get a list of all event creators of the event in your calendar.

Parameters: eventId = text

SetCalendarColor

image

Sets the theme color of your calendar.

Parameters: color = color

SetCalendarDescription

image

Sets the description of your calendar.

Parameters: description = text

SetCalendarHidden

image

Sets whether to hide/unlist your calendar among the list of calendars in your Google Calendar dashboard or not.

Parameters: hideCalendar = boolean

SetCalendarSelected

image

Sets whether to select your calendar among the list of calendars in your Google Calendar dashboard or not. Unselecting a calendar does not unlist it among the list, but it hides the calendar events in the dashboard.

Parameters: selectCalendar = boolean

SetCalendarTimezone

image

Sets the timezone of your calendar.

Parameters: timezone = text

UnsubscribeFromCalendar

image

Unsubscribes from this calendar. You may not unsubscribe if you are the owner, because the owner must delete the calendar in order to unsubscribe.

Property blocks

CalendarId

image

image

image

Specifies the calendar ID of your calendar. Each calendar has their own unique calendar ID that you can find in Google Calendars. Most of the functions of this extension, unless specified, will operate according to this calendar ID. Please read the Instructions document for more info.

Requires: text

ScriptUrl

image

image

image

Specifies the Google Apps Script URL of your App Inventor project. For how to create this URL, please read the Instructions document in Instructions Before Using.

:bookmark_tabs: Instructions before using

:books: FAQ

Q1. My app is crashing when I use your extension. Why?

A1. During tests, I am aware of this issue. Most likely, it's one of those issues.

  • You did not use the correct Calendar ID or event ID in your blocks, especially in the events that have 2 parameters.

  • Check the script to make sure your code 100% matches my script and that you have enabled the necessary permissions.

  • Make sure your blocks match your permission level to this calendar. For example, if you only have permission to view the calendar but you used the SetColor block, it would crash.

  • Other issues. Please post them here.

Q2. Where is my event ID, and how can I get it in my Google Calendar app?

A2. Here are some simple steps.

  1. In the Google Calendar Website, click on the event and the edit icon.

  2. It will take you to a page like https://calendar.google.com/calendar/u/0/r/eventedit/Y2p1M3BvNjczNAU2OG44dDU5XPZvOTgwcGcgZ29yZG9ubHUwNzR5QG1.

  3. Copy the text after eventedit/, in my case, Y2p1M3BvNjczNAU2OG44dDU5XPZvOTgwcGcgZ29yZG9ubHUwNzR5QG1.

  4. In a Base 64 decoder online, like https://www.base64decode.org/, decode this string.

  5. You will get a new string with a space between two texts. Copy the former one. That is your event ID.

Q3. Should I consider sharing my deployment URL with others?

A3. Don't. This is because the script is deployed as your account. By sharing it with others, they have the same access with you, for example, if you are the owner and you share this with others, they have full permission as owners as well by using the URL.

Q4. Where can I use this extension?

A4. You can use this extension in unlimited private projects unlimitedly, and you can use it for all MIT competitions. If you would like to use it elsewhere, e.g. commercially, or non-MIT competitions, please message me first.

Q5: What should I avoid when using this extension?

A5: Refrain from using %23, %2C or %24 in this extension, like the titles, descriptions, locations, etc. The extension might crash or not function properly if so.

:inbox_tray: Downloads

AIX: com.gordonlu.googlecalendar.aix (60.6 KB)

GS SCRIPT: Script.txt (7.0 KB)

AIA:
ClTest.aia (61.6 KB)

This extension is open source! GitHub - GordonL0049/GoogleCalendar: App Inventor implementation of Google Calendar.


:+1: Credits

I would like to thank @Kumaraswamy for his post here, @vknow360 for one of his posts about YailList (I forgot which one), @AyProductions for proofreading my draft, my friends @Aquib_Khan, @Salman_Dev, @Horizon and @RR_Media for motivating me and you for reading this.

Please click that beautiful :heart: Like button at the bottom of this post because this literally took four weeks of planning and organizing. Thank you.

17 Likes

... I got a headache just browsing all the Blocks :grin:

4 Likes

That sounds great. :+1: I'll test it more closely later when there is more time...
If you have a (simple) test aia, it would be nice if you made it available.

1 Like

Whose account - the developer/script owner, or the account of the device user? (if the latter, how is authentication handled?)

The script owner's.

I have chosen some methods and functions and posted it here in this AIA. It is impossible (or complicated) to post every single function.

ClTest.aia (61.6 KB)

1 Like

I don't see times of day or alarms in this thread.
Does the extension handle those?

It can currently handle days, but events at different time periods is expected to be added in the next version. I'm currently working on it.

We cannot use Google Calendar in App Inventor to create an event such as "when GoogleCalendar.TimeIsUp", but we can create an email or SMS notification for that. Also intended for next release.

1 Like

What about sending a notification in this case?
Btw great work... :+1: congratulations...
Taifun

2 Likes

Well it may be hard, Google does not tell the extension when the event is fired, they call it a reminder. We can only choose between email or SMS.

Wow!!! Mind blowing @Gordon_Lu :+1:t2::+1:t2:

1 Like

I'm sorry, I've fixed some errors in the documentation. Please re-read it if you have. Thanks.

You are one of my favourite extension developers, @Gordon_Lu. Keep it up! :grin:

1 Like

The popup reminder might do this:

but the script owner's calendar must be also on the device users calendar, I guess.

I think so too, but I will have to authenticate the script user again in the app. Google will need to confirm that I was the one confirming the reminder.

I also had another hypothesis, that is, the popup reminder does not require authentication, and the reminder will be sent to all devices that has the Google account logged in.

Tested addPopupReminder(mins).

Works, but seems that the Calendar app has to be open and on screen for the popup to show, and go into the notification area. Could be a setting I need to make ?

What happens when you add a WebViewer showing the Calendar app and that the height and width is 1 px x 1 px?

Would then need to authenticate....

1 Like

Had a fiddle about with settings (probably all locked down to prevent annoying popups :wink: ), now being notified without app in foreground, even with phone off.

Does it work when you close the app completely, killing it in background as well? If yes, can you tell me what you changed? Thanks.