iOS Swift - Prevent OS from killing app in background mode? - ios

I've created an app that takes in bluetooth data from a local device and uploads it to a database. I'd like to be able to keep doing this indefinitely when the app is pushed to the background or if the phone is put into lock/sleep mode.
I've edited Plist info to allow CoreBlueTooth and network content to be enabled while in background mode. Using this and a couple memory saving tweaks for when the app gets pushed into the background, I'm able to hit just under 4 hours of operation when the app is pushed to background and the phone is put to lock/sleep. However, after 4 hours the phone seems to automatically terminate the app completely (while being at over 80% battery life).
Is there any way to prevent iOS from terminating suspended apps and ensure that they run indefinitely (until battery runs out)?
Thanks!

Related

why my Ios App is killed by OS in background mode?

hi i have an iOS app that runs perfectly in when i run it through Xcode on my iPhone.when i press the home button and lock the screen, the app keeps recording the data.after 1 or 2 hours when i unlock screen it is still recording data and works perfectly.but when i stop the app , unplug my phone and run the installed app directly through app icon on my iPhone it is killed by the os after a few seconds in lock screen.i have already asked similar question but couldn't find any help.if someone could download the source code and have a look at it it will be very nice of him/her.Thank you
why my Ios App is killed by OS in background mode?
The OS won't allow apps to run for long periods in the background in order to save power. There are exceptions — you can tell the OS that your app needs to run in the background for one of several reasons such as playing music in the background. There are also some facilities for waking up your app in the background to do some processing -- for example, your app can be notified when the location changes.

IOS App suspended automatically

I have a problem in my release iOS app...
When i use my app and through all of feature (Like to another view in my app etc) in my app and then i click home button in ios to switch in to another app then i switch back to my app. My latest state (View) still exist. However, when i switch in to another app for a while, my app restarting from splash screen.
Another problem when i am trying to detect the problem in my ios simulator, the problem i have in the release app could not appear in my ios simulator.
Any people here could give me a solution to fix my problem ?
If the problem i have in memory usage, how many memory usage can be tolerated by IOS system ? and how can i know from ios simulator that memory usage is greater than the limit ?
additional info : my iOS app is based on objective-c and mixing with swift code. I use XCODE 8 and my app not using background service like download video, music, and etc. However, i use nsurlsession to fetch data from server and using data from server to load image from server. I use sdwebimage to handle image.
I hope this picture can give another insight about my app. This picture i take when my position in home of IOS, not in my app
It probably is memory usage. The job of the WatchDog process is to look for suspended memory hogs and kill them. You appear to be one.
You can readily see in Xcode how much memory you were using when you went into the background. How much was it? If it's a lot, don't do that. It's your job to release as much memory as you can when you go into the background, for this very reason.
However, your app can never hope to live forever — sooner or later, it will be killed in the background — so another responsibility you have is to save its state and, if you are launched from scratch, restore that state. That's just how iOS works.

iOS9 reports app background usage when app is not running in the background

We have an app that has UIBackgroundModes set to Audio because it offers streaming of audio inside the app. I have used the app over a period of 6 days and never used the streaming part but still iOS reports the app as having 1 hour of background usage and 3,2 hours on screen.
Is there any reason why the app would continue in the background if the audio is not active? I thought it would only do so if we actually played audio. When testing the app in debugger I don't see any activity after pressing the home button so it seems suspended to me but iOS9 seems to think otherwise.
with the BG mode, your app runs in the BG as long as it isn't killed by the user

IOS app background to foreground

I am working in an ios app,that runs in background mode. How should I fetch the app from background to foreground when the battery percentage change?
Apple will not let you do that with its public APIs. If anything you could maybe read up on this and run some background code.
Besides, with this application, I guess you would be waiting until the battery runs low, which may take a long time. This the device will terminate the application (and you can't even do anything).

Launch app from background service

I've developed Android app which has a background service in the sleep mode. This service works with accelerometer data and can launch the app from the sleep mode over the lock screen.
Is it possible to make the same on iOS?
I mean:
Create a service which can work in background with accelerometer data.
Service can launch the app when the phone is in the sleep mode over lock screen. (without unlocking)
If I'm not mistaken it must be possible on iOS7, isn't it?
Thanks!
Yes – Apple publicly stated background processing at WWDC keynote and it can be done to a degree on iOS6
No – Apple will 'probably' never allow an app to be opened without the user instigating it and certainly not over the lock screen.
You could use Push / Local Notifications which do appear on the lock screen to try and entice a user at a specific time to launch the app but no guarantees.

Resources