-->

收到背景BluetoothManager通知(Receive BluetoothManager no

2019-09-18 05:09发布

我用我的应用程序的BluetoothManager私人框架,我想知道我怎么能接受BluetoothManager通知,当应用程序在后台(例如:接收在后台连接/蓝牙disconected通知)。

提前致谢。

Answer 1:

采用

// global notification explorer
CFNotificationCenterAddObserver(CFNotificationCenterGetLocalCenter(),
    NULL, MyCallBack, NULL, NULL, 
    CFNotificationSuspensionBehaviorDeliverImmediately);

并收到通知:

// global notification callback
void MyCallBack (CFNotificationCenterRef center,void *observer,CFStringRef name,const void object,CFDictionaryRef userInfo)
{
    NSLog(@"CallBack:CFN Name:%@ Data:%@", name, userInfo);
}


文章来源: Receive BluetoothManager notifications in background