简体   繁体   English

在iOS中为实施目标4.3实施信标

[英]Implement Beacon in iOS for Deployment Target 4.3

Beacon region monitoring was introduced in iOS7. 在iOS7中引入了信标区域监视。 And I have a App with 4.3 as deployment target. 我有一个以4.3为部署目标的App。 I need to update the App with the new requirement for beacon region monitoring. 我需要使用信标区域监视的新要求来更新应用程序

  1. Is it supported xcode 4.6. 是否支持xcode 4.6。
  2. If I build it in xcode 5, then Can I set the deployment target to 4.3? 如果我在xcode 5中构建它,那么可以将部署目标设置为4.3吗?

what are the other ways that I can achieve this. 还有哪些其他方法可以实现这一目标。

Thanks, 谢谢,

If you want to implement region monitoring using beacon tech, You should do build application on xcode 5.0+, and deployment target should be ios7+ . 如果要使用信标技术实现区域监视,则应在xcode 5.0+上构建应用程序,并且部署目标应为ios7 + But you can do with xcode 4.6 but you have to know about add base sdk as IOS7+ . 但是您可以使用xcode 4.6进行操作,但是您必须了解将基本sdk添加为IOS7 +的知识

See this reference document which support for beacon, 请参阅此参考文档,该文档支持信标,

CLBeaconRegion available from IOS7 , CLBeacon available from IOS7 . 可从IOS7获得CLBeaconRegion可从IOS7获得CLBeacon

Note: In IOS, your iphone can also act as beacon device(normally beacon is an external bluetooth device, see this ref ) broadcast(advertising beacon) via Bluetooth LE hardware which is only available in iPhone 4S, iPhone 5,5c,5s. 注意:在IOS中,您的iPhone还可以充当信标设备(通常信标是外部蓝牙设备, 请参阅此参考 )通过Bluetooth LE硬件广播(广告信标),仅在iPhone 4S,iPhone 5,5c,5s中可用。 iPad 4,iPad Mini, iPad Air..etc. iPad 4,iPad Mini,iPad Air..etc。 So When you support for beacon, you have to note about hardware also. 因此,当您支持信标时,还必须注意有关硬件的信息。

The Core Location framework provides two ways to detect a user's entry and exit into specific regions: geographical region monitoring (iOS 4.0 and later and OS X 10.8 and later) and beacon region monitoring (iOS 7.0 and later) . 核心位置框架提供了两种检测用户进入特定区域的方法: 地理区域监视(iOS 4.0和更高版本以及OS X 10.8和更高版本)和信标区域监视(iOS 7.0和更高版本) A geographical region is an area defined by a circle of a specified radius around a known point on the Earth's surface. 地理区域是由围绕地球表面已知点的指定半径的圆定义的区域。 In contrast, a beacon region is an area defined by the device's proximity to Bluetooth low energy beacons. 相反,信标区域是由设备与蓝牙低功耗信标的接近程度定义的区域。 Beacons themselves are simply devices that advertise a particular Bluetooth low energy payload—you can even turn your iOS device into a beacon with some assistance from the Core Bluetooth framework. 信标本身就是宣传特定蓝牙低功耗有效负载的设备,甚至在Core Bluetooth框架的帮助下,您甚至可以将iOS设备变成信标。

https://developer.apple.com/library/ios/documentation/userexperience/conceptual/LocationAwarenessPG/RegionMonitoring/RegionMonitoring.html https://developer.apple.com/library/ios/documentation/userexperience/conceptual/LocationAwarenessPG/RegionMonitoring/RegionMonitoring.html

You CAN build iBeacon applications using XCode 4.x targeting older iOS releases. 使用的XCode 4.x的针对老年IOS版本iBeacon显示应用。 The setup is a bit tricky and these apps can only use the iBeacon functionality on phones with iOS7 or later. 设置有些棘手,这些应用只能在装有iOS7或更高版本的手机上使用iBeacon功能。 But it can still run on earlier iOS versions. 但是它仍然可以在早期的iOS版本上运行。

The trick is that you first have to make a binary wrapper around the iBeacon APIs using XCode 5. This wrapper code must query the CoreLocation classes to see if the iBeacon APIs exist, and exit gracefully if they do not. 诀窍是,您首先必须使用XCode 5围绕iBeacon API进行二进制包装。此包装代码必须查询CoreLocation类以查看iBeacon API是否存在,如果不存在,请正常退出。 You only have to use XCode 5 to compile this binary, then you add it into your XCode 4.x project (along with your header file so source code can access the class interface). 您只需要使用XCode 5来编译此二进制文件,然后将其添加到XCode 4.x项目中(连同头文件,以便源代码可以访问类接口)。

Below is a snippet of the code from a class that accomplishes this for monitoring iBeacons. 下面是一个类的代码片段,该类完成了此操作以监视iBeacons。 You would have to add additional methods for ranging. 您将不得不添加其他用于范围调整的方法。

  typedef void(^RNDetermineStateCompletionHandler)(NSInteger state, CLRegion *region);

  - (id)init {
      self = [super init];
      if (self != nil) {
          _locationManager = [[CLLocationManager alloc] init];
          _locationManager.delegate = self;
      }
      return self;
  }

  - (BOOL)isIBeaconCapable {
      return [CLLocationManager isRangingAvailable];
  }

  - (void)setUUID:(NSString *)uuidStr {
          NSUUID *uuid = [[NSUUID alloc] initWithUUIDString:uuidStr];
          NSLog(@"RNLocation Wrapper: Set UUID to %@", uuidStr);
          _beaconRegion = [[NSClassFromString(@"CLBeaconRegion") alloc] initWithProximityUUID:uuid identifier:@"my.region.identifier"];
  }

  - (void)monitorBeaconRangeWithHandler:(RNDetermineStateCompletionHandler)completionHandler {
      for (CLBeaconRegion *region in [_locationManager monitoredRegions]) {
          NSLog(@"Stopping monitoring on: %@ ", region.identifier);
          [_locationManager stopMonitoringForRegion:region];
      }

      _stateBlock = completionHandler;
      [_locationManager startMonitoringForRegion:_beaconRegion];
  }


  - (void)locationManager:(CLLocationManager *)manager didDetermineState:(CLRegionState)state forRegion:(CLRegion *)region {
      if (_stateBlock) {
          _stateBlock(state, region);
      }
  }

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM