This is an example app. Replace the files Xcode generated with the three below at path ios/CarpWatch Watch App/.

CarpWatchSensorController.swift

This contains four main parts:
Activates the WCSession, restores whether sampling was running when the app was last closed, sets the chunk format, asks the phone for settings, and resumes sampling if it was running.The columnar chunk format is 3–5× smaller than row-oriented JSON, which directly reduces radio time on both devices.
Maps the keys the phone sends onto the AWARE sensor configurations. AWARE itself applies label, db_host and debug to every registered sensor; everything else is applied here, because only the watch app knows which sensors existSee Settings Sent to the Watch.
Builds the set of enabled sensors, requests HealthKit authorization if heart rate is among them, and starts the background session chosen by the phone
Runs on a timer at fileTransferInterval, and whenever the app goes to the background. WCSession.transferFile queues the files, so this works even when the phone is out of range
CarpWatchSensorController.swift

CarpWatchApp.swift

CarpWatchApp.swift
On watchOS 9 and earlier, onChange(of:) takes a single-parameter closure: .onChange(of: scenePhase) { phase in ... }.

ContentView.swift

ContentView.swift

Custom settings

Say your study needs a sensor threshold the package does not expose. You can add a custom setting by:
1

From Dart

Add the key in AppleWatchDevice.toWatchSettings(). Keys the native AppleWatchSensor.Config does not recognise are forwarded to the watch verbatim.
2

Read it on the watch

Pick it up in apply(settings:) and apply it to the relevant sensor configuration.

Next step

Build and verify