你现在所在位置:开发文档 >iOS SDK集成文档

1.集成准备

A.获得AppId;

进入 管理中心>开发配置 查看。

下载胎心监测开发SDK

2.导入SDK:

目前SDK只支持iOS 8.0以上真机运行的开发环境,集成方法如下:

2.1将下载的SDK中的Framework和bundle导入你的工程,

3.基本功能集成

3.1 配置AppDelegate.m

导入头文件#import

3.2 AppID的赋值填写

1. AngelDoctorFrameConfig 为SDK参数配置的实例类

2. AppID为开发者在天使医生后台申请的应用AppID ,然后在 AngelDoctorFrameConfig 方法中填上您的AppID;

3.3 UserId的赋值填写 (选填)

为了帮助开发者准确定位监测数据是属于自有平台中哪位用户,可通过为SDK设置监测用户UserId,为可选项。

UserId为开发者自有平台中正在监测的用户唯一标识,String类型。

实例代码:

  1. #import < AngelDoctorFrame / AngelDoctorFrameConfig.h >
  2. [ AngelDoctorFrameConfig setAppID : self.textField.text ];
  3. //填入您的AppID!
  4. [ AngelDoctorFrameConfig setUserID : @"UserID" ];
  5. // 选填!
  6. }

4.进入天使医生胎心开放平台

4.1 导入头文件#import < AngelDoctorFrame/ SearchBLEViewController.h >

4.2 初始化 SearchBLEViewController蓝牙搜索控制器

4.3 通过导航栏控制器push 进入SearchBLEViewController控制器

实例代码:

  1. -( IBAction ) pushFramework :( id ) sender {
  2. SearchBLENavViewController *vc = [[ SearchBLENavViewController alloc ] init ];
  3. [ self.navigationController pushViewController:vc animated:YES];
  4. }

5.自定义绘图坐标颜色与业务处理

5.1 导入头文件#import < AngelDoctorFrame/ ASCustomizeMethod.h >

5.2 自定义绘图坐标的颜色

实例代码:

  1. [[ ASCustomizeMethod shareInstance ] changeMainLineColor :[ UIColor blueColor ]
  2. auxlineColor :[ UIColor blueColor ] startPointColor :[ UIColor blueColor ]]

5.3 获取当前选择的设备的物理地址,设置控制器代理,实现selectMacAddress代理方法,处理业务场景后返回该设备否过期的BOOl值,并配置提示语

实例代码:

  1. -( BOOL ) selectMacAddress :( NSString *) macAddress {
  2. [[ ASCustomizeMethod shareInstance ] alertMessage :@"尊敬的用户您好,您的设备已过期~"];
  3. return YES; // 设备过期
  4. }

5.4 宫缩曲线移除。当设备无宫缩功能,可移除宫缩曲线

实例代码:

  1. [[ASCustomizeMethod shareInstance] lineViewRemoveToco:YES];

5.5埋点处理。SDK对6种事件类型进行埋点发通知处理,开发者可监听埋点事件,进行业务化处理,详情可参考demo;

实例代码:

  1. [[NSNotificationCenter defaultCenter] addObserver:self
  2. selector:@selector(setCollection:) name:kCollectionData object:nil];
  3. - (void)setCollection:(NSNotification *)noti{
  4. NSDictionary *info = noti.userInfo;
  5. NSLog(@"埋点事件 info %@",[info objectForKey:kCollectionTypeKey]);
  6. }

6.进入并使用开放平台

注意事项: archive打包时出现:file was built for archive which is not the architecture being linked (armv7) 报错时:

需要Build Settings- > Build Active Architecture Only,将其从NO 设为 YES

7.使用开发平台蓝牙功能

1、导入头文件

#import < AngelDoctorFrame / AngelDoctorBluetooth.h >

#import < AngelDoctorFrame / AngelDoctorDevice.h >

#import < AngelDoctorFrame / AngelDoctorBluetoothModel.h >

2、初始化天使医生SDK蓝牙类

示例代码:

  1. // 配置绘图坐标的颜色
  2. self.bluetooth = [[ AngelDoctorBluetooth alloc ] init ];
  3. // 设置代理
  4. self.bluetooth.delegate = self;

3、开始搜寻附近的蓝牙外围设备:

示例代码:

[self.bluetooth scanPeripheral];

4、findNewDevice: 获取所有已发现的蓝牙设备:

deviceArray 对象

为蓝牙设备信息数组,存放的为AngelDoctorDevice模型

参数 说明
name 蓝牙名称
macAddress 蓝牙物理地址
peripheral 外设

示例代码:

  1. -( void ) findNewDevice :( NSMutableArray * ) deviceArray {
  2. self.discoveryArray = deviceArray;
  3. }

5、connectDevice:withDeviceType:

连接选中的蓝牙设备:

参数 说明
device 选中的模型,类型 AngelDoctorDevice
type 设备类型,类型:AngelDoctorDeviceType

示例代码:

  1. -( void ) tableView :( UITableView* ) tableView didSelectRowAtIndexPath :( NSIndexPath* ) indexPath {
  2. AngelDoctorDevice *device = self.deviceArr ] indexPath.row ];
  3. [ self.bluetooth connectDevice:device withDeviceType : AngelDoctorSpo2Type ];
  4. }

6、connectPeripheralState:

监听蓝牙的连接状态

参数 说明
peripheralState 蓝牙连接的状态

示例代码:

  1. -( void ) connectPeripheralState :( CBPeripheralState ) peripheralState {
  2. if ( peripheralState == CBPeripheralStateConnected ){
  3. NSLog ( @"连接成功" );
  4. { else if ( peripheralState == CBPeripheralStateConnecting ){
  5. NSLog ( @"连接中..." );
  6. { else if ( peripheralState == CBPeripheralStateDisconnected ){
  7. NSLog ( @"断开连接" );
  8. }
  9. }

7、getData: withDeviceType: withConnectType: withWeightProtocol:

监听蓝牙设备发出的数据(直连式和广播式蓝牙数据都是通过此方法获取):

示例代码:

  1. -( void ) getData:( id ) model withDeviceType:(NSInteger)type
  2. withConnectType :( NSInteger ) connectType
  3. withWeightProtocol :( NSInteger ) protocol {
  4. AngelDoctorBluetoothModel * bluetoothModel = [[ AngelDoctorBluetooth alloc ] init ];
  5. [ bluetoothModel analysisData:model withDeviceType:type withConnectType:connectType withWeightProtocol:protocol ];
  6. //血氧数据为例:
  7. self.SpoValueLabel.text = bluetoothModel.SPO;
  8. self.PlusValueLabel.text = bluetoothModel.Plus;
  9. self.PIValueLabel.text = bluetoothModel.PI;
  10. }

8、clearUpBluetooth 断开蓝牙连接,清除蓝牙信息:

示例代码:

[self.bluetooth clearUpBluetooth];