The docs for the 4.2.0 Beta 1 SDK claim:
~/Library/Application Support/Garmin/ConnectIQ/Sdks/connectiq-sdk-mac-4.2.0.beta1-2022-10-11-bff57b73c/CoreTopics.html#subscribingtocomplications
Once you have the complication id, you can persist the id in storage for later use.
You can use
Complications.registerComplicationChangeCallback()to subscribe to multiple complication values. All subscriptions are terminated when your app shuts down and must be re-done when your app is launched. When you subscribe, you register a callback to be called when the value updates:function onStart(params as Dictionary) as Void { // Retrieve persisted Complication ID mComplicationId = Storage.getValue(COMPLICATION_ID_KEY); // Register a callback for receiving // updates on complication information Complications.registerComplicationChangeCallback( self.method(:onComplicationChanged)); // Liking and subscribing Complications.subscribeToUpdates(mComplicationId); }
But if I try to persist a Complications.Id to storage (whether it's an ID for a native complication or an ID for a CIQ complication), I get the following error:
Error: Unhandled Exception
Exception: UnexpectedTypeException: Given value cannot be serialized
e.g.
var complicationId = new Complications.Id(Complications.COMPLICATION_TYPE_BATTERY); Storage.setValue("foo", complicationId as PropertyValueType);
Furthermore, the above code won't compile without the "as PropertyValueType" cast (which is expected.) But if iterate through the installed complications using getComplications(), I can call Storage.setValue() on a Complications.Id obtained through iteration without any compilation problems (but the same run-time error is encountered.)
e.g.
var iter = Complications.getComplications(); var complication = iter.next();
while (complication != null) { System.println("short label: " + complication.shortLabel); System.println("long label: " + complication.longLabel); System.println("ID: " + complication.complicationId.toString()); Storage.setValue("abcd", complication1.complicationId); // compiles but crashes at run-time}