You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
In the example above, there is a call of **preferredUnits** function. You can provide identifiers to get preferred units for them and eventually receive properly calculated values from queries. The units will be chosen automatically based on you current localization. This is only required for **QuantityTypes**. If you will try to provide invalid unit for a type, you will get an error.
@@ -214,18 +227,23 @@ Try simple **observerQuery** to get notifications if something is changed.
214
227
This call is a subscription for EventChannel of the plugin, so don't forget to cancel it as soon as you don't need it anymore.
215
228
216
229
```dart
217
-
void observerQuery() async {
218
-
final identifier = QuantityType.stepCount.identifier;
219
-
final sub = HealthKitReporter.observerQuery(identifier, _predicate,
220
-
onUpdate: (identifier) async {
230
+
Future<void> observerQuery() async {
231
+
final identifier = QuantityType.stepCount.identifier;
232
+
final sub = HealthKitReporter.observerQuery(
233
+
[identifier],
234
+
_predicate,
235
+
onUpdate: (identifier) async {
221
236
print('Updates for observerQuerySub');
222
237
print(identifier);
223
-
});
224
-
print('observerQuerySub: $sub');
225
-
final isSet = await HealthKitReporter.enableBackgroundDelivery(
226
-
identifier, UpdateFrequency.immediate);
227
-
print('enableBackgroundDelivery: $isSet');
228
-
}
238
+
},
239
+
);
240
+
print('observerQuerySub: $sub');
241
+
final isSet = await HealthKitReporter.enableBackgroundDelivery(
242
+
identifier,
243
+
UpdateFrequency.immediate,
244
+
);
245
+
print('enableBackgroundDelivery: $isSet');
246
+
}
229
247
```
230
248
231
249
According to [Observing Query](https://developer.apple.com/documentation/healthkit/hkobserverquery) and [Background Delivery](https://developer.apple.com/documentation/healthkit/hkhealthstore/1614175-enablebackgrounddelivery)
0 commit comments