ios - didEnterRegion, didExitRegion not being called -


i've been experimenting region monitoring in order show alert or local notification when user within set region. first step, added print line see if works on debug area. however, while other lines being printed, i'm not getting didenterregion , didexitregion.

i simulating location in/outside of given region having no luck. great if @ code below , see i've missed. thank you.

    import uikit     import corelocation      class viewcontroller: uiviewcontroller, cllocationmanagerdelegate {      var manager = cllocationmanager?()            override func viewdidload() {             super.viewdidload()             // additional setup after loading view, typically nib.             manager = cllocationmanager()             let latitude: cllocationdegrees = 48.858400             let longitude: cllocationdegrees = 2.294500             let center: cllocationcoordinate2d = cllocationcoordinate2dmake(latitude, longitude)             let radius: cllocationdistance = cllocationdistance(100.0)             let identifier: string = "notre dame"              let currregion = clcircularregion(center: center, radius: radius, identifier: identifier)              manager?.distancefilter = 10             manager?.desiredaccuracy = kcllocationaccuracybest             currregion.notifyonentry = true             currregion.notifyonexit = true              manager?.requestwheninuseauthorization()               manager?.delegate = self             manager?.pauseslocationupdatesautomatically = true              manager?.startmonitoringforregion(currregion)             manager?.startupdatinglocation()               }          override func didreceivememorywarning() {             super.didreceivememorywarning()             // dispose of resources can recreated.         }          func locationmanager(manager: cllocationmanager, didstartmonitoringforregion region: clregion) {             print("the monitored regions are: \(manager.monitoredregions)")         }          func locationmanager(manager: cllocationmanager, didupdatelocations locations: [cllocation]) {             let locvalue:cllocationcoordinate2d = manager.location!.coordinate             print("locations = \(locvalue.latitude) \(locvalue.longitude)")         }          func locationmanager(manager: cllocationmanager, didenterregion region: clregion)  {             nslog("entered")         }          func locationmanager(manager: cllocationmanager, didexitregion region: clregion) {             nslog("exited")         }       } 

you can make work changing

manager?.requestwheninuseauthorization()

to

manager?.requestalwaysauthorization()

then add info.plist file key nslocationalwaysusagedescription value "this testing purpose" or whatever text want appear user requesting use location


Comments

Popular posts from this blog

ios - RestKit 0.20 — CoreData: error: Failed to call designated initializer on NSManagedObject class (again) -

laravel - PDOException in Connector.php line 55: SQLSTATE[HY000] [1045] Access denied for user 'root'@'localhost' (using password: YES) -

java - Digest auth with Spring Security using javaconfig -