ios - health kit observer query always called when the app becomes active -


the resulthandler of hkobserverquery called when app becomes active (background -> foreground)

but, wrote code of query in didfinishlaunchingwithoptions method in appdelegate.swift. know method called when app launched not app become active.

func application(application: uiapplication,     didfinishlaunchingwithoptions launchoptions: [nsobject: anyobject]?) -> bool {     healthstore.authorizehealthkit {         ...     } } // other appdelegate methods empty 

how make handler of query called when app launched?

why want prevent updatehandler firing?

you can't control when updatehandler of hkobserverquery fires while query running. can prevent being called @ stopping query. designed called whenever there might new healthkit data matching predicate. should design updatehandler such doesn't matter when called.

if wanted observer query not fire when app returns foreground, need stop query -[hkhealthstore stopquery:] when app enters background, before suspends.


Comments

Popular posts from this blog

javascript - Chart.js (Radar Chart) different scaleLineColor for each scaleLine -

apache - Error with PHP mail(): Multiple or malformed newlines found in additional_header -

java - Android – MapFragment overlay button shadow, just like MyLocation button -