I build my own SIP app based on Linphone SDK.
When I make an outgoing call, then after 30 seconds of the call I get these messages:
[BackgroundTask] Background Task 7 ("Liblinphone cpu lock"), was created over 30 seconds ago. In applications running in the background, this creates a risk of termination. Remember to call UIApplication.endBackgroundTask(_:) for your task in a timely manner to avoid this.
[BackgroundTask] Background Task 10 ("belle-sip transaction(0x280e88410)"), was created over 30 seconds ago. In applications running in the background, this creates a risk of termination. Remember to call UIApplication.endBackgroundTask(_:) for your task in a timely manner to avoid this.
Then the App crash after 30 seconds or sometimes after up to max 4 minutes of having an outgoing call active. This crash also happens if my app is only ringing for more then 30 seconds when I try to make an outgoing call.
When the crash happens, then the app is NOT in background. The app is just in foreground during an outgoing all.
The app is build with Swift 5.0 and iOS target version 13.0
Related
This question already has an answer here:
make timer run on background iOS for more than 3 minutes
(1 answer)
Closed 3 years ago.
I have a requirement as below:
On tapping a button on a view ,a timer should be activated for 5 minutes.And timer should continue it's execution if the application is moved to background and if the application is killed from background.Please help.
That is not possible. Apps get suspended shortly after they are swapped out for another app (A suspended app is still in memory but does not get CPU time.) Once suspended an app can be terminated at any time without warning.
You can request background time, but you are limited to 3 minutes. Only a few types of applications (e.g. music players and turn-by-turn navigation apps) are allowed to run continuously.
If you need your app to be notified at some future time, you should consider creating a local notification with a future "fire date". That will wake up your app and give it a chance to respond (assuming the user taps the notification to send it to your app.)
For example, find the location and upload it to a server.
I need find the user location when the app is closed and upload it to my server.
This can be done in iOS 6.x and below
Invoke the beginBackgroundTaskWithExpirationHandler method of the UIApplication class when the app is first backgrounded.
This will grant your app an additional 10 minutes of time
Before that 10 minutes expires, temporarily enable fine-grained location updates using startUpdatingLocation and then request more time using the beginBackgroundTaskWithExpirationHandler method.
The temporary enabling of location updates magically resets the 10 minute background grace period. The app can therefore periodically renew its ‘lease’ before it expires and keep running in the background indefinitely.
below is a detailed walkthrough:
http://gooddevbaddev.wordpress.com/2013/10/22/ios-7-running-location-based-apps-in-the-background/
Apple has provided certain services which can run in the background for 10 minutes, but what if I have to perform some other task like downloading a file ... how much time limit do I get for it
Before iOS 7 you could request up to 10 minutes of background time (via beginBackgroundTaskWithExpirationHandler:) or you could use any of the background modes available at the time (such as location, voip, etc).
VoIP handler, for instance, will be called at most every 10 minutes and will give up to 3 minutes of background time IIRC.
With iOS 7 you can download and upload files out-of-process, without your app running. Please check documentation on NSURLSession and NSURLSessionConfiguration.
You can do it (directly after your app went to the background, that is, not let's say an hour later), and you approx. do have 10 minutes, although that is not guaranteed. See here in the apple documentation:
https://developer.apple.com/library/ios/documentation/iphone/conceptual/iphoneosprogrammingguide/ManagingYourApplicationsFlow/ManagingYourApplicationsFlow.html#//apple_ref/doc/uid/TP40007072-CH4-SW20
You can request a Executing a Finite-Length Task in the Background
which will run in background for maximum 10 min. This should be long enough to download file.
So no it is not just for certain services, you can get your app running the background for a longer period of time if your app is a VOIP app, track user location, playing audio or your app is app for an external accessories.
I've integrated Google Analytics iOS SDK in my iOS App, I want to set a long dispatch interval to avoid frequent network calls. I want to set 6 hours or longer interval.
// set Google Analytics dispatch interval, eg: 20 seconds
[GAI sharedInstance].dispatchInterval = 6*60*60; // dispatch after every 6 hours
I have few queries:
Q1. What will happen if App is killed just before the data is dispatched, will data be sent immediately when app is launched next time? (eg: app killed just few minutes before the dispatch interval).
Q2. Let's suppose app tries to dispatch data after 6 hours but network is not available at that time. will data be dispatched again after next 6 hours as aggregate of 12 hours data?
Any suggestion for optimised approach? I don't want to consume network bandwidth after every few seconds or minutes just for minor data.
dispatchInterval default is 120 (2 min).
Did you send a lot of datas? If you have vital datas, I suggest to keep it as 120(or better). As it use very minimal bandwidth.
If you are offline, the data will be sent when you are online again. (use event to test it easily in your app)
According to Google.:
Data collected using the Google Analytics SDK for iOS is stored locally before being dispatched on a separate thread to Google Analytics.
If a user loses network access or quits your app while there are still hits waiting to be dispatched, those hits are persisted in local storage. They will be dispatched the next time your app is running and dispatch is called.
More info here: https://developers.google.com/analytics/devguides/collection/ios/v3/dispatch
I'm developing iOS application that should do some background work with specific interval (30-3600 seconds) so ideally I'm need infinite background execution for my app. I'm using "update 1" solution from this answer but there is one problem.
I'm using setKeepAliveTimeout:600 handler: to register keep-alive handler in application: didFinishLaunchingWithOptions: delegate method and;
Calling beginBackgroundTaskWithExpirationHandler:;
Moving app to background. Everything is fine. Timers are firing, work in progress, backgroundTimeRemaining says i have ~600 seconds;
After 600 second app is suspended;
After few seconds keep-alive handler calling and requesting background execution again. But this time backgroundTimeRemaining says i only have about 50 seconds;
After 50 seconds the application is suspended again;
~550 seconds suspend;
GOTO 5.
I'm testing my app on iPhone 3GS with latest version OS (6.1.3).
So the question is why I'm getting only about 50 seconds after second time call for beginBackgroundTaskWithExpirationHandler:?
Is there any other way to do some work with short-time interval (e.g. 30 seconds) in background on iOS?
PS: Application I'm developing is for in-company usage, so I don't care about rejecting it by Apple.