How to test Complication Subscriber and Publisher in the simulation

Hi, me again. Playing with complications now. I added a Complication Publisher code to one of my app and modified the sample https://forums.garmin.com/developer/connect-iq/f/discussion/315443/here-are-a-few-complication-samples app to subscribe to the complication.

My app does publish and it is seen by the sample app through this code snippet

var complicationId = iter.next();
while (complicationId != null) {
    System.println(complicationId.longLabel.toString());
    complicationId = iter.next();
}

but I get an "Exception: The target complication was not found" when in the sample app I try subscribe to its updates, Which I presume is because my app isn't running in the simulator while the sample app is running. If it's the case, how to get two apps running at the same time?

Thanks.

  • Make sure you are simulating a device with complications, and in the sim you can use Simulation>Complications to make sure you are publishing correctly:  This is one of my "widgets" that publishes on a fr965.  The background service runs every 15 minutes and publishes when it gets data and akso publishes when the glance view or main view opens.


    Without closing the sim, run the watch face you are using to use the complication.  While searching, look for COMPLICATION_TYPE_INVALID.  That's a CIQ publisher, then look for a specific longLabel and subscribe.

    It's showing what was last published.  Also, because of the background service publishing, the watch face will update every 15 minutes without touching the sim.

    I tend you use the same device for the publisher and watch face in the sim, but switching the watch face to the fenix7x and not restarting the "widget" works.

    Make sure you are using devices that handle complications

    if the publisher isn't running or hasn't published yet, the test watch face I have shows this:

      

    same if I use a target for the Watch face that doesn't support complications

  • Ok, got further but stuck again.

    I got the sample watch face to show my complication data (instead of the hearth rate) through the simulator so I know it's subscribed to my publishing. This is working well. I'm having an issue with its onPress code.

    If I leave it 'as is', it doesn't work because the complicationId id is 0 and the code checks for > 0. Fixed that by returning -1 if not found and accepting >= 0 instead. Still not working. I get

    Error: Unhandled Exception
    Exception: Invalid complication id to launch

    So I changed the Id to 100 in my app for Complications.updateComplication.

    and found that this Id is passed in the mIndex property of the complicationId but can't access it directly.

    With myComplicationId being what is returned by iter.next(),

    var index = myComplicationId.complicationId.mIndex;

    Creates a
    Error: Symbol Not Found Error
    Details: Could not find symbol 'mIndex'

    How do I get that mIndex value out of there?

    I also found that I need to subscribe to update like this, which I find is weird (but works nonetheless)

    Complications.subscribeToUpdates(myComplicationId.complicationId);

    So for the time being, in the onPress function, I've hardcoded the id like such

    Complications.exitTo(new Complications.Id(100));

    and it seems it wants to launch, I get no exceptions but the watch face simply closes without any warning or error and without launching or indicating it wants to launch the app. Is this the expected behavior in the simulator or am I doing something wrong?

  • When you are looking for a CIQ Published comp, you probably have something like this:

                if(ty==Complications.COMPLICATION_TYPE_INVALID) {
                    if(complicationId.longLabel.equals(names[MySettings.comp])) {
                        compCIQ=complicationId.complicationId;
                    }  
                }

    then in your input delegate, use compCIQ from the view


        function onPress(evt) {
            Complications.exitTo(view.compCIQ);
            return true;
        }

  • First, thank you for the time you're taking to help me on this. I can now launch the App from within the watch face. And again, this brings more questions...

    1. While the watch face is running. when I simulate a background temporal event for the app, I can see the App output appearing in the Debug Console, but once exitTo is called and the wtach face switches to the Glance, nothing appears in the Debug Console anymore. Is there something I can set so they do show up? Otherwise it's hard to debug.

    2. Is it possible to launch to the Main view instead of the Glance from the watch face?

    Thanks again.

  • Things might make more sense if you run on a real device.  Let temporal events occur "naturally" in the sim.

    With a CIQ "widget" publisher in the sim, onPress starts with the glance - a known issue and has been reported - but on a real device, you go to the full screen and not the glance

  • Ok thanks, I'll try it on my Venu2.

  • One more question, lol

    Currently, I have a resources-venu2 directory where I put the complication.xml file in so it doesn't stop on error on watches that doesn't support complications at compile time. Beside doing the same for every other watches that support complications, is there a better way to bunch all of them together?

  • I have the xml for complications in it's own folder, and then with jungles include that directory for devices that support complications,  Like this:

    #forerunner
    fr255.resourcePath= resources;resources-basic;resources-comp
    fr255m.resourcePath=resources;resources-basic;resources-comp
    fr255s.resourcePath=resources;resources-basic;resources-comp
    fr955.resourcePath= resources;resources-basic;resources-comp
    
    fr265.resourcePath= resources;resources-basic;resources-comp
    fr265s.resourcePath=resources;resources-basic;resources-comp
    fr965.resourcePath= resources;resources-basic;resources-comp

  • Thanks, that seems much simpler.

    BTW, just tried in the real watch and it's working great. Thanks again for your help.