Coder Social home page Coder Social logo

Comments (8)

kvs-coder avatar kvs-coder commented on July 17, 2024 2

Hi @spiritinlife

According to the Apple Documentation related to background updates, the observing queries should be initilized in didFinishLaunchingWithOptions of AppDelegate file. This background delivery and observing queries combination will allow you to get notifications from Apple Health even if your app is killed. The idea is that whenever a new value appears/disappears in Apple Health, the observerQuery's update handler will be triggered, and the code you provide there will be executed. But, unfortunately this works only natively.

I am afraid there is no chance for now to do the same in Flutter part of the library, i.e put observation in "main" function.
Because events handling between the native part and the flutter part starts when the subscription is set on the flutter side.

Although the observer query will be still running when the app has "Not Running" lifecycle state, the stream subscription on the flutter side will be canceled when the app will be killed by the system.

I will try to adjust the explanation in README

from health_kit_reporter.

kvs-coder avatar kvs-coder commented on July 17, 2024

Btw, in order to see how ObserverQuery is actually working, you can check out a native example of the HealthKitReporter. It is the base library for this flutter wrapper

from health_kit_reporter.

kvs-coder avatar kvs-coder commented on July 17, 2024

I will also present some changes in event handling in new version

from health_kit_reporter.

spiritinlife avatar spiritinlife commented on July 17, 2024

@VictorKachalov thx for the quick response.

This library seems to be able to do it https://github.com/nanoglobal/nano_healthkit.
Also https://github.com/fluttercommunity/flutter_workmanager should be doing something similar.

from health_kit_reporter.

kvs-coder avatar kvs-coder commented on July 17, 2024

Ok, it appeared, that it was suppose to work all the time :) but was a lack of an appropriate Capability for background fetch and an argument exceptions in enabling background deliveries. You may try again. In the example app I added some local notifications, which should be triggered if some data changes. The version is 1.0.5 now.

from health_kit_reporter.

kvs-coder avatar kvs-coder commented on July 17, 2024

hi @spiritinlife

Have you already tried to use this package with observing queries on and while the app is in background/killed?

from health_kit_reporter.

spiritinlife avatar spiritinlife commented on July 17, 2024

from health_kit_reporter.

rologr35 avatar rologr35 commented on July 17, 2024

@VictorKachalov I've been testing ObserverQuery while the app is killed but I can't make it work properly. I already enable background capabilities and even init the observer as an isolated function in the main method of the app. I can say it was working a few times while the app is killed but after waiting some time it stops working properly. Thanks in advance

from health_kit_reporter.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.