NP(Notification Provider):消息提供者,指的是ANCS服务的生产者,即IOS设备。
NC(Nofitication Consumer):消息接受者,指的是ANCS服务的客户端,即周边BLE设备。
Apple Notification Center Service 是一项首要服务,其服务UUID为7905F431-B5CE-4E99-A40F-4B1E122D00D0。一个 NP 上可能只存在一个 ANCS 实例。由于 iOS 的性质,不能保证 ANCS 始终存在。因此,NC 应该寻找并订阅 GATT 服务的 Service Changed 特性,以便随时监控 ANCS 的潜在发布和取消发布。
ANCS具备三个特征:
数据传输格式:

数据格式:
NORDIC的相关代码描述:
/**@brief iOS notification structure. */
typedef struct
{uint32_t notif_uid; //!< Notification UID.ble_ancs_c_evt_id_values_t evt_id; //!< Whether the notification was added, removed, or modified.ble_ancs_c_notif_flags_t evt_flags; //!< Bitmask to signal if a special condition applies to the notification, for example, "Silent" or "Important".ble_ancs_c_category_id_val_t category_id; //!< Classification of the notification type, for example, email or location.uint8_t category_count; //!< Current number of active notifications for this category ID.
} ble_ancs_c_evt_notif_t;/**@brief Event IDs for iOS notifications. */
typedef enum
{BLE_ANCS_EVENT_ID_NOTIFICATION_ADDED, /**< The iOS notification was added. */BLE_ANCS_EVENT_ID_NOTIFICATION_MODIFIED, /**< The iOS notification was modified. */BLE_ANCS_EVENT_ID_NOTIFICATION_REMOVED /**< The iOS notification was removed. */
} ble_ancs_c_evt_id_values_t;/**@brief Flags for iOS notifications. */
typedef struct
{uint8_t silent : 1; //!< If this flag is set, the notification has a low priority.uint8_t important : 1; //!< If this flag is set, the notification has a high priority.uint8_t pre_existing : 1; //!< If this flag is set, the notification is pre-existing.uint8_t positive_action : 1; //!< If this flag is set, the notification has a positive action that can be taken.uint8_t negative_action : 1; //!< If this flag is set, the notification has a negative action that can be taken.
} ble_ancs_c_notif_flags_t;/**@brief Category IDs for iOS notifications. */
typedef enum
{BLE_ANCS_CATEGORY_ID_OTHER, /**< The iOS notification belongs to the "other" category. */BLE_ANCS_CATEGORY_ID_INCOMING_CALL, /**< The iOS notification belongs to the "Incoming Call" category. */BLE_ANCS_CATEGORY_ID_MISSED_CALL, /**< The iOS notification belongs to the "Missed Call" category. */BLE_ANCS_CATEGORY_ID_VOICE_MAIL, /**< The iOS notification belongs to the "Voice Mail" category. */BLE_ANCS_CATEGORY_ID_SOCIAL, /**< The iOS notification belongs to the "Social" category. */BLE_ANCS_CATEGORY_ID_SCHEDULE, /**< The iOS notification belongs to the "Schedule" category. */BLE_ANCS_CATEGORY_ID_EMAIL, /**< The iOS notification belongs to the "E-mail" category. */BLE_ANCS_CATEGORY_ID_NEWS, /**< The iOS notification belongs to the "News" category. */BLE_ANCS_CATEGORY_ID_HEALTH_AND_FITNESS, /**< The iOS notification belongs to the "Health and Fitness" category. */BLE_ANCS_CATEGORY_ID_BUSINESS_AND_FINANCE, /**< The iOS notification belongs to the "Buisness and Finance" category. */BLE_ANCS_CATEGORY_ID_LOCATION, /**< The iOS notification belongs to the "Location" category. */BLE_ANCS_CATEGORY_ID_ENTERTAINMENT /**< The iOS notification belongs to the "Entertainment" category. */
} ble_ancs_c_category_id_val_t;
NC 可能想要与 iOS 通知进行交互。它可能想要检索关于它的更多信息,包括它的内容,或者它可能想要对其执行操作。这些属性的检索是通过控制点和数据源特性执行的。
NC 可以通过将特定命令写入控制点特性来发出请求以检索有关 iOS 通知的更多信息。如果写入控制点特征成功,NP 将通过数据源特征上的 GATT 通知流立即响应请求。
获取通知属性命令允许 NC 检索特定 iOS 通知的属性。
命令格式如下:

响应格式如下:

获取应用程序属性命令允许 NC 检索安装在 NP 上的特定应用程序的属性。
命令格式如下:

响应格式如下:

和Get Notification Attributes 命令的响应一样,如果对 Get App Attributes 命令的响应大于协商的 GATT 最大传输单元 (MTU),它会被 NP 分成多个片段。NC 必须通过拼接每个片段来重组响应。当收到每个请求属性的完整元组时,响应完成。
Perform Notification Action 命令允许 NC 对特定的 iOS 通知执行预定的操作。执行通知操作命令包含以下字段:
发出此命令时,无论成功与否,都不会在数据源特征上生成任何数据。
从 iOS 8.0 开始,NP 可以通知 NC 与 iOS 通知相关的潜在操作。然后,NC 可以代表用户请求 NP 执行与特定 iOS 通知关联的操作。
EventFlags通过检测通知源特性生成的 GATT 通知字段中设置标志的存在,通知 NC 在 iOS 通知上存在可执行操作:
NP 代表 NC 执行的实际操作由 NP 确定,并根据执行它们的 iOS 通知而有所不同。例如,对来电通知执行积极操作可能会接听它,而执行消极操作可能会拒绝它。
NC 不得预先假设或尝试猜测对 iOS 通知执行的确切操作,因为这些操作基于它无法获得的信息,以及其他因素,例如 NP 实现的 ANCS 版本。NP 保证积极和消极的行动与不会让用户感到惊讶的结果相关联。
如果出现在 iOS 通知中,正面和负面操作可能会向用户表示为复选标记、X 标记或通常与确认和取消相关的颜色(例如绿色和红色)。
NC 可以通过检索 iOS 8.0 中引入的新通知属性来检索简要描述与 iOS 通知关联的实际操作的标签:
官方描述地址,了解更多详情请点击。
上一篇:MyBatisPlus入门
下一篇:2022美亚个人赛复盘