<?xml version="1.0" encoding="UTF-8" ?>
<?xml-stylesheet type="text/xsl" href="https://devzone.nordicsemi.com/cfs-file/__key/system/syndication/rss.xsl" media="screen"?><rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:slash="http://purl.org/rss/1.0/modules/slash/" xmlns:wfw="http://wellformedweb.org/CommentAPI/" xmlns:atom="http://www.w3.org/2005/Atom"><channel><title>How to connect multiple peripherals when app gets suspended or kills due to memory ?</title><link>https://devzone.nordicsemi.com/f/nordic-q-a/19902/how-to-connect-multiple-peripherals-when-app-gets-suspended-or-kills-due-to-memory</link><description>I have added below code. 
 //Central manager Initialization

self.centralManager = [[CBCentralManager alloc] initWithDelegate:self queue:nil options:@{ CBCentralManagerOptionRestoreIdentifierKey:@&amp;quot;myCentralManager&amp;quot;}];

//Appdelegate.m

 //State</description><dc:language>en-US</dc:language><generator>Telligent Community 13</generator><lastBuildDate>Thu, 02 Mar 2017 14:56:57 GMT</lastBuildDate><atom:link rel="self" type="application/rss+xml" href="https://devzone.nordicsemi.com/f/nordic-q-a/19902/how-to-connect-multiple-peripherals-when-app-gets-suspended-or-kills-due-to-memory" /><item><title>RE: How to connect multiple peripherals when app gets suspended or kills due to memory ?</title><link>https://devzone.nordicsemi.com/thread/77449?ContentTypeID=1</link><pubDate>Thu, 02 Mar 2017 14:56:57 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:f28283ff-787f-4d18-92aa-c04ddbfa1603</guid><dc:creator>Mostafa Berg</dc:creator><description>&lt;p&gt;I&amp;#39;ve updated the answer to respond to your new questions, hope this helps :)&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: How to connect multiple peripherals when app gets suspended or kills due to memory ?</title><link>https://devzone.nordicsemi.com/thread/77448?ContentTypeID=1</link><pubDate>Thu, 23 Feb 2017 10:38:09 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:325a936f-8939-4ae0-a7a5-53da42b3c8d6</guid><dc:creator>Nik</dc:creator><description>&lt;p&gt;If my all peripherals are connected and then my application get terminated by system due to memory. then I am able to get the peripherals in my willRestorePeripherals method. Once I get all the peripherals do I only need to set the peripherals.delegate = self and I can get the event of peripherals ? or do I need to send the connect command to those restored peripherals again ? am I missing something ?&lt;/p&gt;
&lt;p&gt;Also do we need to ReInitialize the Central Manager in AppDelegate again when  I get a callback in my AppDelegate ?
I know I am asking so many questions but It will be very helpful.
Thanks.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: How to connect multiple peripherals when app gets suspended or kills due to memory ?</title><link>https://devzone.nordicsemi.com/thread/77447?ContentTypeID=1</link><pubDate>Thu, 23 Feb 2017 09:03:44 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:6d467d2f-a6e4-44e3-82fd-d65937d7a09a</guid><dc:creator>Mostafa Berg</dc:creator><description>&lt;p&gt;The answer to your question is actually in the link you posted:)&lt;/p&gt;
&lt;p&gt;You don&amp;#39;t manually connect to peripherals like that, the state restoration is only used when your app is force quit by iOS to preserve memory for example.&lt;/p&gt;
&lt;p&gt;iOS handles the connection/disconnection for your peripherals when the app is in background, if you are connected, and the app is closed, the connection will remain open to the peripheral and won&amp;#39;t be disconnected, you can also scan and connect new peripherals in the background.&lt;/p&gt;
&lt;p&gt;You must also set the bluetooth background mode in your app&amp;#39;s capabilities&lt;/p&gt;
&lt;p&gt;Please read those points thoroughly :&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;
&lt;p&gt;&lt;a href="https://developer.apple.com/library/content/documentation/NetworkingInternetWeb/Conceptual/CoreBluetooth_concepts/CoreBluetoothBackgroundProcessingForIOSApps/PerformingTasksWhileYourAppIsInTheBackground.html#//apple_ref/doc/uid/TP40013257-CH7-SW7"&gt;Core bluetooth background execution modes&lt;/a&gt;&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;&lt;a href="https://developer.apple.com/library/content/documentation/NetworkingInternetWeb/Conceptual/CoreBluetooth_concepts/CoreBluetoothBackgroundProcessingForIOSApps/PerformingTasksWhileYourAppIsInTheBackground.html#//apple_ref/doc/uid/TP40013257-CH7-SW5"&gt;Performing Long-Term Actions in the Background&lt;/a&gt;&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;&lt;a href="https://developer.apple.com/library/content/documentation/iPhone/Conceptual/iPhoneOSProgrammingGuide/BackgroundExecution/BackgroundExecution.html#//apple_ref/doc/uid/TP40007072-CH4-SW23"&gt;Declaring Your App’s Supported Background Tasks&lt;/a&gt;&lt;/p&gt;
&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;if something is unclear please let us know.&lt;/p&gt;
&lt;hr /&gt;
&lt;p&gt;&lt;strong&gt;Edit1: Added more info to answer first comment&lt;/strong&gt;&lt;/p&gt;
&lt;p&gt;To answer all your questions please refer to &lt;a href="https://developer.apple.com/library/prerelease/content/documentation/NetworkingInternetWeb/Conceptual/CoreBluetooth_concepts/BestPracticesForInteractingWithARemotePeripheralDevice/BestPracticesForInteractingWithARemotePeripheralDevice.html#//apple_ref/doc/uid/TP40013257-CH6-SW11"&gt;this page&lt;/a&gt; in the docs&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;Note that some peripherals might be connected even if your app is killed, but some might not if you went out of range, etc.., you can find how to find which in the link i posted above, but there are two methods to find the peripherals that are connected only and to find all peripherals that were discovered&lt;/li&gt;
&lt;li&gt;Yes you will need to set a delegate for your peripherals again to be able to get events from them&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;Here is a nice flowchart from the link above to explain a bit how to reconnect when you are restoring your app from a killed state:
&lt;img src="https://devzone.nordicsemi.com/cfs-file/__key/communityserver-discussions-components-files/4/ReconnectingToAPeripheral_5F00_2x.png" alt="image description" /&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item></channel></rss>