Posts

Post not yet marked as solved
0 Replies
721 Views
My understanding is that when an app enters the background, the app will run for a period of time and eventually will be suspended, and while in the background can continue to run tasks. Then with no activity an app in the background will be suspended but remain in memory subject to the system purging it on low memory events. When the app is suspended it stops executing code. The user can terminate an app by swiping up from the Home Screen. When an app is suspended and purged or terminated by the user all objects including view controllers are removed from memory and cannot receive updates from the UIApplication object. An exception is region updates, which will be picked up by the appDelegate when the app is in the background, suspended or terminated, and will "activate" the app for processing the event. I also understand region objects are retained in memory regardless of the app's state. Thus on entering a region, the appDelegate can deal with the region entered in whatever state the app might be in. I'm working on an app that uses region monitoring. I have put the didEnterRegion and didExitRegion CLLocationManagerDelegate functions in the appDelegate, where I also set up and start location services. I have one MasterViewContoller for UI reporting enter/exit region activity and one NSObject class Comm that handles enter/exit events by sending off an http post. This Comm object is instantiated in the MasterviewController like this: let comm = Comm() and the MasterViewController is reference in appDelegate like this: var vc = MasterViewController() In appDelegate I have the didEnterRegion and didExitRegion functions: func locationManager(_ manager: CLLocationManager, didEnterRegion region: CLRegion) {       if region is CLCircularRegion { let identifier = region.identifier [NOTE: code here to issue a local notification for testing - this functions regardless of the app's state]           vc.processRegionEvent(regionid: identifier) comm.sendHttp(theid: identifier)       } } This works as expected so long as the app is not in the background or has been terminated - e.g. manually by the user or by the system for being in the background for a while. But once the app is terminated or goes to the background, neither the viewController or the Comm class consistently respond. Sometimes they respond and sometimes not - this is what I am trying to isolate and fix. It appears that even though the appDelegate "activates" and responds to region events, that doesn't mean the app and its objects are fully loaded and ready to respond to events and function calls. When using region monitoring, what is the preferred method to insure the relevant objects such as a viewController and other classes are instantiated and able to respond to region changes picked up by the appDelegate when the app is in the background or terminated? Is is necessary to put the entire code in appDelegate?
Posted
by mojomaker.
Last updated
.
Post not yet marked as solved
0 Replies
598 Views
The answer looks like NO, but is it possible using PhoneKit to intercept a carrier call (not VOIP) and based on the number (i.e. whether its in your contacts or not) put it directly into voicemail or allow to ring as usual?
Posted
by mojomaker.
Last updated
.