基于位置区域的服务

1. 背景

Ref[1]

在iOS设备锁屏的状态下,App的icon会出现在屏幕的左下角。

iOS 8 Feature: Location-based Lockscreen App Shortcuts Appearing on iPhone

http://www.igeeksblog.com/ios-8-feature-location-based-lockscreen-app-shortcuts-appearing-on-iphone/

Can I get my iOS app to appear on the lower left corner of the lock screen?

http://stackoverflow.com/questions/25897219/can-i-get-my-ios-app-to-appear-on-the-lower-left-corner-of-the-lock-screen

2. 区域监控和iBeacon

Ref[1]

2.1 Core Location framework提供两种方式来检测(detect)一个用户进入和退出某个区域:

A) geographical region monitoring (iOS 4.0+ OS X v10.8+)

B) beacon region monitoring (iOS 7+)

geographical region is an area defined by a circle of a specified radius around a known point on the Earth’s surface.

beacon  region is an area defined by the device’s proximity to Bluetooth low-energy beacons.

Apps can use region monitoring to be notified when a user crosses geographic boundaries or when

a user enters or exits the vicinity of a beacon.

In iOS, regions associated with your app are tracked at all times, including when the app isn’t running.

If a region boundary is crossed while an app isn’t running, that app is relaunched into the background to handle the event.

Similarly, if the app is suspended when the event occurs, it’s woken up and given a short amount of time (around 10 seconds)

to handle the event.

2.2 判断Region Monitoring(区域监控)是否可用

A) 设备没有必要的硬件来支持RM。

B) 用户拒绝App的使用RM的授权。

C) 用户在"设置"App中关闭了定位服务。

D) 用户在"设置"App中关闭了"后台App刷新"的功能。

E) 设备在Airplane模式时不能启动必须的硬件。

以上原因都会导致RM不可用。

在iOS 7.0+, 在监控区域之前调用isMonitoringAvailableForClass: and authorizationStatus(CLLocationManager)。

在之前的iOS中,调用regionMonitoringAvailable

方法isMonitoringAvailableForClass:通过返回值来告诉App硬件是否支持某类的RM。如果返回YES, 进而调用

authorizationStatus来决定App是否已被授权使用定位服务。如果status是kCLAuthorizationStatusAuthorized

则App可以接收"穿越边界"(boundary crossing)的通知。如果status是其它的值,则App不会收到这些通知。

"Finally, if your app needs to process location updates in the background, be sure to check the

backgroundRefreshStatus property of the UIApplication class. You can use the value of this property

to determine if doing so is possible and to warn the user if it is not. Note that the system doesn’t wake

your app for region notifications when the Background App Refresh setting is disabled globally

or specifically for your app." Ref[1]

2.3 监控地理区域 (Monitoring Geographical Regions)

Geographical region monitoring uses location services to detect entry and exit into known geographical locations.

2.3.1 定义一个被监控的地理区域

在监控地理区域之前,必须定义一个区域(region)并将它注册到系统中。

iOS 7.0+, 使用CLCircularRegion类来定义。在以前的iOS版本中,使用CLRegion类。

每个region包括定义地理区域的数据和唯一的一个ID。这个ID用来在App中来标识一个区域。

使用CLLocationManager的方法startMonitoringForRegion: 来注册区域。

Demo-1: Creating and registering a geographical region based on a Map Kit overlay

Monitoring of a geographical region begins immediately after registration for authorized apps.

However, don’t expect to receive an event right away, because only boundary crossings generate an event.

To check whether the user is already inside the boundary of a region, use the requestStateForRegion: method of the CLLocationManager class.

"Regions are a shared system resource, and the total number of regions available systemwide is limited.

For this reason, Core Location limits to 20 the number of regions that may be simultaneously monitored

by a single app. To work around this limit, consider registering only those regions in the user’s immediate vicinity.

As the user’s location changes, you can remove regions that are now farther way and add regions coming

up on the user’s path. If you attempt to register a region and space is unavailable, the location manager calls thelocationManager:monitoringDidFailForRegion:withError: method of its delegate with

thekCLErrorRegionMonitoringFailure error code."

2.3.2 处理穿越地理区域边界的事件

3. 监控Beacon区域

beacon由以下信息标识:

proximity UUID: a 128-bit value that uniquely identifies one or more beacons as a certain type or from a certain organization.

major value: is a 16-bit unsigned integer that can be used to group related beacons that have the same proximity UUID.

minor value: is a 16-bit unsigned integer that differentiates beacons with the same proximity UUID and major value.

一个beacon区域可以代表多个beacon。

(Note that although every beacon must advertise a proximity UUID, major and minor values are optional.)

3.1 定义被监控的beacon区域

定义beacon区域使用CLBeaconRegion类。

"Note that a region’s identifier is unrelated to the identifying information that a beacon advertises."

Demo-2: Creating and registering a beacon region

"When a user’s device detects a beacon that is advertising the identifying information defined by

the registered beacon region (proximity UUID, major value, and minor value), the system generates

an appropriate region event for your app."

3.2 处理Beacon区域的穿越边界事件

3.3 Determining the Proximity of a Beacon Using Ranging

startRangingBeaconsInRegion:

Demo-3: Determining the relative distance between a beacon and a device

4. 将iOS设备转换为iBeacon

Ref[1]

"Any iOS device that supports sharing data using Bluetooth low energy can be used as an iBeacon.

In Core Bluetooth, a peripheral is a device that advertises and shares data using Bluetooth low energy. Advertising your beacon’s data is the only way other devices can detect and range your beacon. " Ref[1]


Reference

1. <<Location and Maps Programming Guide>> Region Monitoring and iBeacon

https://developer.apple.com/library/mac/documentation/UserExperience/Conceptual/LocationAwarenessPG/RegionMonitoring/RegionMonitoring.html

2. iOS 8 pushes location context to a new level: lock screen notifications triggered by iBeacon

http://blog.estimote.com/post/97824495825/ios-8-pushes-location-context-to-a-new-level-lock

3. Core Bluetooth Programming Guide


Item

Region Monitoring: 区域监控,RM

iOS.Location-Based Service的更多相关文章

  1. LBS(Location Based Service)(基于位置的服务)

    LBS(Location Based Service)(基于位置的服务) Android 中定位方式基本可以分为两种:GPS定位,网络定位. GPS定位的工作原理是基于手机内置的GPS硬件直接和卫星进 ...

  2. Android - 位置定位(Location)服务(Service)类的基本操作

    位置定位(Location)服务(Service)类的基本操作 本文地址: http://blog.csdn.net/caroline_wendy 定位服务(Location Service),能够确 ...

  3. Information Centric Networking Based Service Centric Networking

    A method implemented by a network device residing in a service domain, wherein the network device co ...

  4. 【读书笔记】iOS网络-Web Service协议与风格

    协议指的是在与其它系统交换结构化信息时所要遵循的一套格式,过程与规则.此外,协议定义了在传输过程中所要使用的数据格式.这样,接收系统就能正确地解释结构化信息并做出正应的回应. 1,简单对象访问协议. ...

  5. Restful based service 的跨域调用

    1.关于跨域, w3c的官方文档:https://www.w3.org/TR/cors/ 2.有时间再整理吧. <html> <head> <script src=&qu ...

  6. iOS APP EuclidStudy Service Support

    Hi,If you have any questions, you can send a message here or send them to us. We will answer you as ...

  7. IOS原生地图与高德地图

    原生地图 1.什么是LBS LBS: 基于位置的服务   Location Based Service 实际应用:大众点评,陌陌,微信,美团等需要用到地图或定位的App 2.定位方式 1.GPS定位  ...

  8. iOS开发——高级篇——地理定位 CoreLocation

    一.CoreLocation 在移动互联网时代,移动app能解决用户的很多生活琐事,比如周边:找餐馆.找KTV.找电影院等等导航:根据用户设定的起点和终点,进行路线规划,并指引用户如何到达 在上述应用 ...

  9. iOS开发拓展篇—CoreLocation简单介绍

    iOS开发拓展篇—CoreLocation简单介绍 一.简介 1.在移动互联网时代,移动app能解决用户的很多生活琐事,比如 (1)导航:去任意陌生的地方 (2)周边:找餐馆.找酒店.找银行.找电影院 ...

  10. iOS之原生地图与高德地图

    原生地图 1.什么是LBS LBS: 基于位置的服务 Location Based Service 实际应用:大众点评,陌陌,微信,美团等需要用到地图或定位的App 2.定位方式 1.GPS定位 2. ...

随机推荐

  1. FMS Dev Guide学习笔记

    翻译一下其中或许对游戏开发有用的一个章节 一.开发交互式的媒体应用程序 1.共享对象(Shared objects)     ----关于共享对象     使用共享对象可以同步用户和存储数据.共享对象 ...

  2. js 提示条

    js: var Persen = { timeUptopBar:function(fun) { var obj = $('.top-alert'); obj.fadeOut(1500,function ...

  3. 用jQuery实现轮播图效果,js中的排他思想

    ---恢复内容开始--- jQuery实现轮播图不用单独加载. 思路: a. 通过$("#id名");选择需要的一类标签,获得一个伪数组 b.由于是伪数组的原因,而对数组的处理最多 ...

  4. yml和properties配置文件区别

    我们可以观察到的格式就是yml文件是梯级呈现的,我们应该注意一下几个方面: 1>在properties文件里面的 “ .”  连接在yml文件里面全部换成 ":" 进行连接, ...

  5. 如何更改Oracle字符集避免乱码

    转一位大神的笔记. 国内最常用的Oracle字符集ZHS16GBK(GBK 16-bit Simplified Chinese)能够支持繁体中文,并且按照2个字符长度存储一个汉字.UTF8字符集是多字 ...

  6. 彻底弄懂css中单位px和em,rem的区别

    PX:PX实际上就是像素,用PX设置字体大小时,比较稳定和精确.但是这种方法存在一个问题,当用户在浏览器中浏览我们制作的Web页面时,如果改变了浏览器的缩放,这时会使用我们的Web页面布局被打破.这样 ...

  7. 第二章 向量(c)无序向量

  8. 动态添加select选项空选项问题

    问题:动态添加校区选项的数据的时候,总是多添加一项空白的数据. 动态添加代码如下: 网上找到的原因:因为在option中有标签没有闭合,所以导致浏览器认为是两个option, 所以只需要给这个标签添加 ...

  9. FPGA功耗那些事儿(转载)

    在项目设计初期,基于硬件电源模块的设计考虑,对FPGA设计中的功耗估计是必不可少的.笔者经历过一个项目,整个系统的功耗达到了100w,而单片FPGA的功耗估计得到为20w左右,有点过高了,功耗过高则会 ...

  10. HDU-1042.N!(大数与小数相乘的乘法模拟)

    本题大意:给定一个10000以内的整数n,让你求出n!并输出. 本题思路:先初始化一个存放答案的数组ans,初始ans[0] = 1,并初始化其剩下的元素为0,接着就从2开始依次与ans数组内的每一个 ...