0
私はアラートを設定しようとしています。ユーザーが特定の場所を入力すると、アラートがポップアップし、ユーザーは「チェックイン」できます。ユーザーがアプリケーションをチェックインした後、apiエンドポイントにそのユーザーが正常にチェックインしたことを通知します。これは初めてのジオフェンシングとコアロケーションでの作業です。チェックインアラートとジオフェンスがどのように結びついているかは完全にはわかりません。ここに私のコードは次のとおりです。ジオフェンシングとCLCircularRegionを使用して「チェックイン」アラートを設定するにはどうすればよいですか?
領域に入るか、終了時に通知するCLCircularRegion
に
notifyOnEntry = true
を設定
import UIKit
import CoreLocation
class ViewController: UIViewController, CLLocationManagerDelegate{
var manager = CLLocationManager()
override func viewDidLoad() {
super.viewDidLoad()
// Core Location
manager.delegate = self
manager.desiredAccuracy = kCLLocationAccuracyBest
manager.requestWhenInUseAuthorization()
manager.startUpdatingLocation()
var latitude: CLLocationDegrees = 43.039278
var longitude: CLLocationDegrees = -87.932479
var center: CLLocationCoordinate2D = CLLocationCoordinate2DMake(latitude, longitude)
var radius: CLLocationDistance = CLLocationDistance(10.0)
var identifier: String = "storeID"
var geoRegion: CLCircularRegion = CLCircularRegion(center: center, radius: radius, identifier: identifier)
}
func showSimpleAlertWithTitle(title: String!, message: String!, viewController: UIViewController) {
let alert = UIAlertController(title: title, message: message, preferredStyle: .Alert)
let action = UIAlertAction(title: "Check-In", style: .Cancel , handler: nil)
alert.addAction(action)
viewController.presentViewController(alert, animated: true, completion: nil)
}
}