ios - AirLocate 和 BeaconDemo : not showing up

标签 ios objective-c bluetooth-lowenergy ibeacon

我有 2 台设备,iPhone 5(充当 Beacon)和 iPhone 5s(充当 Beacon Detector),均装有 iOS 8.1。

两个设备都启用:

  • 定位服务(隐私 > 定位服务 > 始终用于 AirLocate)
  • 蓝牙
  • Wi-Fi,加入具有互联网连接的相同 SSID(不太相关)
  • iPhone 5s有SIM卡,信号够强
  • iPhone 5 没有 SIM 卡

在 iPhone 5 中,我安装了 Apple 的 AirLocate演示和配置如下(在配置页面):

  • 启用:是
  • UUID:E2C56DB5-DFFB-48D2-B060-D0F5A71096E0
  • 专业:0
  • 未成年人:0
  • 实测功率:-59

由于报告原始 AirLocate 默认情况下在 iOS 8 中不工作,我修改了 AppDelegate 的 didFinishLaunchingWithOptions :

- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{

    // This location manager will be used to notify the user of region state transitions.
    self.locationManager = [[CLLocationManager alloc] init];
    self.locationManager.delegate = self;
    if([self.locationManager respondsToSelector:@selector(requestAlwaysAuthorization)]) {
        [self.locationManager requestAlwaysAuthorization];
    }

    if ([UIApplication instancesRespondToSelector:@selector(registerUserNotificationSettings:)]){
        [application registerUserNotificationSettings:[UIUserNotificationSettings settingsForTypes:UIUserNotificationTypeAlert|UIUserNotificationTypeBadge|UIUserNotificationTypeSound categories:nil]];
    }
    return YES;
}

在 iPhone 5s 中,我安装了 Beacon Demo并配置如下(添加一个新的 Beacon):

  • 信标 UUID:E2C56DB5-DFFB-48D2-B060-D0F5A71096E0
  • 主要 ID:(空)
  • 未成年人 ID:(空)
  • 问候语:入学测试
  • 再见讯息:再见测试

然而,iPhone 5 并没有出现在 iPhone 5s 中,一直声称“Not In Range”。我错过了什么?


截图:

Left: AirLocate; Right: Beacon Demo

左:AirLocate;右:信标演示


更新 Beacon 演示中的最新 didFinishLaunchingWithOptions:

- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
    // Set up Core Location Manager
    self.coreLocation = [[CLLocationManager alloc] init];
    _coreLocation.delegate = self;
    if([self.coreLocation respondsToSelector:@selector(requestAlwaysAuthorization)]) {
        NSLog(@"Core Location requesting always authorization");
        [self.coreLocation requestAlwaysAuthorization];
    }
    if ([UIApplication instancesRespondToSelector:@selector(registerUserNotificationSettings:)]){
        [application registerUserNotificationSettings:[UIUserNotificationSettings settingsForTypes:UIUserNotificationTypeAlert|UIUserNotificationTypeBadge|UIUserNotificationTypeSound categories:nil]];
    }

    // Load any previously registered notifications
    [self loadNotificationRegions];

    // Override point for customization after application launch.
    return YES;
}

最佳答案

如果您使用来自 here 的 Beacon Demo 版本那么您需要像对 AirLocate 演示应用程序一样对其进行等效修改。这两个应用程序都不需要 iOS 8 中添加的必要权限。

执行此操作时,请确保您还在 Info.plist 文件中添加了相应的条目,如 here. 所述。

关于ios - AirLocate 和 BeaconDemo : not showing up,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/27853809/

相关文章:

android - android中的ibeacon集合小于ios

android - 如何使用蓝牙 LE MAC 地址唯一地识别 android 设备?

ios - 将 setPredicate 的结果保存到 NSString

ios - 将base64解码为uiimage iOS Swift

ios - SKLableNode - 使用图像作为颜色模式

iphone - iOS中定时器的实现方式

java - gatt.writeCharacteristic() 可能返回 false 的原因是什么?

ios - 将输入数字存储在文本框中的变量中

ios - Corona SDK : storyboard. gotoScene 效果

objective-c - 为什么我的 objective-c 代码不会在 xCode 中导致错误?