Pat*_*ick 13 delegates bluetooth objective-c ios ibeacon
我正在使用自定义BeaconManager委托,因此信标范围不是由视图控制器的生命周期决定的.一切都很好但每隔一段时间(1-2天)的灯塔范围就会停止工作,并且不会被称为执行范围.解决这个问题的唯一方法是让我重置我的iPhone,一旦我这样做,它就完美无缺.下面是我正在使用的代码.基本流程是,当我的ViewController调用ViewDidLoad时,它会向AppDelegate发送一个通知,告诉它开始为信标设置范围,我从不告诉它停止,因为我希望它继续为信标范围而不管用户导航的位置在应用程序中.我想知道我的代码是否导致了这个问题,或者这只是蓝牙的一个错误.谢谢你的帮助!
BeaconManager.m
#import "BeaconManager.h"
#import "AppDelegate.h"
@interface BeaconManager()<CLLocationManagerDelegate>
@property (nonatomic, strong) CLLocationManager *locationManager;
@property (nonatomic, strong) CLBeaconRegion *beaconRegion;
@end
@implementation BeaconManager
+ (id)sharedManager
{
static BeaconManager *sharedBeaconManager = nil;
static dispatch_once_t once;
dispatch_once(&once, ^{
sharedBeaconManager = [[self alloc] init];
});
return sharedBeaconManager;
}
- (id)init
{
self = [super init];
if(self)
{
self.locationManager = [[CLLocationManager alloc] init];
self.locationManager.delegate = self;
}
return self;
}
- (void)startBeaconMonitoring:(NSString*)forUUID
{
NSUUID * uuid = [[NSUUID alloc] initWithUUIDString:forUUID];
self.beaconRegion = [[CLBeaconRegion alloc] initWithProximityUUID:uuid identifier:@"com.beacons.publicRegion"];
[self.locationManager startMonitoringForRegion:self.beaconRegion];
[self.locationManager startRangingBeaconsInRegion:self.beaconRegion];
}
- (void)stopBeaconMonitoring
{
//Stop the region monitoring
if(self.locationManager != nil && self.beaconRegion != nil) {
[self.locationManager stopRangingBeaconsInRegion:self.beaconRegion];
}
}
#pragma mark - CLLocationManagerDelegate
- (void)locationManager:(CLLocationManager *)manager didRangeBeacons:(NSArray *)beacons inRegion:(CLBeaconRegion *)region
{
self.beacons = beacons;
if(self.delegate != nil) {
[self.delegate beaconManager:self didRangeBeacons:self.beacons];
}
}
@end
Run Code Online (Sandbox Code Playgroud)
ViewController.m
@implementation ViewController
- (void)viewDidLoad
{
[super viewDidLoad];
[[NSNotificationCenter defaultCenter] postNotificationName:@"startRanging" object:nil userInfo:nil];
}
Run Code Online (Sandbox Code Playgroud)
AppDelegate.m
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(startRangingForZombies) name:@"startRanging" object: nil];
return YES;
}
- (void)startRanging
{
//Start the beacon region monitoring when the controller loads
BeaconManager *beaconManager = [BeaconManager sharedManager];
beaconManager.delegate = self;
[beaconManager startBeaconMonitoring:@"1234-54324-34242-34242-43243"];
}
Run Code Online (Sandbox Code Playgroud)
dav*_*ung 21
我们收到Radius Networks的许多报告,这些报告停止检测iBeacons,需要重新启动或关闭蓝牙并重新打开才能解决问题.人们已经在iPhone 4S,iPhone 5s,iPhone 5c和iPad上报道了这一点.
我没有任何确凿的证据证明这是iOS 7.1中出现的问题,但自发布以来报告频率已经上升.因此,间接证据非常强烈.
当这款手机进入此状态时,手机仍然可以扫描蓝牙设备,仍然可以作为iBeacon进行传输.因此,它不是蓝牙的硬件问题.根据现有证据,它很可能是CoreLocation中新引入的错误.
小智 5
实际上,它是iOS 7.1中的一个已知错误.对于最新版本的iOS,蓝牙堆栈严格来说是一个软件问题.蓝牙设备检测有时会停止工作 - 不幸的是,所有iOS 7.1兼容设备都是如此.该错误已经报告给Apple,但只要他们没有为此发布修复程序,最好的解决方案是重新启动设备.
如果重启没有帮助,SmartRobotic有一个方便的指南如何解决它:http://www.smartbotics.com/#!4-Tips-to-Fix-Bluetooth-Problems-After-iOS-71-Upgrade / c118r/031A86F6-C8E8-4768-B4FD-E6F83D9E4317
如果您在升级到iOS 7.1后遇到蓝牙连接问题,请尝试这4个提示.
- 关闭并重新启动 - 有些人报告说,这是iOS 7.1升级后修复设备所需的全部内容.
- 切换蓝牙关闭并重新打开 - 向上滑动以访问控制中心并点击蓝牙图标,等待至少30秒,然后重新打开.这通常可以修复遇到连接问题的设备.
- 杀死(强制退出)有问题的应用程序 - 首先双击Home以启动多任务卡界面.触摸并按住应用程序的卡片,然后将其扔掉.这将强制应用程序退出,并在下次打开应用程序时完全重新加载.
- 清除并重置蓝牙设备配对 - 转到设置>蓝牙,然后点击违规设备的(i)图标.点击忘记此设备.现在,您应该能够重新添加蓝牙硬件并将其重新配对.要清除所有配对设备,请转至设置>常规>重置>重置网络设置,然后重新设置蓝牙配对.
希望这些建议能解决您的蓝牙连接问题.
干杯.
归档时间: |
|
查看次数: |
10221 次 |
最近记录: |