如何在 Flutter 应用程序中有效地使用 HealthKit 的计步功能?
How can I efficiently use HealthKit's step count functionality within a Flutter app?
我正在研究我必须为我们的初创公司构建的应用程序。
我想在 iOS.
上使用 HealthKit 构建一个应用程序来记录一个人每天走的步数
当用户请求刷新或重启应用时,我可以请求最新可用的步数。但是,我们希望在用户完成一定数量的步数(例如 10,000)后立即向用户推送通知。
所以我想知道我是否可以在 flutter 中设置一个监听器,这样 HealthKit 就会(电池有效地)提供最新的步数,因为他们进来或在一组 value/interval.
这种 'listener' 架构在 Flutter 和本机 Swift 代码之间进行通信是否可以通过 Flutter 实现?如果可以,这是最好的方法吗?
Android 那边也可以这样吗?
感谢您的关注。
也许 HealthKit's or HKObserverQuery 是您在 iOS 方面所需要的
Receiving Background Deliveries
Apps can also register to receive updates while in the background by
calling the HealthKit store’s
enableBackgroundDelivery(for:frequency:withCompletion:) method. This
method registers your app for background notifications. HealthKit
wakes your app whenever new samples of the specified type are saved to
the store. Your app is called at most once per time period defined by
the frequency you specified when registering.
至于架构
communicates between flutter and native Swift code ... Is the same
also possible on the Android
我相信您正在寻找 Flutter Platform Channels where you can find a Swift Example。
Flutter uses a flexible system that allows you to call
platform-specific APIs whether available in Java or Kotlin code on
Android, or in ObjectiveC or Swift code on iOS.
Flutter’s platform-specific API support does not rely on code
generation, but rather on a flexible message passing style:
The Flutter portion of your app sends messages to its host, the iOS or
Android portion of your app, over a platform channel.
The host listens on the platform channel, and receives the message. It
then calls into any number of platform-specific APIs – using the
native programming language – and sends back a response to the client,
the Flutter portion of your app.
不幸的是,我没有看到任何 existing Flutter HealthKit 但希望可用的工具足以让您为 HealthKit 构建自己的桥梁。
Brandon Donnelson 在 Creating a Plugin 上的视频也可能有所帮助。
我不确定是否有 HealthKit 替代 Android。
我正在研究我必须为我们的初创公司构建的应用程序。
我想在 iOS.
上使用 HealthKit 构建一个应用程序来记录一个人每天走的步数当用户请求刷新或重启应用时,我可以请求最新可用的步数。但是,我们希望在用户完成一定数量的步数(例如 10,000)后立即向用户推送通知。 所以我想知道我是否可以在 flutter 中设置一个监听器,这样 HealthKit 就会(电池有效地)提供最新的步数,因为他们进来或在一组 value/interval.
这种 'listener' 架构在 Flutter 和本机 Swift 代码之间进行通信是否可以通过 Flutter 实现?如果可以,这是最好的方法吗? Android 那边也可以这样吗?
感谢您的关注。
也许 HealthKit's or HKObserverQuery 是您在 iOS 方面所需要的
Receiving Background Deliveries
Apps can also register to receive updates while in the background by calling the HealthKit store’s enableBackgroundDelivery(for:frequency:withCompletion:) method. This method registers your app for background notifications. HealthKit wakes your app whenever new samples of the specified type are saved to the store. Your app is called at most once per time period defined by the frequency you specified when registering.
至于架构
communicates between flutter and native Swift code ... Is the same also possible on the Android
我相信您正在寻找 Flutter Platform Channels where you can find a Swift Example。
Flutter uses a flexible system that allows you to call platform-specific APIs whether available in Java or Kotlin code on Android, or in ObjectiveC or Swift code on iOS.
Flutter’s platform-specific API support does not rely on code generation, but rather on a flexible message passing style:
The Flutter portion of your app sends messages to its host, the iOS or Android portion of your app, over a platform channel.
The host listens on the platform channel, and receives the message. It then calls into any number of platform-specific APIs – using the native programming language – and sends back a response to the client, the Flutter portion of your app.
不幸的是,我没有看到任何 existing Flutter HealthKit 但希望可用的工具足以让您为 HealthKit 构建自己的桥梁。
Brandon Donnelson 在 Creating a Plugin 上的视频也可能有所帮助。
我不确定是否有 HealthKit 替代 Android。