5 Replies
      Latest reply on Jan 16, 2020 2:27 PM by OCS1
      OCS1 Level 1 Level 1 (0 points)

        Ladies and gentlemen,

         

        one of my clients would like an iOS application, which would allow him to control his HomeKit devices in a special way, and which would keep active when the device is in its charging dock, continuously informing him of the current state.

         

        I can do most of the things desired, but there are two requirements which I can't find any way how to do:

        1. launch/activate my application automatically whenever the device is put to the dock (=starts charging)
        2. when in charger, launch/activate my application automatically whenever the device would normally sleep the screen.

         

        In other words, the client would want the special HK controller activates whenever the device is put to the charger, and also — only when in charger — whenever he stops using the device in the normal way for the idle interval (whilst, obviously, if not in charger, he wants the device to normally switch off the screen and lock).

         

        Is there any trick to do either of these two things or ideally both? Whatever I try, I can't find any. Thanks for any idea!

        • Re: De/activation of an app based on charging state?
          Claude31 Level 8 Level 8 (7,895 points)

          I understand you want to keep your app active when charging.

          Isn't it what iOS does when it updates iOS while charging ?

           

          Could this discussion help you ?

          https://discussions.apple.com/thread/8180364

            • Re: De/activation of an app based on charging state?
              OCS1 Level 1 Level 1 (0 points)

              Well thanks, but it's a bit more convoluted than that.

               

              He obviously does not want to switch the auto-lock completely off; that would clash seriously with the normal usage, when the iPhone is not charging (or he would have to remember to switch is always back on whenever he takes the iPhone from the dock, which is self-evidently absurd).

               

              The good news is that this is actually not needed at all! Once my application is active, it can both monitor the charging status (through the batteryState property) and, if the iPhone is being charged, it can easily keep the screen unlocked through idleTimerDisabled.

               

              The bad news is that to be able to do this, the app needs to be active. That's why I need a way to automatically launch/activate the application when the device is put into the charger — that's one thing whole solution I can't see :/

               

              (The other one is to make the app automatically launched/activated if the charging is in process, another app is active, and the idle timer strikes in: normally iPhone would switch off the display in this case, I need it again to activate my app.)

               

              Unless I am missing something of importance, that's all I need; all the other requirements I do know how to implement easily.