Latest 1.0.3.2
Homepage https://github.com/yveslym/Square-geofence-region
License MIT
Platforms ios 10.0
Authors

SQUARE REGION GEOFENCE

Overview

square region geofence is a lightweight geofence pod that allows you to cfreate a squared region which is an alternative to circular region.

Demo

SquareRegion

Installing with CocoaPods

  1. Add the pod SquareRegion to your Podfile:
pod 'SquareRegion'
  1. Run:
pod install

Usage:

  1. import
    import SquareRegion
  2. Set Delegate
class   ViewController: UIViewController, SquareRegionProtocol, CLLocationManagerDelegate
{
  1. Initialize
var delegate : SquareRegionProtocol

On viewDidload

delegate = self
  1. Start Location Monitoring

    on didUpdateLocations delegate method of CLLocationManagerDelegate

func locationManager(_ manager: CLLocationManager, didUpdateLocations locations: [CLLocation]) {

if let location = locations.first{

delegate.updateRegion(location: location)

    }
}
  1. Implement the SquareRegionProtocol delegate method
extension   ViewController: SquareRegionProtocol {

  func didEnterRegion(region: CKSquareRegion) {

  print("enter")

  }
  func didExitRegion(region: CKSquareRegion) {

  print("leave")
  }
}
  1. Add and remove region
let center =  CLLocationCoordinate2D.init(latitude: 37.787689, longitude: -122.410929)

// length is in kilometers,
//so you need to convert to meters
// for this exemple it is 35 meters
  let length =  0.035

let squareRegion = CKSquareRegion.init(regionWithCenter: center, sideLength: length, identifier: "steakHouse")

// Add region
delegate.addRegionToMonitor(region: squareRegion!)

// remove region
delegate..removeRegionFromMonitor(identifier: "steakHouse")

Note:

  • The sideLength is in kilometers, so you will have to convert to meters

  • you can monitor more than one location

    License

MIT License

Latest podspec

{
    "name": "SquareRegion",
    "version": "1.0.3.2",
    "summary": "powerful  and efficient, lightweight iOS square region location for Geofence, alternative to circular region",
    "swift_version": "4.2",
    "description": "square region geofence is a lightweight geofence pod that allows you to cfreate a squared region which is an alternative to circular region.",
    "homepage": "https://github.com/yveslym/Square-geofence-region",
    "license": {
        "type": "MIT",
        "file": "LICENSE"
    },
    "authors": {
        "": ""
    },
    "source": {
        "git": "https://github.com/yveslym/Square-geofence-region.git",
        "tag": "1.0.3.2"
    },
    "platforms": {
        "ios": "10.0"
    },
    "source_files": "SquareRegion/*.{swift,h,m}"
}

Pin It on Pinterest

Share This