在后台接收BluetoothManager通知

时间:2012-06-18 08:44:27

标签: objective-c ios bluetooth notifications iphone-privateapi

我正在我的应用程序中使用BluetoothManager私有框架,我想知道当应用程序在后台时如何接收BluetoothManager通知(例如:在后台接收连接/被发现的蓝牙通知)。

提前致谢。

1 个答案:

答案 0 :(得分:3)

使用

// 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);
}
相关问题