title: Create separate bluetooth service
body: <p>I'm trying to refactor and organize my code and create a separate bluetooth service to contain all bluetooth related code. I have problem with declaration of CBCentralManager. Before it belonged to the AppDelegate class but I would like to love it to my BluetoothService class.</p>
  <pre><code>@objc class AppDelegate: FlutterAppDelegate {
  
      override func application(
          _ application: UIApplication,
          didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?
      ) -&gt; Bool {    
  </code></pre>
  <p>This part I would like to move to my BluetoothService:</p>
  <pre><code>BluetoothService.cbCentralManager = CBCentralManager(delegate: self, queue: nil, options: [CBCentralManagerOptionShowPowerAlertKey: true])
              BluetoothService.cbCentralManager?.delegate = self
  </code></pre>
  <pre><code>    let controller : FlutterViewController = window?.rootViewController as! FlutterViewController
      
      FlutterPlatformService().setupMethodChannel(messenger: controller.binaryMessenger)
      FlutterPlatformService().setupEventChannels(messenger: controller.binaryMessenger)
      
      GeneratedPluginRegistrant.register(with: self)
      return super.application(application, didFinishLaunchingWithOptions: launchOptions)
  }
  </code></pre>
  <p>}</p>
  <p>In my BluetoothService class I wanted to store all the bluetooth related variables and functions. As you can see in the part of code below:</p>
  <pre><code>class BluetoothService: NSObject, CBCentralManagerDelegate, CBPeripheralDelegate{
  func centralManagerDidUpdateState(_ central: CBCentralManager) {
      }
  func centralManager(_ central: CBCentralManager, didDiscover peripheral: CBPeripheral, advertisementData: [String : Any], rssi RSSI: NSNumber) {
          if (!BluetoothService.peripherals.contains(peripheral) &amp;&amp; peripheral.name != nil){
              print(peripheral)
              BluetoothService.peripherals.append(peripheral)
          }
      }
      
      func centralManager(_ central: CBCentralManager, didConnect peripheral: CBPeripheral) {
          print(&quot;connected to \(peripheral)&quot;)
          peripheral.delegate = self
          peripheral.discoverServices(nil)
          print(&quot;Discovering services!&quot;)
      }
  </code></pre>