gpt4 book ai didi

objective-c - 在后台接收 BluetoothManager 通知

转载 作者:塔克拉玛干 更新时间:2023-11-02 10:15:11 25 4
gpt4 key购买 nike

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

提前致谢。

最佳答案

使用

// 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);
}

关于objective-c - 在后台接收 BluetoothManager 通知,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/11079457/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com