CoreBluetooth "willRestoreState" - what exactly should be done there?
<p>I'm developing an application that needs to continuously run and track some peripheral characteristic.</p>

<p>All works fine in foreground.<br>
It also works in background, but I'm not sure that I do it correctly.</p>

<p>I red many posts about state restoration and implementing <code>willRestoreState</code>, but many of them don't explicit tells you what to do when this method getting called.</p>

<p>The process that I'm making goes like this:</p>

<p>I'm creating a central manager using  </p>

<pre><code>myCentralManager =
        [[CBCentralManager alloc] initWithDelegate:self queue:nil
         options:@{ CBCentralManagerOptionRestoreIdentifierKey:
         @"myCentralManagerIdentifier" }];
</code></pre>

<p>From here I'm doing the <strong>regular flow</strong> of:<br>
Waiting for central manager to get powered on (centralManagerDidUpdateState) -> Scan for my peripheral -> Connect to it -> Discover service -> Discover characteristic -> Subscribe to the charactristic -> Reading data</p>

<p>Then I kill my app using</p>

<pre><code>kill(getpid(), SIGKILL);
</code></pre>

<p>I'm waiting a couple of seconds, and then starts advertising again from my peripheral. </p>

<p>Then I can see that the process is coming back to life, and my logs show that <code>didFinishLaunchingWithOptions</code> in AppDelegate is getting called.</p>

<p>I then restore the central manager like this:</p>

<pre><code> NSArray *identifiers = launchOptions[UIApplicationLaunchOptionsBluetoothCentralsKey];

   if (identifiers &amp;&amp; identifiers.count &gt; 0) {
        _centralManager = [[CBCentralManager alloc] initWithDelegate:self
                                                               queue:nil
                                                             options:@{CBCentralManagerOptionRestoreIdentifierKey:[identifiers objectAtIndex:0]}];
    } 
</code></pre>

<p>I can also see that <code>willRestoreState</code> and <code>centralManagerDidUpdateState</code> are getting called.</p>

<p>Here's where I'm lost. 
What should I do next?  If I'm keep doing the regular flow (which I described above, All seems to work fine - and in the same way as above.</p>

<p>But - Am I doing the right thing?</p>

<p>Should I do something in <code>willRestoreState</code>?
If yes, what I should do?</p>

<p>Thanks in advance!</p>