Introduction
This took me 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 Instructions before using section after the documentation.
Documentation
Event blocks
AddedGuestToEvent
This event is fired when you have added a guest to this calendar event.
Parameters: calendarId = text, eventId = text, guestEmail = text
AfterCalendarColorSet
This event is fired when you have set the color of this calendar.
Parameters: calendarId = text, color = color
AfterCalendarDescriptionSet
This event is fired when you have set the description of this calendar.
Parameters: calendarId = text, description = text
AfterCalendarDescriptionSet
This event is fired when you have set the description of this calendar.
Parameters: calendarId = text, description = text
AfterCalendarSetIfHidden
This event is fired you have set if the calendar should be hidden in your dashboard.
Parameters: calendarId = text, isHidden = boolean
AfterCalendarSetIfSelected
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
This event is fired when you have set the timezone of this calendar.
Parameters: calendarId = text, newTimezone = text
CheckedIfCalendarIsHidden
This event is fired after the extension has checked if the calendar is hidden in your dashboard.
Parameters: calendarId = text, isHidden = boolean
CheckedIfCalendarIsPrimary
This event is fired after the extension has checked if the calendar is your primary calendar.
Parameters: calendarId = text, isPrimary = boolean
CheckedIfCalendarIsSelected
This event is fired after the extension has checked if the calendar is selected in your dashboard.
Parameters: calendarId = text, isSelected = boolean
CheckedIfCalendarIsYours
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
This event is fired when the extension has created a new calendar in your account.
Parameters: calendarId = text, calendarName = text
CreatedMultipleWholeDaysEvent
This event is fired when the extension has created a multiple-whole-day event in your calendar.
Parameters: title = text, eventId = text
CreatedSingleWholeDayEvent
This event is fired when the extension has created a single-whole-day event in your calendar.
Parameters: title = text, eventId = text
DeletedCalendar
This event is fired when the extension has deleted a calendar in your account.
Parameters: calendarId = text
DeletedEvent
This event is fired when the extension has deleted an event in your calendar.
Parameters: calendarId = text, eventId = text
Error
This event is fired when an error has occurred.
Parameters: message = text
GotCalendarColor
This event is fired when the extension has received the color of the calendar.
Parameters: calendarId = text, color = number (int)
GotCalendarDescription
This event is fired when the extension has received the description of the calendar.
Parameters: calendarId = text, description = text
GotCalendarName
This event is fired when the extension has received the name of the calendar.
Parameters: calendarId = text, name = text
GotCalendarTimeZone
This event is fired when the extension has received the time zone of the calendar.
Parameters: calendarId = text, timezone = text
GotDefaultCalendarId
This event is fired when the extension has received the ID of your default calendar.
Parameters: id = text
ListedCalendars
This event is fired when the extension has received a list of your calendars.
Parameters: calendarId = text, calendars = list
ListedEventCreators
This event is fired when the extension has listed a series of creators of this event.
Parameters: calendarId = text, eventId = text, creators = list
ListedOwnedCalendars
This event is fired when the extension has received a list of your calendars that you solely own.
Parameters: calendarId = text, calendars = list
UnsubscribedFromCalendar
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
Adds a guest to this event.
Parameters: eventId = text, guestEmail = text
CreateCalendar
Creates a calendar in your account.
Parameters: calendarName = text
CreateMultipleWholeDaysEvent
Creates an event in the calendar that lasts for multiple days.
Parameters: title = text, startDate = instant, endDate = instant
CreateMultipleWholeDaysEventWithOptions
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
Creates a single day event in your calendar.
Parameters: title = text, date = instant
CreateSingleDayEventWithOptions
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
Deletes this calendar permanently.
DeleteEvent
Deletes this event in the calendar.
Parameters: eventId = text
GetCalendarColor
Gets the theme color of the calendar.
GetCalendarDescription
Attempts to get the description of the calendar.
GetCalendarName
Attempts to get the name, or the title, of the calendar.
GetCalendarTimezone
Attempts to get the timezone of the calendar. A sample response may be "Asia/Hong_Kong".
GetDefaultCalendarId
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
Checks if this calendar is hidden, or unlisted, in the list of your calendars in your Google Calendar dashboard.
IsCalendarOwnedByYou
Checks if this calendar is owned by you, i.e. if you are the owner of this calendar.
IsCalendarSelected
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
Checks if this calendar is your primary calendar.
ListAllCalendars
Attempts to get a list of all of your calendars. The CalendarId property does not affect this method.
ListAllOwnedCalendars
Attempts to get a list of all of your owned calendars. The CalendarId property does not affect this method.
ListEventCreators
Attempts to get a list of all event creators of the event in your calendar.
Parameters: eventId = text
SetCalendarColor
Sets the theme color of your calendar.
Parameters: color = color
SetCalendarDescription
Sets the description of your calendar.
Parameters: description = text
SetCalendarHidden
Sets whether to hide/unlist your calendar among the list of calendars in your Google Calendar dashboard or not.
Parameters: hideCalendar = boolean
SetCalendarSelected
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
Sets the timezone of your calendar.
Parameters: timezone = text
UnsubscribeFromCalendar
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
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
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.
Instructions before using
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.
-
In the Google Calendar Website, click on the event and the edit icon.
-
It will take you to a page like
https://calendar.google.com/calendar/u/0/r/eventedit/Y2p1M3BvNjczNAU2OG44dDU5XPZvOTgwcGcgZ29yZG9ubHUwNzR5QG1
. -
Copy the text after
eventedit/
, in my case,Y2p1M3BvNjczNAU2OG44dDU5XPZvOTgwcGcgZ29yZG9ubHUwNzR5QG1
. -
In a Base 64 decoder online, like https://www.base64decode.org/, decode this string.
-
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.
Downloads
AIX: com.gordonlu.googlecalendar.aix (60.6 KB)
GS SCRIPT: Script.txt (7.0 KB)
This extension is open source! GitHub - gordonlu310/GoogleCalendar: App Inventor implementation of Google Calendar.
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 Like button at the bottom of this post because this literally took four weeks of planning and organizing. Thank you.