kvs-coder/health_kit_reporter

Is it possible to listen to 2 (or more) anchoredObjectQuery?

quentinleguennec opened this issue · 6 comments

Describe the bug
When I try to call HealthKitReporter.anchoredObjectQuery twice (first time for WorkoutType.workoutType.identifier, second for CategoryType.sleepAnalysis.identifier) it seems to overwrite the first call with the second, so I cannot see updates to WorkoutType.workoutType.identifier, only those for CategoryType.sleepAnalysis.identifier.

I tried each one separately (i.e.test with WorkoutType.workoutType.identifier, then rebuild the app and test with CategoryType.sleepAnalysis.identifier) and they both work. But 2 together do not work.

Smartphone (please complete the following information):

  • Device: Iphone 8
  • OS: iOS 14

Additional context
[✓] Flutter (Channel stable, 2.5.2, on macOS 11.6 20G165 darwin-x64, locale en-GB)
[✓] Android toolchain - develop for Android devices (Android SDK version 29.0.2)
[✓] Xcode - develop for iOS and macOS

Hi @quentinleguennec

thank you for your message.

Indeed, I checked this. The problem is with the event channel names, since they are static strings. I found a solution, you can provide multiple identifiers to create an anchoredObjectQuery. Please check this in the version 1.5.1

Thanks @VictorKachalov

I didn't had the time to test the new version yet but I had a look at the code changes.
If I get it right anchoredObjectQuery now takes a list of identifiers, but if we call anchoredObjectQuery again with new values it wil still overwrite the previous listeners, right? (probably not an issue for me, just curious).

Hi @VictorKachalov

I just tried to use he new version 1.5.1 but I get a compile error preventing me to build:

Failed to build iOS app
Error output from Xcode build:
↳
    --- xcodebuild: WARNING: Using the first of multiple matching destinations:
    { platform:iOS, id:dvtdevice-DVTiPhonePlaceholder-iphoneos:placeholder, name:Any iOS Device }
    { platform:iOS Simulator, id:dvtdevice-DVTiOSDeviceSimulatorPlaceholder-iphonesimulator:placeholder, name:Any iOS Simulator Device }
    ** BUILD FAILED **


Xcode's output:
↳
    /Users/quentinleguennec/Dev/SDKs/flutter/.pub-cache/hosted/pub.dartlang.org/health_kit_reporter-1.5.1/ios/Classes/StatisticsCollectionQueryStreamHandler.swift:39:55: error: type 'PreferredUnit' has no member 'make'
                if let preferredUnit = try? PreferredUnit.make(from: preferredUnit) {
                                            ~~~~~~~~~~~~~ ^~~~
    /Users/quentinleguennec/Dev/SDKs/flutter/.pub-cache/hosted/pub.dartlang.org/health_kit_reporter-1.5.1/ios/Classes/SwiftHealthKitReporterPlugin.swift:822:92: warning: string interpolation produces a debug description for an optional value; did you mean to make this explicit?
                                    message: "Error in json encoding of beat by beat series: \(series)",
                                                                                          ^~~~~~
    /Users/quentinleguennec/Dev/SDKs/flutter/.pub-cache/hosted/pub.dartlang.org/health_kit_reporter-1.5.1/ios/Classes/SwiftHealthKitReporterPlugin.swift:822:92: note: use 'String(describing:)' to silence this warning
                                    message: "Error in json encoding of beat by beat series: \(series)",
                                                                                          ^~~~~~
                                                                                          String(describing:  )
    /Users/quentinleguennec/Dev/SDKs/flutter/.pub-cache/hosted/pub.dartlang.org/health_kit_reporter-1.5.1/ios/Classes/SwiftHealthKitReporterPlugin.swift:822:92: note: provide a default value to avoid this warning
                                    message: "Error in json encoding of beat by beat series: \(series)",
                                                                                          ^~~~~~
                                                                                          ?? <#default value#>
    Command CompileSwiftSources failed with a nonzero exit code
    remark: Incremental compilation has been disabled: it is not compatible with whole module optimization
    Command CompileSwiftSources failed with a nonzero exit code
    note: Using new build system
    note: Planning
    note: Build preparation complete
    note: Building targets in parallel
    /Users/quentinleguennec/Dev/FlutterProjects/Quantiome/quantiome-app/ios/Pods/Pods.xcodeproj: warning: The iOS deployment target 'IPHONEOS_DEPLOYMENT_TARGET' is set to 8.0, but the range of supported deployment target versions is 9.0 to 15.0.99. (in target 'Reachability' from project 'Pods')
    /Users/quentinleguennec/Dev/FlutterProjects/Quantiome/quantiome-app/ios/Pods/Pods.xcodeproj: warning: The iOS deployment target 'IPHONEOS_DEPLOYMENT_TARGET' is set to 8.0, but the range of supported deployment target versions is 9.0 to 15.0.99. (in target 'BoringSSL-GRPC' from project 'Pods')
    /Users/quentinleguennec/Dev/FlutterProjects/Quantiome/quantiome-app/ios/Pods/Pods.xcodeproj: warning: The iOS deployment target 'IPHONEOS_DEPLOYMENT_TARGET' is set to 8.0, but the range of supported deployment target versions is 9.0 to 15.0.99. (in target 'AppAuth' from project 'Pods')
    /Users/quentinleguennec/Dev/FlutterProjects/Quantiome/quantiome-app/ios/Pods/Pods.xcodeproj: warning: The iOS deployment target 'IPHONEOS_DEPLOYMENT_TARGET' is set to 8.0, but the range of supported deployment target versions is 9.0 to 15.0.99. (in target 'abseil' from project 'Pods')
    /Users/quentinleguennec/Dev/FlutterProjects/Quantiome/quantiome-app/ios/Pods/Pods.xcodeproj: warning: The iOS deployment target 'IPHONEOS_DEPLOYMENT_TARGET' is set to 8.0, but the range of supported deployment target versions is 9.0 to 15.0.99. (in target 'gRPC-Core' from project 'Pods')
    /Users/quentinleguennec/Dev/FlutterProjects/Quantiome/quantiome-app/ios/Pods/Pods.xcodeproj: warning: The iOS deployment target 'IPHONEOS_DEPLOYMENT_TARGET' is set to 8.0, but the range of supported deployment target versions is 9.0 to 15.0.99. (in target 'gRPC-C++' from project 'Pods')
    /Users/quentinleguennec/Dev/FlutterProjects/Quantiome/quantiome-app/ios/Pods/Pods.xcodeproj: warning: The iOS deployment target 'IPHONEOS_DEPLOYMENT_TARGET' is set to 8.0, but the range of supported deployment target versions is 9.0 to 15.0.99. (in target 'leveldb-library' from project 'Pods')
    /Users/quentinleguennec/Dev/FlutterProjects/Quantiome/quantiome-app/ios/Pods/Pods.xcodeproj: warning: The iOS deployment target 'IPHONEOS_DEPLOYMENT_TARGET' is set to 8.0, but the range of supported deployment target versions is 9.0 to 15.0.99. (in target 'gRPC-C++-gRPCCertificates-Cpp' from project 'Pods')
    /Users/quentinleguennec/Dev/FlutterProjects/Quantiome/quantiome-app/ios/Pods/Pods.xcodeproj: warning: The iOS deployment target 'IPHONEOS_DEPLOYMENT_TARGET' is set to 8.0, but the range of supported deployment target versions is 9.0 to 15.0.99. (in target 'GoogleSignIn' from project 'Pods')

Could not build the precompiled application for the device.

Error launching application on Quentin’s iPhone.

@quentinleguennec Hi,

have you tried to run pod update?

The new 1.5.1 version is build upon the latest original HealthKitReporter CocoaPod

@VictorKachalov That fixed it, thanks!

I've been testing 1.5.1 and it seems to work well, I'll close this issue.