gpt4 book ai didi

IOS 启用指示与通知

转载 作者:行者123 更新时间:2023-11-28 14:10:08 25 4
gpt4 key购买 nike

根据苹果的文档,我们可以使用 setNotifyValue(true, for:/characteristic/) 同时启用 Indicate 和 Notify。

但是,我只想启用 Indicate.... Swift 4 是否提供了执行此操作的方法?在 Android 上可以通过以下方式实现:

bluetoothDescriptor.setValue(BluetoothGattDescriptor.ENABLE_INDICATION_VALUE);
bluetoothGatt.writeDescriptor(bluetoothDescriptor);

其中 BluetoothGattDescriptor.ENABLE_INDICATION_VALUE = {0x02, 0x00}

这听起来很熟悉吗?

最佳答案

此功能由 Core Bluetooth 而非 Swift 提供,因此 Swift 版本无关;该功能在 Swift、Objective-C 甚至 C# 中都是相同的。

来自documentation :

If the specified characteristic is configured to allow both notifications and indications, calling this method enables notifications only.

接收指示而非通知的唯一方法是外设仅提供相关特征的指示,并通过特征描述符声明这一点。

关于IOS 启用指示与通知,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/52656461/

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