资源简介
iBeacon唤醒App保持蓝牙长连接处理的单例,需要手机的始终定位权限。
可以应用在其他需要唤醒App的场景,比如商场、小店、打卡签到等。
可以应用在其他需要唤醒App的场景,比如商场、小店、打卡签到等。
代码片段和文件信息
//
// RY_iBeaconManager.m
// Ryeex
//
// Created by Asten on 2018/12/7.
// Copyright © 2018年 Ryeex. All rights reserved.
//
#import “RY_iBeaconManager.h“
#import “HeyPlusCentralManager.h“
#import
#define iBeaconSignal @“10F86430-1314-1516-1718-192021222325“
#define iBeaconMonitorSignalbase @“10F86430-1346-11E4-9191-“
#define iBeaconMonitorSignal @“10F86430-1346-11E4-9191-0800200C9A66“
#define iBeaconMonitorSignalText @“10F86430-1346-11E4-9191-0800200C9A66“
@interface RY_iBeaconManager()
@property (nonatomic strong) CLLocationManager *iBeaconManager;
@property (nonatomic strong) CLBeaconRegion *ibeacon;
@property (nonatomic strong) CBPeripheralManager *peripheralManager;
@end
@implementation RY_iBeaconManager
+ (RY_iBeaconManager*)sharedInstance {
static RY_iBeaconManager *instance = nil;
static dispatch_once_t onceToken;
dispatch_once(&onceToken ^{
instance = [[RY_iBeaconManager alloc] init];
// [instance simulateiBeaconSignal];
[instance initManager];
});
return instance;
}
//模拟iBeacon信号
- (void)simulateiBeaconSignal{
_peripheralManager= [[CBPeripheralManager alloc] initWithDelegate:self queue:nil options:nil];
NSUUID *proximityUUID = [[NSUUID alloc] initWithUUIDString:iBeaconSignal];
//创建beacon区域
CLBeaconRegion *beaconRegion = [[CLBeaconRegion alloc] initWithProximityUUID:proximityUUID major:1090 minor:102 identifier:@“iBeacon-Asten“];
NSDictionary *beaconPeripheraData = [beaconRegion peripheralDataWithMeasuredPower:[NSNumber numberWithInt:60]];
if(beaconPeripheraData) {
[self.peripheralManager startAdvertising:beaconPeripheraData];//开始广播
}
}
- (void)peripheralManagerDidUpdateState:(CBPeripheralManager *)peripheral{
}
- (void)initManager{
if ([CLLocationManager isMonitoringAvailableForClass:[CLBeaconRegion class]] && !self.iBeaconManager) {
self.iBeaconManager = [[CLLocationManager alloc]init];
self.iBeaconManager.delegate = self;
[self.iBeaconManager requestAlwaysAuthorization];
if ([self.iBeaconManager respondsToSelector:@selector(allowsBackgroundLocationUpdates)]) {
[self.iBeaconManager setAllowsBackgroundLocationUpdates:YES];
}
NSString *fullSignal = [NSString stringWithFormat:@“%@%@“iBeaconMonitorSignalbase[[HeyPlusCentralManager getInstance].currentDevice.mac stringByReplacingOccurrencesOfString:@“:“ withString:@““]];
// NSString *fullSignal = [NSString stringWithFormat:@“%@9CF6DD3013AE“iBeaconMonitorSignalbase];
_ibeacon = [[CLBeaconRegion alloc] initWithProximityUUID:[[NSUUID alloc]initWithUUIDString:fullSignal] identifier:@“iBeacon“];
_ibeacon.notifyEntryStateOnDisplay = YES;
[self.iBeaconManager startMonitoringForRegion:_ibeacon];
DDLogError(@“%@ GrootiBeaconManager ibeaconManager startMonitoringForRegion signal %@“APP_TAGfullSignal);
属性 大小 日期 时间 名称
----------- --------- ---------- ----- ----
目录 0 2019-12-30 02:36 iBeacon\
文件 5368 2019-12-30 02:28 iBeacon\RY_iBeaconManager.m
文件 333 2019-12-30 02:28 __MACOSX\iBeacon\._RY_iBeaconManager.m
文件 357 2019-08-26 09:27 iBeacon\RY_iBeaconManager.h
文件 333 2019-08-26 09:27 __MACOSX\iBeacon\._RY_iBeaconManager.h
- 上一篇:macOS pptp
- 下一篇:arcgis锐角检查工具
评论
共有 条评论