Receive BluetoothManager notifications in background

拜拜、爱过 提交于 2019-12-08 01:04:07

问题


I'm using the BluetoothManager private framework in my app and I want to know how can I receive BluetoothManager notifications when the application is in background (ex: Receive the connected/disconected bluetooth notification in background).

Thanks in advance.


回答1:


Use

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

and receive the notifications:

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


来源:https://stackoverflow.com/questions/11079457/receive-bluetoothmanager-notifications-in-background

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!