Chapter 13: Location Tracking & Beacons
前言
這張大部分時間是都講Location處理,當user進入到感興趣的區域,可以主動提醒使用者一些內容。
大綱
Getting started
Enabling Core Location
Start region monitoring
Monitoring a region
Reacting to a region change
Stop region monitoring
Bonus: Distance calculation
Time for testing
Detecting a beacon
Managing beacons monitoring
Manually stopping region and beacon monitoring
Consuming the beacon detection
Responding to beacon notifications
Timer and QR code detection
Testing
Locating the user
位置權限要求有兩種when in use和always
在iOS10之前只有always這個選項,在iOS11之後,必須加入這兩個選項到plist中。
In fact, LocationManager will implement a total of nine methods defined in CLLocationManagerDelegate, four of which will be forwarded via the custom LocationManagerDelegate to AdViewController.
Geofencing
Geofencing翻譯成地理圍欄,也就是現實世界中的虛擬邊界。在上一節中,我們可以獲取使用者的當前位置,但我們目的並不是要位置,而是想要知道使用者是否在某個特定區域的範圍中。
Monitoring a region
我們可以在單一裝置最多moniter20個regions。
Bonus: Distance calculation
Beacon
Beacon也可以用來做到像Geofencing的功能,只是可以用在更細微的區域,進行所謂的微定位,如大型買場,博物館..等。距離範圍分成三種Far(10公尺以上),Near(10公尺以內), Immediate(幾公分內)。
Managing beacons monitoring
Consuming the beacon detection
最後要把beacon偵測跟QR Code掃描綁在一起。當進到某個特定beacon範圍內會自動觸發QR Code掃描。
Last updated