self.locationManager.requestAlwaysAuthorization() is only available on iOS 8.0 or newer - Swift -


i developing simple ios app in swift gets location of user , shows location. need set app target ios 7.0 , higher iphone 4 users can use app. however, when set deployment target 7.0 build error saying:

/users/toing_toing/dev/xyz/homepageviewcontroller.swift:35:30: 'requestalwaysauthorization()' available on ios 8.0 or newer

it comes line:

self.locationmanager.requestalwaysauthorization() 

i need app access gps time moment, cant find replacement code fix deployment target error. can do?

just use self.locationmanager.startupdatinglocation()

var authorizationstatus = cllocationmanager.authorizationstatus() if (authorizationstatus == .authorizedwheninuse || authorizationstatus == .authorizedalways {   locationmanager.startupdatinglocation() }else if self.locationmanager.respondstoselector(selector("requestalwaysauthorization")) {    self.locationmanager.requestalwaysauthorization() }else {    locationmanager.startupdatinglocation() } 


Comments

Popular posts from this blog

php - Wordpress website dashboard page or post editor content is not showing but front end data is showing properly -

How to get the ip address of VM and use it to configure SSH connection dynamically in Ansible -

javascript - Get parameter of GET request -