Bug 24324 - Bluetooth delegates are not called when app is in background
Summary: Bluetooth delegates are not called when app is in background
Status: RESOLVED UPSTREAM
Alias: None
Product: iOS
Classification: Xamarin
Component: General ()
Version: XI 8.4.0
Hardware: Macintosh Mac OS
: Normal normal
Target Milestone: Untriaged
Assignee: Paola Villarreal
URL:
Depends on:
Blocks:
 
Reported: 2014-11-07 02:36 UTC by urs
Modified: 2014-11-21 13:21 UTC (History)
5 users (show)

Tags:
Is this bug a regression?: ---
Last known good build:

Notice (2018-05-24): bugzilla.xamarin.com is now in read-only mode.

Please join us on Visual Studio Developer Community and in the Xamarin and Mono organizations on GitHub to continue tracking issues. Bugzilla will remain available for reference in read-only mode. We will continue to work on open Bugzilla bugs, copy them to the new locations as needed for follow-up, and add the new items under Related Links.

Our sincere thanks to everyone who has contributed on this bug tracker over the years. Thanks also for your understanding as we make these adjustments and improvements for the future.


Please create a new report on Developer Community or GitHub with your current version information, steps to reproduce, and relevant error messages or log files if you are hitting an issue that looks similar to this resolved bug and you do not yet see a matching new report.

Related Links:
Status:
RESOLVED UPSTREAM

Description urs 2014-11-07 02:36:24 UTC
CoreBluetooth delegates are not called anymore while iPhone (iOS 8.1) is locked (or while app is just in background), if the app is built for AdHoc/AppStore distribution. When debugging is enabled, it works like expected.

Background modes are enabled via the Info.plist:
<key>UIBackgroundModes</key>
<array>
  <string>bluetooth-central</string>
</array> 

Version infos:
Xamarin Studio
Version 5.5.2 (build 3)
Installation UUID: a76b291c-27da-4998-aa85-0dcb9ec6278b
Runtime:
	Mono 3.10.0 ((detached/e204655)
	GTK+ 2.24.23 (Raleigh theme)

	Package version: 310000023
------------
Xamarin.iOS
Version: 8.4.0.15 (Indie Edition)
Hash: 08968c4
Branch: 
Build date: 2014-10-20 21:48:06-0400
------------
Operating System
Mac OS X 10.10.0
Darwin 14.0.0 Darwin Kernel Version 14.0.0
    Fri Sep 19 00:26:44 PDT 2014
    root:xnu-2782.1.97~2/RELEASE_X86_64 x86_64
Comment 1 Rolf Bjarne Kvinge [MSFT] 2014-11-07 02:54:30 UTC
Only project configurations differ between the different profiles, so you'll need to narrow it down by modifying one of the failing project configurations to be more and more like the working project configuration, until it starts working (and then you know the option which makes it break).

The most likely project option pages to start looking: 'iOS Build' (both the General and Advanced tabs), 'Compiler' and 'iOS Bundle Signing'
Comment 2 urs 2014-11-07 04:44:37 UTC
It starts working as soon as "Enable debugging" is checked. But that is not what I want for the AppStore configuration. It might be an iOS bug?
Comment 5 Rolf Bjarne Kvinge [MSFT] 2014-11-07 05:35:07 UTC
Can you attach a test project or some sort of sample code so that we can try to reproduce this?
Comment 6 urs 2014-11-07 06:37:12 UTC
Connect to a BLE peripheral which is able to send notifications. Activate notifications with CBPeripheral.SetNotifyValue() and listen to the event CBPeripheral.UpdatedCharacterteristicValue. 
The event is firing in debug mode, but not with debugging disabled.
Comment 7 Rolf Bjarne Kvinge [MSFT] 2014-11-07 07:59:34 UTC
@Paola, can you try to reproduce this since you have a BLE device?

@urs, do you know if this worked in previous versions of Xamarin.iOS (and if that's the case, which versions)?
Comment 8 urs 2014-11-07 09:29:16 UTC
Yes it did work before. But this was with iOS 7.x. In september I started working with iOS 8 and I recognized the issue just a few days ago, because it's only happening if debugging is disabled.
Comment 11 Paola Villarreal 2014-11-07 12:08:24 UTC
Sure! A test case would be ideal. Otherwise it might take a little longer and not necessarily the issue will be reproduced/confirmed
Comment 18 Dan Ardelean 2014-11-19 17:43:23 UTC
I think you can reproduce it with any BLE device. Just connect from an Xamarin app and subscribe the RSSI. Then start launching , closing the app. Launch again, close the app and you will see at some point stops working. I think in 5 minutes of using the app, close, open you will see the behaviour. When it stops working to make it run again you will have to disable and then re-enable bluetooth on the device
Comment 19 Paola Villarreal 2014-11-19 18:54:38 UTC
Can you please tell me if you can reproduce this issue with the BLE Explorer sample? 

http://developer.xamarin.com/content/BluetoothLEExplorer/BluetoothLEExplorer.zip
Comment 20 Paola Villarreal 2014-11-21 13:21:50 UTC
So, a heads up: RSSI events are known not to trigger on iOS 8. 

http://stackoverflow.com/questions/26061359/ios-readrssi-doesnt-trigger-the-reading

Upstreaming this bug.