iOS BLE device paired while app is in background or killed or suspend
I am able to pair/connect BLE device with my app while app is open. But when my app goes to background/suspended mode, I am not able to keep connection alive.
Is is possible to keep connection alive and get notified for disconnect event for device?
ios ibeacon core-bluetooth
add a comment |
I am able to pair/connect BLE device with my app while app is open. But when my app goes to background/suspended mode, I am not able to keep connection alive.
Is is possible to keep connection alive and get notified for disconnect event for device?
ios ibeacon core-bluetooth
add a comment |
I am able to pair/connect BLE device with my app while app is open. But when my app goes to background/suspended mode, I am not able to keep connection alive.
Is is possible to keep connection alive and get notified for disconnect event for device?
ios ibeacon core-bluetooth
I am able to pair/connect BLE device with my app while app is open. But when my app goes to background/suspended mode, I am not able to keep connection alive.
Is is possible to keep connection alive and get notified for disconnect event for device?
ios ibeacon core-bluetooth
ios ibeacon core-bluetooth
edited Nov 14 '18 at 16:23
rmaddy
242k27316380
242k27316380
asked Nov 14 '18 at 12:00
Nirav PandyaNirav Pandya
113
113
add a comment |
add a comment |
3 Answers
3
active
oldest
votes
Sure it is.
First things first: you can scan peripheral and connect to them in background as long as they expose at least one service(this service must be indicated while you are launching the scan command).
You must specify that in your target capabilities, just by checking Uses Bluetooth LE accessories
.
To detect bluetooth disconnection you just need to implement the CBCentralManagerDelegate
method func centralManager(CBCentralManager, didDisconnectPeripheral: CBPeripheral, error: Error?)
.
The connection is kept alive in background as long as your peripheral does not require a keep alive signal, if you need to do some operations in background the Uses Bluetooth LE accessories
check is required.
To simplify working with BLE I suggest you to check out this library.
add a comment |
For background applications there is limitations. Not all functions may be used in background. Then you send application to moderation with unreasonable background functions you will be failed.
- Apps that play audible content to the user while in the background,
such as a music player app - Apps that record audio content while in
the background - Apps that keep users informed of their location at all
times, such as a navigation app - Apps that support Voice over Internet
Protocol (VoIP) - Apps that need to download and process new content
regularly - Apps that receive regular updates from external accessories
Here you will find more description. May be your case is "Apps that receive regular updates from external accessories" with "Acts as a Bluetooth LE accessory" mode.
In google also you will find a lot of information.
add a comment |
For supporting the Core-Bluetooth in suspended / background mode Enable your application for backdrops support.
Goto your Project --> Target --> Capabilities --> Switch On Background Modes --> Select Use Bluetooth LE accessories.
But iOS system may kill your background application at any time for free the memory for foreground application.
For getting the connected/Disconnected events use below line of code.
central.connect(peripheral, options: [CBConnectPeripheralOptionNotifyOnConnectionKey:true, CBConnectPeripheralOptionNotifyOnDisconnectionKey: true])
add a comment |
Your Answer
StackExchange.ifUsing("editor", function ()
StackExchange.using("externalEditor", function ()
StackExchange.using("snippets", function ()
StackExchange.snippets.init();
);
);
, "code-snippets");
StackExchange.ready(function()
var channelOptions =
tags: "".split(" "),
id: "1"
;
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function()
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled)
StackExchange.using("snippets", function()
createEditor();
);
else
createEditor();
);
function createEditor()
StackExchange.prepareEditor(
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader:
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
,
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
);
);
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53299770%2fios-ble-device-paired-while-app-is-in-background-or-killed-or-suspend%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
3 Answers
3
active
oldest
votes
3 Answers
3
active
oldest
votes
active
oldest
votes
active
oldest
votes
Sure it is.
First things first: you can scan peripheral and connect to them in background as long as they expose at least one service(this service must be indicated while you are launching the scan command).
You must specify that in your target capabilities, just by checking Uses Bluetooth LE accessories
.
To detect bluetooth disconnection you just need to implement the CBCentralManagerDelegate
method func centralManager(CBCentralManager, didDisconnectPeripheral: CBPeripheral, error: Error?)
.
The connection is kept alive in background as long as your peripheral does not require a keep alive signal, if you need to do some operations in background the Uses Bluetooth LE accessories
check is required.
To simplify working with BLE I suggest you to check out this library.
add a comment |
Sure it is.
First things first: you can scan peripheral and connect to them in background as long as they expose at least one service(this service must be indicated while you are launching the scan command).
You must specify that in your target capabilities, just by checking Uses Bluetooth LE accessories
.
To detect bluetooth disconnection you just need to implement the CBCentralManagerDelegate
method func centralManager(CBCentralManager, didDisconnectPeripheral: CBPeripheral, error: Error?)
.
The connection is kept alive in background as long as your peripheral does not require a keep alive signal, if you need to do some operations in background the Uses Bluetooth LE accessories
check is required.
To simplify working with BLE I suggest you to check out this library.
add a comment |
Sure it is.
First things first: you can scan peripheral and connect to them in background as long as they expose at least one service(this service must be indicated while you are launching the scan command).
You must specify that in your target capabilities, just by checking Uses Bluetooth LE accessories
.
To detect bluetooth disconnection you just need to implement the CBCentralManagerDelegate
method func centralManager(CBCentralManager, didDisconnectPeripheral: CBPeripheral, error: Error?)
.
The connection is kept alive in background as long as your peripheral does not require a keep alive signal, if you need to do some operations in background the Uses Bluetooth LE accessories
check is required.
To simplify working with BLE I suggest you to check out this library.
Sure it is.
First things first: you can scan peripheral and connect to them in background as long as they expose at least one service(this service must be indicated while you are launching the scan command).
You must specify that in your target capabilities, just by checking Uses Bluetooth LE accessories
.
To detect bluetooth disconnection you just need to implement the CBCentralManagerDelegate
method func centralManager(CBCentralManager, didDisconnectPeripheral: CBPeripheral, error: Error?)
.
The connection is kept alive in background as long as your peripheral does not require a keep alive signal, if you need to do some operations in background the Uses Bluetooth LE accessories
check is required.
To simplify working with BLE I suggest you to check out this library.
answered Nov 14 '18 at 14:05
AndreaAndrea
19.7k867106
19.7k867106
add a comment |
add a comment |
For background applications there is limitations. Not all functions may be used in background. Then you send application to moderation with unreasonable background functions you will be failed.
- Apps that play audible content to the user while in the background,
such as a music player app - Apps that record audio content while in
the background - Apps that keep users informed of their location at all
times, such as a navigation app - Apps that support Voice over Internet
Protocol (VoIP) - Apps that need to download and process new content
regularly - Apps that receive regular updates from external accessories
Here you will find more description. May be your case is "Apps that receive regular updates from external accessories" with "Acts as a Bluetooth LE accessory" mode.
In google also you will find a lot of information.
add a comment |
For background applications there is limitations. Not all functions may be used in background. Then you send application to moderation with unreasonable background functions you will be failed.
- Apps that play audible content to the user while in the background,
such as a music player app - Apps that record audio content while in
the background - Apps that keep users informed of their location at all
times, such as a navigation app - Apps that support Voice over Internet
Protocol (VoIP) - Apps that need to download and process new content
regularly - Apps that receive regular updates from external accessories
Here you will find more description. May be your case is "Apps that receive regular updates from external accessories" with "Acts as a Bluetooth LE accessory" mode.
In google also you will find a lot of information.
add a comment |
For background applications there is limitations. Not all functions may be used in background. Then you send application to moderation with unreasonable background functions you will be failed.
- Apps that play audible content to the user while in the background,
such as a music player app - Apps that record audio content while in
the background - Apps that keep users informed of their location at all
times, such as a navigation app - Apps that support Voice over Internet
Protocol (VoIP) - Apps that need to download and process new content
regularly - Apps that receive regular updates from external accessories
Here you will find more description. May be your case is "Apps that receive regular updates from external accessories" with "Acts as a Bluetooth LE accessory" mode.
In google also you will find a lot of information.
For background applications there is limitations. Not all functions may be used in background. Then you send application to moderation with unreasonable background functions you will be failed.
- Apps that play audible content to the user while in the background,
such as a music player app - Apps that record audio content while in
the background - Apps that keep users informed of their location at all
times, such as a navigation app - Apps that support Voice over Internet
Protocol (VoIP) - Apps that need to download and process new content
regularly - Apps that receive regular updates from external accessories
Here you will find more description. May be your case is "Apps that receive regular updates from external accessories" with "Acts as a Bluetooth LE accessory" mode.
In google also you will find a lot of information.
answered Nov 14 '18 at 13:26
Vasily AvilovVasily Avilov
5817
5817
add a comment |
add a comment |
For supporting the Core-Bluetooth in suspended / background mode Enable your application for backdrops support.
Goto your Project --> Target --> Capabilities --> Switch On Background Modes --> Select Use Bluetooth LE accessories.
But iOS system may kill your background application at any time for free the memory for foreground application.
For getting the connected/Disconnected events use below line of code.
central.connect(peripheral, options: [CBConnectPeripheralOptionNotifyOnConnectionKey:true, CBConnectPeripheralOptionNotifyOnDisconnectionKey: true])
add a comment |
For supporting the Core-Bluetooth in suspended / background mode Enable your application for backdrops support.
Goto your Project --> Target --> Capabilities --> Switch On Background Modes --> Select Use Bluetooth LE accessories.
But iOS system may kill your background application at any time for free the memory for foreground application.
For getting the connected/Disconnected events use below line of code.
central.connect(peripheral, options: [CBConnectPeripheralOptionNotifyOnConnectionKey:true, CBConnectPeripheralOptionNotifyOnDisconnectionKey: true])
add a comment |
For supporting the Core-Bluetooth in suspended / background mode Enable your application for backdrops support.
Goto your Project --> Target --> Capabilities --> Switch On Background Modes --> Select Use Bluetooth LE accessories.
But iOS system may kill your background application at any time for free the memory for foreground application.
For getting the connected/Disconnected events use below line of code.
central.connect(peripheral, options: [CBConnectPeripheralOptionNotifyOnConnectionKey:true, CBConnectPeripheralOptionNotifyOnDisconnectionKey: true])
For supporting the Core-Bluetooth in suspended / background mode Enable your application for backdrops support.
Goto your Project --> Target --> Capabilities --> Switch On Background Modes --> Select Use Bluetooth LE accessories.
But iOS system may kill your background application at any time for free the memory for foreground application.
For getting the connected/Disconnected events use below line of code.
central.connect(peripheral, options: [CBConnectPeripheralOptionNotifyOnConnectionKey:true, CBConnectPeripheralOptionNotifyOnDisconnectionKey: true])
answered Nov 20 '18 at 7:08
iOS_MaccusiOS_Maccus
30710
30710
add a comment |
add a comment |
Thanks for contributing an answer to Stack Overflow!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53299770%2fios-ble-device-paired-while-app-is-in-background-or-killed-or-suspend%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown