launchOptions: [UIApplication.LaunchOptionsKey: Any]? is always nil

Viewed 17

when I go to get the "bluetoothCentrals" it is always returned "nil"

The purpose of this application is to ensure that a ble device is connected once when the application is started and that when the application is killed the connection remains active, so that when I go to press a button in the bluetooth device, the application is reopened to make an api call

  • AppDelegate
internal func application(
   _ application: UIApplication, 
   didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?
) -> Bool {
   guard let options = launchOptions,
         let bluetoothCentrals = options[UIApplication.LaunchOptionsKey.bluetoothCentrals] as? [String]
   else {
      return true
   }

   print(bluetoothCentrals) // return always nil
   return true
}
  • CentralManager
centralManager = CBCentralManager(
   delegate: self, 
   queue: nil, 
   options:[CBCentralManagerOptionRestoreIdentifierKey: "centralManager"]
)
0 Answers
Related