iOS 接入指南

SDK支持平台

  • iOS 12.0以上的版本
  • WatchOS 6.0以上的版本(默认不支持,如需支持请联系业务同事申请)

权限

需在Info.plist中添加以下权限

  • NSBluetoothAlwaysUsageDescription

  • NSBluetoothPeripheralUsageDescription

如需在后台运行,则还要添加以下权限:

  • App communicates using CoreBluetooth

  • App shares data using CoreBluetooth

App Privacy

https://developer.apple.com/documentation/bundleresources/privacy_manifest_files/describing_use_of_required_reason_api

Type Reasons SDK使用原因
User Defaults CA92.1: Access info from same app, per documentation 用于缓存蓝牙扫描到的设备信息,以加快连接
File Timestamp C617.1: Inside app or group container, per documentation 使用stat函数获取SDK日志文件的大小和时间,以达到自动清除SDK日志文件
System Boot Time 35F9.1: Measure time on-device, per documentation 使用mach_absolute_time函数,用于记录输出日志的时间

导入SDK

为了兼容多种架构,SDK在1.3.1版本以后,将采用xcframework形式发布.

framework形式

导入framework

xcframework形式

请导入一下以下框架

Welland的xcframework

ICBleProtocol.xcframework

ICBodyFatAlgorithms.xcframework

ICDeviceManager.xcframework

ICLogger.xcframework

System的框架

libc++.tbd

libz.tbd

导入xcframework

增加头文件引用

在需要调用ICDeviceManager的文件中,增加头文件引用。

import <ICDeviceManager/ICDeviceManager.h>

SDK接入流程

初始化SDK

调用[[ICDeviceManager shared] initMgr]进行初始化SDK,在初始化之前,建议调用[ICDeviceManager shared].delegate设置好代理对象。否则可能会丢失部分回调。如:

[ICDeviceManager shared].delegate = self;
[[ICDeviceManager shared] initMgr];

扫描设备

SDK初始化完成后,如果需要查找附近的设备,可以调用扫描接口来进行扫描设备:

[[ICDeviceManager shared] scanDevice:delegate];

设备将通过扫描回调代理对象进行回调(调用扫描接口前,请确保蓝牙是否开启,否则该接口不会生效,如正常扫描过程中关闭蓝牙,然后再次打开蓝牙,请重新调用该接口,SDK不会自动去开启扫描).

注: 如果已知道设备的mac地址,可以直接调用添加设备接口,不用调用扫描接口。SDK内部会自动去连接这个设备。

停止扫描

调用了扫描设备接口,在已经找到需要的设备后,请调用停止扫描(sdk不会自动停止):

[[ICDeviceManager shared] stopScan];

添加设备

如果已经找到需要的设备了,调用添加设备接口:

[[ICDeviceManager shared] addDevice:device callback:^(ICDevice *device ICAddDeviceCallBackCode code) {}];

接口可以时SDK去连接设备并收取数据(请确保设备处于亮屏状态,否则SDK将会不会收到数据, 中途蓝牙关闭或设备息屏,当蓝牙重新开启或设备再次亮屏,SDK会自动去连接,无需再次添加设备或扫描设备).

删除设备

当不想SDK去连接和收取设备数据时,从SDK移除该设备,可以调用移除设备接口:

[[ICDeviceManager shared] removeDevice:device callback:^(ICDevice *device, ICRemoveDeviceCallBackCode code) {
}];

更新用户信息

因为要计算用户的体脂以及一些其他数据,所以需要App调用更新用户信息接口:

[[ICDeviceManager shared] updateUserInfo:userInfo];

日志目录

如出现SDK收不到数据或连接异常等情况,请把SDK日志发给我们,获取SDK日志目录:

[[ICDeviceManager shared] getLogPath];

设备设置接口

部分设备支持设置单位或卡路里等属性,获取这些设置接口:

[[ICDeviceManager shared] getSettingManager];

体脂算法接口

获取体脂算法接口:

[[ICDeviceManager shared] getBodyFatAlgorithmsManager];
GUANGDONG WELLAND TECHNOLOGY CO.,LTD All Right ReservedUpdate time: 2024-07-20 11:41:18

results matching ""

    No results matching ""

    results matching ""

      No results matching ""