title: How to add services to CBPeripheralManager correctly in Xamarin
body: <p>I am attempting to add services to a CBPeripheralManager for IOS using Visual Studio for Mac. However, when I scan for my peripheral using another device, I do not see my added service.  The advertising name is correct, but I only see other services (presumably default for iphone).</p>
  
  <p>As a side note, I wrote the program in swift and get the same issue.</p>
  
  <p>My xcode version is 9 and my ios target version is 11. </p>
  
  <p>My code is as follows</p>
  
  <pre><code>CBPeripheralManager _peripheral;
  public BLEPeripheral()
      {
          _peripheral = new CBPeripheralManager();//this, DispatchQueue.CurrentQueue);
          _peripheral.CharacteristicSubscribed += (object sender, CBPeripheralManagerSubscriptionEventArgs e) =&gt;
          {
              Console.WriteLine("Device Subscribed: {0}", e.Central.UUID);
              _connectedDevices.Add(e.Central);
              ServiceSubscribed(this, e);
          };
  
          _peripheral.WriteRequestsReceived += (object sender, CBATTRequestsEventArgs e) =&gt; {
              Console.WriteLine("Write Request Received");
          };
  
  
          _peripheral.ServiceAdded += (object sender, CBPeripheralManagerServiceEventArgs e) =&gt;
          {
              Console.WriteLine("Service {0} was added", e.Error);
              Console.WriteLine(e.Service.Characteristics.Length.ToString());
              Console.WriteLine(e.Service.UUID.ToString());
  
              IsAdvertising = true;
              StartAdvertisingOptions advOptions = new StartAdvertisingOptions();
              advOptions.LocalName = "myDevice";
  
              _peripheral.StartAdvertising(advOptions);
              Console.WriteLine("starting the advertisement");
          };
  
          _peripheral.AdvertisingStarted += (object sender, Foundation.NSErrorEventArgs e) =&gt;
          {
              Console.WriteLine("Advertising did start");
          };
  
          _peripheral.StateUpdated += (object sender, EventArgs e) =&gt;
          {
              Console.WriteLine("UpdatedState: {0}", _peripheral.State);
          };
  
      }
  </code></pre>
  
  <p>My Code for setting up the service is:</p>
  
  <pre><code>public void setupService()
      {
          txChar = new CBMutableCharacteristic(txCharUUID, CBCharacteristicProperties.Notify, null, CBAttributePermissions.Readable);
          var MyServiceUUID = CBUUID.FromString("A66C4FFC-52C6-4C04-B97C-34E5E91DG5BG");
  
          MyService = new CBMutableService(MyServiceUUID, true);
          MyService.Characteristics = new CBMutableCharacteristic[] { txChar };
          _peripheral.AddService(MyService);
  
      }
  </code></pre>
  
  <p>The state of the peripheralmanager is PoweredOn.  I check this before pressing the button which adds the service and starts advertisement.</p>