UbuduIndoorLocation 2.8.1

UbuduIndoorLocation 2.8.1

许可证 BSD-2-Clause
发布最后发布2022年11月

由以下人员维护:Jean-Baptiste QuesneyJean Felix TRANTomasz ZiolkowskiFrancois Kruta



Ubudu Indoor Location SDK for iOS

室内位置 SDK 提供了一种解决方案,允许移动设备在室内场地内估算其位置。位置是根据场地内放置的 Beacon 并从其中接收信号广播的设备实时计算的。

该解决方案允许用户在 Ubudu 管理平台上创建自己的地图。地图附属于在管理器中先前创建的特定场地。然后可以在地图上定义和定位各种实体。

Beacons

这是最重要的部分。正确地定位地图上的 Beacon 并相应地部署到场地中是进行精确室内定位的关键。用户必须以使室内定位应工作的整个表面都被覆盖的方式在地图上放置 Beacon。为了达到最佳定位精确度,至少应始终有四个 Beacon 在移动设备的视线范围内并且足够接近。

地图区域

区域是位于地图上的矩形区域。它们有助于定义我们想要检测存在或距离的兴趣区域。移动设备可以通过SDK API访问给定地图上定义的所有区域,也可以检索当前最近区域,或计算到任何区域的距离。

不可导航区域

这些区域表示一个场所内人员无法进入的区域。它们可以在编辑地图时定义。您应标记所有不可进入的墙和/或大障碍物,以及移动设备无法在其中“立即穿过”(需要绕过障碍物才能从一边到另一边)的区域。定义这些不可导航区域可以让室内定位SDK实现更高的精度,并提供更好的体验。

系统和硬件要求

  • iOS 7.0或更高版本。
  • iPhone 4S / iPad 第3代 / iPad mini / iPod touch 第5代,或任何更晚的设备。

将Ubudu SDK添加到项目

使用CocoaPods

这是启动的最简单和首选方式。只需将以下行添加到Podfile文件中

pod 'UbuduIndoorLocation'

然后执行pod install

如果您尚未为项目使用CocoaPods,您可以通过阅读CocoaPods文档开始使用。

直接安装

如果您不想或不能使用 CocoaPods,您可以通过以下说明手动安装 SDK。

  1. UbuduIndoorLocation.framework 文件夹拖放到 XCode 中项目中的 Frameworks 文件夹。勾选 "Copy items into destination group's folder (if needed)" 选项。

  2. 如果项目中有以下框架和库,请将其添加到您项目中。(别忘了 libc++.dylib!)

    • Foundation
    • CoreGraphics
    • UIKit
    • CoreLocation
    • libc++.dylib

    您的框架文件夹应该看起来像这样

    illustration_frameworkfolder

    https://developer.apple.com/library/ios/recipes/xcode_help-project_editor/Articles/ 在项目中添加 Apple 框架的说明。

  3. 在项目设置中,前往:"General"->"您的目标"->"构建设置"->"(全)"->"其他链接器标志" 并添加以下标志:-ObjC

II. 项目配置

位置授权(必需)

从 iOS 8.0 开始,必需在 Info.plist 文件中添加一个条目,以指示您的应用需要哪种位置授权。

  • 要使用 "始终" 模式,请添加 NSLocationAlwaysUsageDescription 键。
  • 要使用 "在使用时" 模式,则添加 NSLocationWhenInUseUsageDescription 键。

室内定位 SDK 可以与两种模式一起工作,因为它基于 iBeacon 范围,这基本上是一个仅前台功能。

illustration_entry

您还需要在启动 Ubudu 室内定位管理器之前调用相应的 CoreLocation 方法 之前

  • 在应用使用时 模式:[[[CLLocationManager alloc] init] requestWhenInUseAuthorization];
  • 始终 模式:[[[CLLocationManager alloc] init] requestAlwaysAuthorization];

有关详细信息,请参阅 Apple CoreLocation 文档

III. 设置室内定位 SDK

首先您需要一个配置好的地图。要创建和配置一个地图,请访问 ubudu Manager

  • 场所与室内地图 中选择一个场所。
  • 点击 地图 按钮,然后点击 添加

一旦配置了地图的属性,管理者就会为您提供地图的唯一密钥。

  • 在您的视图控制器中导入头文件 #import <UbuduIndoorLocation/UbuduIndoorLocation.h>
  • 实例化一个 UBUIndoorLocationManager 对象。
  • 使用方法 loadMapWithKey:success:failure: 加载您的地图。
  • 在您的视图控制器中实现协议 UBUIndoorLocationManagerDelegate
  • 最后,调用室内位置管理器的 start 方法以开始接收位置更新。

同样存在一个 stop 方法,当您不再需要场馆内的位置时,请不要忘记调用它。

以下是一个如何初始化和启动 SDK 的示例

- (void)viewDidLoad
{
    [super viewDidLoad];
    [self initIndoorLocationManager];
}

- (void)initIndoorLocationManager
{
	NSString *mapKey = @"1eff16a0d6c80132a0ef0a824b34cee9";
	
	self.locationManager = [[UBUIndoorLocationManager alloc] init];
    self.locationManager.delegate = self;

	[self.locationManager loadMapWithKey:mapKey success:^{
        NSLog(@"Map loading success");
        [self.locationManager start]; // start only on success callback
        
    } failure:^(NSError *error) {
        NSLog(@"Map loading failure: %@", error);
    }];
}

IV. 位置管理者代表

UBUIndoorLocationManagerDelegate 提供了回调方法,您可以根据需要实现以接收室内位置管理器的事件。

实现以下任何方法以接收对您的应用程序感兴趣的任何事件

- (void)locationManager:(UBUIndoorLocationManager *)locationManager didUpdateBeacons:(NSArray *)beaconsUpdates; 

- (void)locationManager:(UBUIndoorLocationManager *)locationManager positionDidChange:(UBUPositionUpdate *)positionUpdate;

- (void)locationManager:(UBUIndoorLocationManager *)locationManager closestNavigablePointDidChange:(UBUPositionUpdate *)positionUpdate;

- (void)locationManager:(UBUIndoorLocationManager *)locationManager closestBeaconDidChange:(UBUPositionUpdate *)positionUpdate;

- (void)locationManager:(UBUIndoorLocationManager *)locationManager closestZoneDidChange:(UBUPositionUpdate *)positionUpdate;

V. 地图渲染

Ubudu 室内位置 SDK 提供了一个简单的视图控制器,可以显示地图、您定义的区域以及地图上的您当前位置。

在您的 header 文件中,您可以声明 @class UBUMapViewController;

以及一个 属性@property(strong, nonatomic) UBUMapViewController * mapViewController;

根据之前的代码片段(参考:III 设置室内位置 SDK),以下是如何显示地图视图管理器的示例。

- (void)viewDidLoad
{
    [super viewDidLoad];
    [self initIndoorLocationManager];
}

- (void)viewDidAppear:(BOOL)animated
{
    [super viewDidAppear:animated];
    // Subscribe as delegate everytime we appear because mapViewController sets itself as location manager delegate when presented
    self.locationManager.delegate = self;
}

- (void)initIndoorLocationManager
{
	NSString *mapKey = @"1eff16a0d6c80132a0ef0a824b34cee9";
	
	self.locationManager = [[UBUIndoorLocationManager alloc] init];
	 [self.locationManager loadMapWithKey:mapKey success:^{
        NSLog(@"Map loading success");
        [self.locationManager start];
        
        // Push the map view conroller once the map is loaded
		[self showMap];
    } failure:^(NSError *error) {
        NSLog(@"Map loading failure: %@", error);
    }];
}

- (void)showMap
{
    self.mapViewController = [[UBUMapViewController alloc] init];
    self.mapViewController.locationManager = self.locationManager;
    [self presentViewController:self.mapViewController animated:YES completion:NULL];
}