Post

Replies

Boosts

Views

Activity

ios swift application instance time alive
Hi all, I have created an application that uses location services and bluetooth services. Inside AppDelegate using significant location changes I am assigning a new instance of CBCentralManager like this How long this instance is staying alive? I am noticing that it may last even five days but I am not sure which parameters affect this? class AppDelegate: UIResponder, UIApplicationDelegate ,CLLocationManagerDelegate,CBCentralManagerDelegate,UNUserNotificationCenterDelegate { private static var centralManager : CBCentralManager! func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool { if let keys = launchOptions?.keys { if keys.contains(.location) { AppDelegate.centralManager = CBCentralManager(delegate: self, queue: nil) locationManager.requestAlwaysAuthorization() locationManager.allowsBackgroundLocationUpdates = true locationManager.pausesLocationUpdatesAutomatically = false } } return true } func centralManager(_ central: CBCentralManager, didDiscover peripheral:CBPeripheral, advertisementData: [String : Any], rssi RSSI: NSNumber) { AppDelegate.centralManager.connect(peripheral, options: nil)* } func centralManager(_ central: CBCentralManager, didDisconnectPeripheral peripheral: CBPeripheral, error: Error?) { AppDelegate.centralManager.connect(peripheral, options: nil) } func centralManager(_ central: CBCentralManager, didDisconnectPeripheral peripheral: CBPeripheral, error: Error?) { AppDelegate.centralManager.connect(peripheral, options: nil) } }
0
0
295
Aug ’23