Google Calendar Notifications

 How I can get google calendar events and notifications on my watch widget? Couldn't find any resource on this subject. 

  • You can get notifications and calendar events from a paired Android or iOS phone via built-in notifications and calendar widgets/glances, if that's what you mean:
    https://support.garmin.com/en-CA/?faq=TLeDN92ZU0AgN4df6HakwA

    If you mean that you want to write your own calendar/notifications widget in Connect IQ, I guess you'd have to talk to the Google Calendar API using the CIQ Communications module.

  • I'm going to write my own version. Thanks for some clue. 

  • I managed to write some code, but still it doesnt working. 

    using Toybox.Communications;
    using Toybox.System;
    const CLIENT_ID = ********
    const OAUTH_CODE = "">accounts.google.com/.../auth";
    const OAUTH_ERROR = "access_denied";

    // the OAuth service can now be used with a makeWebRequest() call
    // register a callback to capture results from OAuth requests
    Communications.registerForOAuthMessages(method(:onOAuthMessage));



    // wrap the OAuth request in a function
    function getOAuthToken() {
       status = "Look at OAuth screen\n";
       Ui.requestUpdate();

       // set the makeOAuthRequest parameters
       var params = {
           "scope" => Comm.encodeURL("">www.googleapis.com/.../calendar.readonly"),
           "redirect_uri" =>  "">oauth2.googleapis.com/token",
           "response_type" => "code",
           "client_id" => $.CLIENT_ID
       };

       // makeOAuthRequest triggers login prompt on mobile device.
       // "responseCode" and "responseError" are the parameters passed
       // to the resultUrl. Check the oauth provider's documentation
       // to determine the correct strings to use.
       Comm.makeOAuthRequest(
           params,
           Comm.OAUTH_RESULT_TYPE_URL,
           {"responseCode" => $.OAUTH_CODE, "responseError" => $.OAUTH_ERROR}
       );
    }

    // implement the OAuth callback method
    function onOAuthMessage(message) {
        if (message.data != null) {
            var code = message.data[$.OAUTH_CODE];
            var error = message.data[$.OAUTH_ERROR];
        } else {
            // return an error
        }
    }
  • Also created google api project for my account

  • I think it is no longer a case since, there is a quide on google calendar api for python, java, js and other languates with given code examples. 

    I got en error: extraneous input 'Communications' expecting {<EOF>, 'class', 'module', 'using', 'import', 'alias',

    It refers to this line of code:
    Communications.registerForOAuthMessages(method(:onOAuthMessage));
  • Understand this is a different environment where the Garmin doesn't interact directly with google, but the phone is in the middle as a proxy.  If I recall, the change back in 2016 was for security reasons and proxies. I know of a google calendar widget that was removed at the time for this reason.

    Search the bug reports and discussion forum for things like google keep/notes, gmail, calendar etc.

  • I got en error: extraneous input 'Communications' expecting {<EOF>, 'class', 'module', 'using', 'import', 'alias',

    It refers to this line of code:
    Communications.registerForOAuthMessages(method(:onOAuthMessage));

    That’s because you can’t write code outside of functions in Monkey C (other than declarations). It’s not like python or javascript in that sense.

    Even if you put that code in a function, it’s not going to run on a device unless it’s part of a proper project. I don’t know what the rest of the code looks like, but in your case, you may want to create a new project using the command palette: “Monkey C: New Project” > Watch App or Widget. I assume you must have some project structure for the compiler to even get that far, but it’s not clear to me what it is, based on your post.

    You can also look at some of the SDK samples (“Monkey C: Open Samples Folder”), such as the Comm sample.