Announcement

Collapse
No announcement yet.

Check for companionapp from Watchface

Collapse
X
  • Time
  • Show
Clear All
new posts

  • Check for companionapp from Watchface

    Hi!

    Is there a way to check if the companion app is installed on the phone from a watchface (or watchapp).
    Since a watchface can only communicate at most every 5mins (can this limit please be lifted for communication?) and i'm not sure that when showing the watchface it starts with communication (wether it runs the backgroundservice at the same time the watchface shows) I cannot send a simple message to the phone and wait for the answer to test if the companionapp is installed.
    (sorry for not quoting what I'm answering to but a moderator told me not to do it :/)

  • #2
    It's a limit for background temporal events. You can do comm from the main process in a watch-app, but in watchfaces, you can only do it from the background. It's all about the battery. (comm is not cheap battery wise so you don't want it happening too often) The background will run for up to 30 seconds when it runs, so you should be able to ping the phone app and get a response.

    Also, without extra logic, the background process likely won't run each time the watch face starts. If the background runs, and then you move to a widget, and then return to the WF right away, the background won't run again until the next time the temporal event triggers. And the background can also run when the WF isn't even being shown.
    My Connect IQ Apps in the Store
    Facebook - Instagram -
    Twitter

    Comment


    • #3
      So for now there's no reliable way to check for companion app from watchface -> Feature request!
      I know it is a limit for temporal events. Pebble managed to do at least 7 days battery life with no limit on watchfaces communication (you could communicate with the companion app whenever you wanted to).
      I'd really like to see lifting off that limit for communication. For my purposes I really don't want to communicate with the phone frequently(from the watchface), but when I want to I'd like to do it immediately and not waiting for at most 5mins. -> Feature request!
      (sorry for not quoting what I'm answering to but a moderator told me not to do it :/)

      Comment


      • #4
        What's more, I don't need a background service at all, I don't need anything to run after the watchface is closed/stopped/not shown. What I want is a way to communicate with the watchface when it is active. -> Feature request!
        (sorry for not quoting what I'm answering to but a moderator told me not to do it :/)

        Comment


        • #5
          You can control the temporal event so that it gets deleted when the watchface is exited. The background process then stops. I've not done exactly this in a WF, but I do have a setting to turn off backgrounding in a couple WFs. I do have a Df where I delete the temporal even when the DF exits though, and it's the same basic logic.
          My Connect IQ Apps in the Store
          Facebook - Instagram -
          Twitter

          Comment


          • #6
            I know. I'm just saying that there are use cases when there is no need for a background service, but there is a need for a watchface to communicate with a companion app whenever it wants to.
            For now the only way to do this in a watchface is background service. If they pull out the communication function from the background service and put it in the normal workflow, then there is no other need for the background service for my use case.
            (sorry for not quoting what I'm answering to but a moderator told me not to do it :/)

            Comment


            • #7
              Good day

              I have been through many posts on the and from what I understand, it is possible for a watch face to communicate with a companion app but only via the background process. I have tried to do this but with no success.

              This is my delegate:

              Code:
              using Toybox.Background;
              using Toybox.System;
              using Toybox.Position;
              using Toybox.Application as App;
              using Toybox.Communications;
              using Toybox.WatchUi;
              
              (:background)
              class BlackFaceServiceDelegate extends System.ServiceDelegate {
              
                  var strings = ["","","","",""];
                  var stringsSize = 5;
                  var message = new Communications.PhoneAppMessage();
              
                  function initialize() {
                      ServiceDelegate.initialize();
                  }
              
                  function onTemporalEvent() {
                      System.println("TEMPORAL EVENT");
                      Communications.registerForPhoneAppMessages(:onPhone);
                      System.println("TEMPORAL EVENT AFTER CALL");
                  }
              
                  function onPhone(msg) {
                      message = msg.data;
                      System.println("ON PHONE METHOD");
                      System.println("ON PHONE METHOD DATA " + msg);
                      System.println("ON PHONE METHOD COMPLETE DIC");
                      WatchUi.requestUpdate();
                      System.println("ON PHONE METHOD UI UPDATE");
                      System.println("ON PHONE METHOD EXIT");
                  }
              
              }
              This is my App:

              Code:
              using Toybox.Application as App;
              using Toybox.WatchUi as Ui;
              using Toybox.Background;
              
              class BlackFaceApp extends App.AppBase {
              
                  function initialize() {
                      AppBase.initialize();
                  }
              
                  // onStart() is called on application start up
                  function onStart(state) {
                  }
              
                  // onStop() is called when your application is exiting
                  function onStop(state) {
                  }
              
                  // Return the initial view of your application here
                  function getInitialView() {
                      Toybox.Background.registerForTemporalEvent(new Time.Duration(300));
                      return [ new BlackFaceView() ];
                  }
              
                  function getServiceDelegate() {
                      return [new BlackFaceServiceDelegate()];
                  }
              
                  // New app settings have been received so trigger a UI update
                  function onSettingsChanged() {
                      Ui.requestUpdate();
                  }
              }
              But when the event runs I always get a Cannot find symbol error - all permissions are set correctly but it always fails. I have checked the device and I can push the message from my companion app iOS and it is in the APPS/MAIL folder. I did some debugging and it seems to fail on Communications.registerForPhoneAppMessages(: onPhone); all the time. Do you have any advice on how I get this resolved please. I have been through the forums and all over the net with no success. Your help will be highly appreciated.

              Kind regards
              Ravind
              Last edited by Travis.ConnectIQ; Yesterday, 09:24 AM.

              Comment


              • #8
                The issue is that you are passing a Lang.Symbol (: onPhone) to registerForPhoneMessages(), but that function expects you provide a Lang.Method. The following *should* work.

                Code:
                Communications.registerForPhoneAppMessages(self.method(:onPhone));
                Last edited by Travis.ConnectIQ; Yesterday, 09:24 AM.

                Comment

                Working...
                X