如何向连接的设备发送消息通知?

How to send message notification to the connected device?

我正在制作一个蓝牙聊天应用程序,我希望当两个设备都已连接并且一个设备向另一个设备发送消息时,会收到一条通知,告知某个设备发送了一条消息。

麻烦帮我解决这个问题一个星期了。 提前致谢

来自the docs

By default, many of the common Core Bluetooth tasks—on both the central and peripheral side—are disabled while your app is in the background or in a suspended state. That said, you can declare your app to support the Core Bluetooth background execution modes to allow your app to be woken up from a suspended state to process certain Bluetooth-related events. Even if your app doesn’t need the full range of background processing support, it can still ask to be alerted by the system when important events occur.

此类事件可能会发布消息。一旦接收应用程序被系统唤醒,您就可以安排 UILocalNotification 发送。