notificationCount and alarmCount not working for me

Former Member
Former Member
I have updated to v1.2.1, and I have loaded other people's watchface apps that utilize these functions (which do work) to my watch, but cannot seem to get them to work in my watchface application (simulator or watch).

I have this in the onUpdate(dc) function:
var AC = (Sys.getDeviceSettings() has :alarmCount ) ? true : false;
Sys.println ("AC:" + AC.toString());

var NC = (Sys.getDeviceSettings() has :notificationCount ) ? true : false;
Sys.println ("NC:" + NC.toString());

var PC = (Sys.getDeviceSettings() has :phoneConnected ) ? true : false;
Sys.println ("PC:" + PC.toString());

And it returns:
false
false
true
no matter the watch type selected in the simulator. On the watch itself, it doesn't work either (I have different code for that). I have tried various permissions, and configurations, but I am stuck.

Can someone throw me a rescue line here?

Thanks,
Steve
  • What if you use fully qualified names?

    var hasNotificationCount = false;
    if (Toybox.System.getDeviceSettings() has :notificationCount) {
    hasNotificationCount = true;
    }
  • Ok, you're looking at the stuff to see if it exists in the running VM, and not checking to see if it's non zero. You're running the 1.2.1 version of the SDK on your computer, right? With the 1.1.4 (or older) SDK, alarmCount and notifcationCount don't exist.

    Here's how I do it:

    in initialize(), I check to see if the device is running a 1.2.0 or greater version of Connect IQ: (alarmCount was new in 1.2.0 so I see if it's available)

    CIQ12x=(Sys.getDeviceSettings() has :alarmCount ) ? true : false;
    (if you don't use this, your watchface will crash on a devices that has an older version of CIQ)

    Then in onUpdate() I have the following: (where I have "var settings=Sys.getDeviceSettings();" )
    if(CIQ12x) {
    if(settings.alarmCount>0) {
    //display alarm icon/count here
    }
    if(settings.notificationCount>0) {
    //display notifcation icon/count here
    }
    }
    // as phoneConnected was in earlier VM's, this doesn't need to be in the above "if"
    if(settings.phoneConnected) {
    //display BT icon here
    }
  • Former Member
    Former Member
    I'm sorry, but that did not work (Petr). Any other thoughts? I pay a penny a thought.

    Trying jim's....
  • I'm sorry, but that did not work (Petr). Any other thoughts? I pay a penny a thought.

    Trying jim's....


    Are you running the 1.2.1 version of the SDK on your computer? (not just 1.2.1 on your watch) alarmCount and notifcationCount didn't exist before that.
  • Former Member
    Former Member
    I tried jim's suggestion, and have the test checked on initialize. It returns false.
    I'm not sure why it is not working.

    I did a project clean, build, and no success.

    I made a new watchface project from scratch, and not working.

    Is there something in the manifest or other location I need to modify?

    Thanks!
  • Did you set the latest CIQ SDK 1.2.1 in the Eclipse?
  • Former Member
    Former Member
    Yes, I have the v1.2.1:



    Any other ideas? I appreciate the assistance.
  • And what you have set in Window > Preferences > Connect IQ > SDK Root directory?

    These things you posted in the screenshot are just 1.2.1 plugins for Eclipse. But you need a 1.2.1 SDK as well. http://developer.garmin.com/connect-iq/sdk/
  • Former Member
    Former Member
    You might be on to something. I originally installed everything to C:\Connect_IQ, which is where it currently points. Maybe the update went to the default location that is elsewhere? What do you have in there, so I know what the default should be? I can scan my hard drive as well.
    Thanks!
  • You might be on to something. I originally installed everything to C:\Connect_IQ, which is where it currently points. Maybe the update went to the default location that is elsewhere? What do you have in there, so I know what the default should be? I can scan my hard drive as well.
    Thanks!


    If you use eclipse (you have the plugins so I guess you do), under the Connect IQ menu, there is "open SDK manager". Using that, you can update the SDK to 1.2.1.

    If you have the 1.2.1 SDK already someplace on your computer, do as Petr suggested, and just point to the 1.2.1 SDK tree.