How could I create an app that turns on the heart rate sensor when a switch is turned on?

Also if possible, could I have the heart rate sensor stay on in the background?

search github "WatchOS3 Heartrate"

How could I create an app that turns on the heart rate sensor when a switch is turned on?
 
 
Q