I’m building an app that gets Heart Rate and sends this to a web API. I can get the Heart Rate and send it to my Web API by opening the app on the device, however I need this to just run all the time on the device without having to open it. Or at least open it once and then let it run, is this possible, do I need to add something to allow the app to always run on the device? Thanks
Unfortunately Connect IQ does not have any background running features like what you describe. We do have heart rate history options in Activity Monitor and Sensor History that allows you to grab HR info over a certain amount of time. You are at the mercy of the HR sample frequency of the device though so I'm not sure if this is what you are looking for or not.
You can write an app (not a widget, but a full blown app) that collects heart rate data from the Sensor module and sends the data to your web service using the Communications module. If you wanted, you could make the Ui look like a watch face. The user would need to start your app, and it would stay active until the user quit the app (via whatever mechanism you provide).
Yes, with the app open and running all the time, having it look like a watchface could make it easier to use. Instead of just showing the data, a user can look at it and also see the typical things like time, battery level, icons, steps, etc.
Here's an example of where I did that with an app that displays the Temperature from a Tempe sensor:
An actual watch face is very limited in what it can do (it's all about the battery!), so for example, it only updates once per minute most of the time, and there's no access to sensors (Tempe or HRM for example), and it can't do comm. As far as HR, it can display the last reading done by the FW on devices with an OHRM (ActivityMonitor.getHeartRateHistory() is used, and you can see readings taken in 24/7 mode which are a few minutes apart)
I assume the app would need to be open and on the display to function, is that why you suggest a watch face?
To be very clear, I'm not suggesting you implement a watch face. I'm suggesting you create a WatchApp (a full blown app with access to the Communications and Sensor modules), but you make it look like a watch face so that users will be able to use their watch as a watch. There are several apps in the app store that do this, including Jim's Tempe app.
To do this, you'd implement an application (your initial view class would inherit from Ui.View). You might have a look at the code I posted in this thread for a start. It is a start for a base class to give a regular application some of the built-in functionality of a watch face (pseudo-low power mode, ...).
Building a watch app that looks like a watchface is used in a some items in the store. In Time and Tempe that I linked to, I run in "pseudo low power" where the screen only updates once a minute (the Tempe only reports Temperature every minute, so that's fine), but does include things I have standard in watchfaces (it actually uses shared "watchface" code for the icons, the colors, the move bar and the activity info, and includes things like app settings for the colors and other options.
In that case, the reason it can't be done as a watchface (it's probably about 95% "watchface code") is that I access Sensors to get the Tempe data.
But given that, it does consume more battery than a watchface - not much, but noticeable.
I have another watch-app with a main screen that again looks like a watchface and may be a bit closer to what you are looking to do (Simple Walk). It's actually a full blown app to record an outdoor walk. After getting a GPS lock and starting recording, the main screen includes a few extra "non watchface" items like activity time, activity distance, activity steps, and current heart rate (if a HRM is available). Also, this is a case where user input is used (the start/enter button and others). And in addition to the main screen, there are 3 other screens behind it with additional data (accessed with screen swipes or up/down button presses), with a default revert to the main screen after 5 minutes. In that case, I update the screen every second, but it's already a bit harder on the battery as it's using GPS.