swift - Beacon Ranging in the Background on iOS -


i'm trying find way range beacons in background in ios using location monitoring , triggering ranging so:

func locationmanager(manager: cllocationmanager, diddeterminestate state: clregionstate, forregion region: clregion) {     if (state == .inside) {         locationmanager.startrangingbeaconsinregion((region as? clbeaconregion)!)     } } 

i'm trying api call made in beacon ranging

func locationmanager(manager: cllocationmanager, didrangebeacons beacons: [clbeacon], inregion region: clbeaconregion) {         beacon in beacons {             let minor = beacon.minor int             let major = beacon.major int             {                 try apicall.canseebeacons(major, minor: minor)             } catch {                 print("error making api call")             }         }     } 

however works ten minutes while phone in background, after ten minutes no longer works i'm hoping make continuous api calls can made when beacon found. have correct keys set in permissions , i'm using requestalwaysauthorization() on locationmanager

take on apple's ios dev library regarding background executions: https://developer.apple.com/library/ios/documentation/iphone/conceptual/iphoneosprogrammingguide/backgroundexecution/backgroundexecution.html

if type of app 1 of accepted types longer background executions, add key required background modes info.plist array, containing 1 or more of enabled types: audio, location, voip, newsstand-content, external-accessory and/or bluetooth-central.

just note reviewed apple before publishing app on app store.

edited:

i didn't use while, tested , seems it's easier since xcode 6. follow steps:

1. add key required background modes info.plist

2. go capabilities enter image description here

3. select background mode(s) fit. enter image description here


Comments

Popular posts from this blog

routing - AngularJS State management ->load multiple states in one page -

python - GRASS parser() error -

Swift game error message -