Zhi-Wei Cai Zhi-Wei Cai - 8 months ago 165
iOS Question

BLE in Background Mode: didUpdateValueForCharacteristic not called

I've a custom class (let's say,

) that served as a
wrapper (similar to LGBluetooth, I guess). It handles communications between my BLE accessory and the iOS device:


@interface MyBLE : NSObject

@property (nonatomic, strong) CBCentralManager *central;
@property (nonatomic, strong) CBPeripheral *peripheral;

+ (MyBLE *)sharedInstance;



In the
, I initialized it as a
object, which works fine in the foreground. I set up the needed entries in the Info.plist to use the
according to Core Bluetooth Programming Guide so I can kept getting data send by the BLE accessory.

But when I pressed the home button, Xcode console no longer print out any message that should be printed when the iOS got data from the BLE peripheral. The device is already connected to iOS device (central) before went into background mode.

Did I miss anything? It seems that the app no longer gets data from BLE device after 3 mins. (Yes, I did add the


After I moved the initialization of MyBLE object from -init: to -application:didFinishLaunchingWithOptions:, it worked.

Guess somehow the delegate wasn't considered initialized at that point.