Question 1. When a new heart rate sample is added to the healthkit, I want to read this sample immediately even when the app is running in background by using notifications method.Is this really possible, reliably?
So far, I tried the background fetch method to query for new heart rate sample added to the heathkit. However, the fetch does not fire reliably and it is very inconsistent. Hence my app does not receive the new added data immediately or sometimes nothing at all. I tried both simulated version and also on a real hardware.Debugging is also a challenge.
Question 2: I want to read the heart rate in my app when the phone is locked. Is this possible? Many threads says it is not possible due to encryption of data during locked period. But these answers seems to be old threads. Are there any definite answer to such a vital question?
There are many numerous threads without any clarity at all.Apple documentation is garbage. Such hinderance does not encourage beginners like me. Any suggestions would be appreciated.
Related
Can we access the heart rate directly from the apple watch? I know this is a duplicate question, but no one has asked this in like 5 years. I know you can access it from the Health App but I'm not sure how "real-time" that will be.
If you don't expect 100% real-time.
You can use this one: HKAnchoredObjectQuery. I think it has a 300-500ms delay.
A query that returns changes to the HealthKit store, including a snapshot of new changes and continuous monitoring as a long-running query.
I have followed an example tutorial online for integrating in-app purchases in to my app. It is all working fine purchasing and unlocking the extra content. However, the notification that gets posted for confirming the purchase can take from 4-9 seconds to appear. This does not make for a very consistent user experience and makes the app appear slow.
Has anyone else had the same problem as this or know of a fix for it?
The long length of time and inconsistency is probably originating from the following:
When the user makes a purchase network messages will be sent to apples server - the length of time this will take will be inconsistent depending on the distance from the server, the amount of nodes the message passes through and the quality of the connections you are using.
When the message reaches apples server it will need to be processed and a response generated - the length of this time will be inconsistent depending on the load currently affecting the server.
A confirmation then will be transmitted back over the network - same rules apply as for the outgoing message.
The device upon receiving the confirmation will display the alert to the user.
Unless you are able to make changes to the network which the message travels upon or can improve apples servers response times you will not be able to reduce the time or inconsistency.
A "solution" would be to display an activity indicator with a helpful message to the user explaining what is happening, if you plan on doing this recommend the following utility DSActivityView. Its easy to use and quick to hook up and has been useful for me when faced with similar problems.
Is it possible to have an App (running iOS4 on hardware supporting multi-tasking) which starts on iPhone startup and then regularly checks for online updates (every 15 minutes) and then refresh the badge, so the user can see how many unread items there are with-out having a push-server?
I was hoping this would be possible with iOS4 Programming Guide seems to suggest it is only possible to to this regarding Locations tracking, VoIP and playing background audio. There is also the possibility to do local-push notifications, but I don't see to find how to trigger a specific function that way.
Thanks in advance for any help!
edit:
Just having read a bit more, if the application is in the background/inactive state, and I son want to update the badge-number without displaying a message, is there an action triggered like didReceiveLocalNotification? There must be a way to schedule something on a regular basis (like email checking) without having to implement a full server-push-nitification system!
Is it possible to have an App ... which starts on iPhone startup and then regularly checks for online updates (every 15 minutes) and then refresh the badge
As you already figured out, the answer is no.
I need to develop an enterprise app that monitors the network traffic. Basically it detects if the user is in wi-fi or cellular data and save the amount of bytes was sent and received in a period of time.
I saw an App at the AppStore that do exactly this job.
Detecting wi-fi or cellular data is quite simple using the Reachability Sample provided by Apple.
My problem is to keep monitoring the bytes sent and received while the app is in background.
As it is an enterprise App, I used UIBackgroundModes "voip" to avoid the app to be terminated.
I also installed the setKeepAliveTimeout method and I'm able to see the logs each 10 minutes, BUT only for 10 seconds after the method runs. I mean, setKeepAliveTimeout brings my App to run a Timer for 10 seconds each 1o minutes.
I'm thinking wether or not a task in background is the best solution for my problem.
I'll appreciate any comments.
EDIT: Ok guys. Thats the perfect way to do it.
First of all you must read this:
http://www.christian-fries.de/blog/files/tag-ios.html
I tried this and it works really fine.
All we need to do is to create a second thread detached from the main one. This way we have a continuos threading running forever. You must see the GCD docs at Apple's website also.
Second thing you should consider for an enterprise App is to set it up as a voip App, this way iOS will put your App running even after a reboot. It's a special behavior iOS has to keep voip Apps running.
Thats it guys.
I hope it can help you.
We dont have access to this data. There is no way to measure traffic.
The app you saw made an estimation (eg. 1mb/min) and after applicationWillEnterForeground. then you calc time x estimated-traffic and there we go.
Unfortunately there is no way to measure,
so I did a traffic-reset in settings and then i streamed exactly 1 min music. after a few repetitions I had my results. The problem is, that this works only fine with static traffic-processes like audio or video.
hope could help
endo
EDIT: look answer below!
I'm looking for the answer to my question but it's quite difficult for me. I would like to keep connected to the server in background sending location of the iphone with ios4.
I`m really sad because I think that multitasking of apple is not real multitasking, in fact they only keep the state of the app but they don't allow it to run in background.
May be somebody knows if is possible to send a call by http every 30 or 60 minutes...
Please, any help would be very appreciated. Thanks in advance
Depends on it you are looking to track the user -- like Grindr does (this is not bad, per se, it just must be disclosed to the user -- and PLEASE remember to power down the GPS equipment if you really do not need to do this at certain times).
You are able to register for several different types of "location" registrations, wake up (enough to do something with that information) and wait until the next update.
Look at Multitasking under "Receiving Location Events in the Background". It will give you all the info you need. Short answer: iOS4 may not support what you think you need for this, but it, in fact, does support everything required to do what you are asking.
link text (Membership required)
I know this is an old question, but below is a relevant statement from the Core Location documentation regarding background handling of "significant location change":
Because your application is in the
background, it should do minimal work
and avoid any tasks (such as querying
the network) that might prevent it
from returning before the allocated
time expires. If it does not, your
application may be terminated.
link to documentation containing quote
I'm not sure if the quoted statement is saying to avoid all network "queries", but I think a quick POST of the location should be fine.
I did this but my app got rejected due to this last week. I used the ios5 SDK.
There's a good answer to this question by user RedBlueThing here.
The answer is basically yes, you can process network requests, but you might need to ask the OS for more time to accomplish the task.