SwpBluetooth
导入
- 手动导入:
- SwpBluetooth 文件夹导入到项目中。
#import "SwpBluetoothHeader.h
- CocoaPods 导入
- pod search SwpBluetooth
- pod 'SwpBluetooth'
#import <SwpBluetooth/SwpBluetoothHeader.h>
代码示例
SwpBluetooth
.swpBluetoothManagerChain()
// 扫描设备
.swpBluetoothPeripheralBeginScanningChain(^(SwpBluetooth * _Nonnull swpBluetooth, NSArray<SwpBluetoothModel *> * _Nonnull models, NSArray<NSDictionary<NSString *,id> *> * _Nonnull metaDatas) {
//
})
// 设备断开链接回调
.swpBluetoothPeripheralDisconnectChain(^(SwpBluetooth * _Nonnull swpBluetooth, CBPeripheral * _Nonnull perpheral, NSArray<SwpBluetoothModel *> * _Nonnull models, NSArray<NSDictionary<NSString *,id> *> * _Nonnull metaDatas, NSError * _Nonnull error) {
//
})
// 无法链接设备回调
.swpBluetoothConnectPeripheralFailChain(^(SwpBluetooth * _Nonnull swpBluetooth, CBPeripheral * _Nonnull perpheral, NSError * _Nonnull error){
//
})
// 设备写入数据
.swpBluetoothPeripheralWriteDataCompletionChain(^(SwpBluetooth *swpBluetooth, BOOL completion, CBPeripheral * _Nonnull perpheral, NSError * _Nullable error, NSString * _Nullable errorMessage){
NSLog(@"%@", completion ? @"写入成功" : @"写入失败");
})
SwpBluetooth
.swpBluetoothManagerChain()
// 自动连接设备回调
.swpBluetoothPeripheralAutomaticlConnectChain(^(SwpBluetooth * _Nonnull swpBluetooth, CBPeripheral * _Nonnull perpheral, NSArray<SwpBluetoothModel *> * _Nonnull models, NSArray<NSDictionary<NSString *,id> *> * _Nonnull metaDatas){
//
});
SwpBluetooth
.swpBluetoothManagerChain()
// 连接设备,成功回调
.swpBluetoothConnectPeripheralChain(model.peripheral, ^(SwpBluetooth *swpBluetooth, CBPeripheral * _Nonnull perpheral, NSArray<SwpBluetoothModel *> * _Nonnull models, NSArray<NSDictionary<NSString *,id> *> * _Nonnull datas){
});
SwpLocation 文档
注意:
请在项目的 Info.plist 中配置蓝牙权限:
- 隐私 - 蓝牙外围设备使用描述:是否允许此 App 使用蓝牙?
版本记录
- 版本号:1.0.0
- 更新时间:2018-04-14 00:44:33
- 更新内容:
- 完成第一个版本,上传了 pod。
- 版本号:0.0.1
- 更新时间:2018-04-13 01:03:46
- 更新内容:
- 首次上传到 Git,开发版本,功能尚未完成,未上传 pod。
备注
- 将持续更新,如果喜欢,请点赞。
声明
- 版权所有 ©swp_song,如需转载请注明出处