Why does my app fail to display the alert message to turn on Location Services in prepare(for:sender)?2019 Community Moderator ElectionHow to detect tableView cell touched or clicked in swiftExpand and Collapse tableview cellsUpdate or reload UITableView after completion of delete action on detail viewhow to load value in textbox from datepicker in tableviewthread 1: exc_bad_instruction(code=exc_1386_invop,subcode=0x0)TableView not displaying text with JSON data from API callCan't implement required methods of JSQMessagesViewController Swift 3UITableView indexPath.row not increasingI am trying to append a message for my tableview but it is not appending.please help meSwift vertical UICollectionView inside UITableView

It's a yearly task, alright

Good allowance savings plan?

How is the Swiss post e-voting system supposed to work, and how was it wrong?

Can infringement of a trademark be pursued for using a company's name in a sentence?

Playing ONE triplet (not three)

Is "history" a male-biased word ("his+story")?

Replacing Windows 7 security updates with anti-virus?

How to make readers know that my work has used a hidden constraint?

"One can do his homework in the library"

Is having access to past exams cheating and, if yes, could it be proven just by a good grade?

What has been your most complicated TikZ drawing?

Is King K. Rool's down throw to up-special a true combo?

If Invisibility ends because the original caster casts a non-concentration spell, does Invisibility also end on other targets of the original casting?

Why must traveling waves have the same amplitude to form a standing wave?

When were linguistics departments first established

Identifying the interval from A♭ to D♯

Do I need to leave some extra space available on the disk which my database log files reside, for log backup operations to successfully occur?

Making a sword in the stone, in a medieval world without magic

Should QA ask requirements to developers?

Deleting missing values from a dataset

What is the dot in “1.2.4."

Is a lawful good "antagonist" effective?

Running a subshell from the middle of the current command

What to do when during a meeting client people start to fight (even physically) with each others?



Why does my app fail to display the alert message to turn on Location Services in prepare(for:sender)?



2019 Community Moderator ElectionHow to detect tableView cell touched or clicked in swiftExpand and Collapse tableview cellsUpdate or reload UITableView after completion of delete action on detail viewhow to load value in textbox from datepicker in tableviewthread 1: exc_bad_instruction(code=exc_1386_invop,subcode=0x0)TableView not displaying text with JSON data from API callCan't implement required methods of JSQMessagesViewController Swift 3UITableView indexPath.row not increasingI am trying to append a message for my tableview but it is not appending.please help meSwift vertical UICollectionView inside UITableView










-1















I am building a navigation app that prompts the user to turn on location services. If the user selects no to turning them on and he/she returns back to my app, my app refuses to launch the same prompt to turn on location services when I put a call to locationManager.requestWhenInUseAuthorization() in prepare(for:send) before segue transition is executed.



Can anyone suggest why the turn on location services alert is not displayed in prepare(for:sender)?



Thanks.



//
// CountiesTableVC.swift
// TableViewsApp
//
// Created by Stephen Learmonth on 10/12/2018.
// Copyright © 2018 Stephen Learmonth. All rights reserved.
//

import UIKit
import CoreLocation
import MapKit

class CountiesTableVC: UITableViewController

let england : England = England()
var countiesArray : [String] = ["Northamptonshire",
"Bedfordshire",
"Hertfordshire",
"Staffordshire",
"Essex",
"North Yorkshire",
"Herefordshire",
"Cornwall",
"Dorset",
"Derbyshire",
"Leicestershire",
"Lancashire",
"Cheshire",
"Merseyside",
"Suffolk",
"County Durham",
"Cumbria",
"Gloucestershire",
"Wiltshire",
"Nottinghamshire",
"Devon",
"Somerset",
"Lincolnshire"
]
var sortedCounties : [ String ] = []

var selectedCounty : String? = nil

var currentCoordinate: CLLocationCoordinate2D! = nil
var locationManager = CLLocationManager()

override func viewDidLoad()

super.viewDidLoad()

locationManager.delegate = self
locationManager.desiredAccuracy = kCLLocationAccuracyBestForNavigation
locationManager.distanceFilter = 10.0
//
// print("inside viewDidLoad() BEFORE IF authorizationStatus = (CLLocationManager.authorizationStatus().rawValue)")
//
if CLLocationManager.authorizationStatus() != .authorizedWhenInUse
//
// print("inside viewDidLoad() & IF BEFORE call: authorizationStatus = (CLLocationManager.authorizationStatus().rawValue)")
//
// // prompts user to turn on location services
locationManager.requestWhenInUseAuthorization()
//
// print("inside viewDidLoad() & IF AFTER call: authorizationStatus = (CLLocationManager.authorizationStatus().rawValue)")


sortedCounties = countiesArray.sorted $0 < $1



// MARK: - Table view data source

override func numberOfSections(in tableView: UITableView) -> Int
// #warning Incomplete implementation, return the number of sections
return 1


override func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int
// #warning Incomplete implementation, return the number of rows
return sortedCounties.count



override func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell

let cell = tableView.dequeueReusableCell(withIdentifier: "CountyTableViewCell", for: indexPath) as! CountyTableViewCell

let county = sortedCounties[indexPath.row]
let countySites = england.counties[county]
var siteIsSelectable = false
if (countySites?.isEmpty)! == true

cell.backgroundColor = .gray
cell.isUserInteractionEnabled = false

else

siteIsSelectable = true
cell.backgroundColor = .blue
cell.isUserInteractionEnabled = true



cell.setLabel(cellLabel: sortedCounties[indexPath.row], selectable: siteIsSelectable)

return cell


// In a storyboard-based application, you will often want to do a little preparation before navigation
override func prepare(for segue: UIStoryboardSegue, sender: Any?)

if segue.identifier == "toSitesTableVC"

// if CLLocationManager.authorizationStatus() != .authorizedWhenInUse
////
// print("prepare(for:sender) inside BEFORE: authorizationStatus = (CLLocationManager.authorizationStatus().rawValue)")
////
// locationManager.requestWhenInUseAuthorization()
//
// print("prepare(for:sender) AFTER: authorizationStatus = (CLLocationManager.authorizationStatus().rawValue)")
//
// // authorized location status when app is in use; update current location
// locationManager.startUpdatingLocation()
//
//

let sitesTableVC = segue.destination as? SitesTableVC

if let indexPath = self.tableView.indexPathForSelectedRow

selectedCounty = sortedCounties[indexPath.row]
sitesTableVC?.selectedCounty = selectedCounty
sitesTableVC?.currentCoordinate = currentCoordinate





return





extension CountiesTableVC: CLLocationManagerDelegate

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

// print("inside locationManager(manager:didUpdateLocations")

// get current location if available
guard let currentLocation = locations.last else return

// print("inside locationManager(manager:didUpdateLocations) authorizationStatus = (CLLocationManager.authorizationStatus().rawValue)")

// get coordinates of current user location
currentCoordinate = currentLocation.coordinate

manager.stopUpdatingLocation()



func locationManager(_ manager: CLLocationManager, didChangeAuthorization status: CLAuthorizationStatus)

if status != .authorizedWhenInUse

// print("locationManager(manager:didChangeAuthorization) BEFORE: authorizationStatus = (CLLocationManager.authorizationStatus().rawValue)")
// print("locationManager(manager:didChangeAuthorization) BEFORE: status = (status.rawValue)")

manager.requestWhenInUseAuthorization()

// print("locationManager(manager:didChangeAuthorization) AFTER: authorizationStatus = (CLLocationManager.authorizationStatus().rawValue)")
// print("locationManager(manager:didChangeAuthorization) AFTER: status = (status.rawValue)")



// authorized location status when app is in use; update current location
manager.startUpdatingLocation()

return













share|improve this question






















  • Please only post relevant code.

    – rmaddy
    Mar 6 at 19:42















-1















I am building a navigation app that prompts the user to turn on location services. If the user selects no to turning them on and he/she returns back to my app, my app refuses to launch the same prompt to turn on location services when I put a call to locationManager.requestWhenInUseAuthorization() in prepare(for:send) before segue transition is executed.



Can anyone suggest why the turn on location services alert is not displayed in prepare(for:sender)?



Thanks.



//
// CountiesTableVC.swift
// TableViewsApp
//
// Created by Stephen Learmonth on 10/12/2018.
// Copyright © 2018 Stephen Learmonth. All rights reserved.
//

import UIKit
import CoreLocation
import MapKit

class CountiesTableVC: UITableViewController

let england : England = England()
var countiesArray : [String] = ["Northamptonshire",
"Bedfordshire",
"Hertfordshire",
"Staffordshire",
"Essex",
"North Yorkshire",
"Herefordshire",
"Cornwall",
"Dorset",
"Derbyshire",
"Leicestershire",
"Lancashire",
"Cheshire",
"Merseyside",
"Suffolk",
"County Durham",
"Cumbria",
"Gloucestershire",
"Wiltshire",
"Nottinghamshire",
"Devon",
"Somerset",
"Lincolnshire"
]
var sortedCounties : [ String ] = []

var selectedCounty : String? = nil

var currentCoordinate: CLLocationCoordinate2D! = nil
var locationManager = CLLocationManager()

override func viewDidLoad()

super.viewDidLoad()

locationManager.delegate = self
locationManager.desiredAccuracy = kCLLocationAccuracyBestForNavigation
locationManager.distanceFilter = 10.0
//
// print("inside viewDidLoad() BEFORE IF authorizationStatus = (CLLocationManager.authorizationStatus().rawValue)")
//
if CLLocationManager.authorizationStatus() != .authorizedWhenInUse
//
// print("inside viewDidLoad() & IF BEFORE call: authorizationStatus = (CLLocationManager.authorizationStatus().rawValue)")
//
// // prompts user to turn on location services
locationManager.requestWhenInUseAuthorization()
//
// print("inside viewDidLoad() & IF AFTER call: authorizationStatus = (CLLocationManager.authorizationStatus().rawValue)")


sortedCounties = countiesArray.sorted $0 < $1



// MARK: - Table view data source

override func numberOfSections(in tableView: UITableView) -> Int
// #warning Incomplete implementation, return the number of sections
return 1


override func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int
// #warning Incomplete implementation, return the number of rows
return sortedCounties.count



override func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell

let cell = tableView.dequeueReusableCell(withIdentifier: "CountyTableViewCell", for: indexPath) as! CountyTableViewCell

let county = sortedCounties[indexPath.row]
let countySites = england.counties[county]
var siteIsSelectable = false
if (countySites?.isEmpty)! == true

cell.backgroundColor = .gray
cell.isUserInteractionEnabled = false

else

siteIsSelectable = true
cell.backgroundColor = .blue
cell.isUserInteractionEnabled = true



cell.setLabel(cellLabel: sortedCounties[indexPath.row], selectable: siteIsSelectable)

return cell


// In a storyboard-based application, you will often want to do a little preparation before navigation
override func prepare(for segue: UIStoryboardSegue, sender: Any?)

if segue.identifier == "toSitesTableVC"

// if CLLocationManager.authorizationStatus() != .authorizedWhenInUse
////
// print("prepare(for:sender) inside BEFORE: authorizationStatus = (CLLocationManager.authorizationStatus().rawValue)")
////
// locationManager.requestWhenInUseAuthorization()
//
// print("prepare(for:sender) AFTER: authorizationStatus = (CLLocationManager.authorizationStatus().rawValue)")
//
// // authorized location status when app is in use; update current location
// locationManager.startUpdatingLocation()
//
//

let sitesTableVC = segue.destination as? SitesTableVC

if let indexPath = self.tableView.indexPathForSelectedRow

selectedCounty = sortedCounties[indexPath.row]
sitesTableVC?.selectedCounty = selectedCounty
sitesTableVC?.currentCoordinate = currentCoordinate





return





extension CountiesTableVC: CLLocationManagerDelegate

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

// print("inside locationManager(manager:didUpdateLocations")

// get current location if available
guard let currentLocation = locations.last else return

// print("inside locationManager(manager:didUpdateLocations) authorizationStatus = (CLLocationManager.authorizationStatus().rawValue)")

// get coordinates of current user location
currentCoordinate = currentLocation.coordinate

manager.stopUpdatingLocation()



func locationManager(_ manager: CLLocationManager, didChangeAuthorization status: CLAuthorizationStatus)

if status != .authorizedWhenInUse

// print("locationManager(manager:didChangeAuthorization) BEFORE: authorizationStatus = (CLLocationManager.authorizationStatus().rawValue)")
// print("locationManager(manager:didChangeAuthorization) BEFORE: status = (status.rawValue)")

manager.requestWhenInUseAuthorization()

// print("locationManager(manager:didChangeAuthorization) AFTER: authorizationStatus = (CLLocationManager.authorizationStatus().rawValue)")
// print("locationManager(manager:didChangeAuthorization) AFTER: status = (status.rawValue)")



// authorized location status when app is in use; update current location
manager.startUpdatingLocation()

return













share|improve this question






















  • Please only post relevant code.

    – rmaddy
    Mar 6 at 19:42













-1












-1








-1








I am building a navigation app that prompts the user to turn on location services. If the user selects no to turning them on and he/she returns back to my app, my app refuses to launch the same prompt to turn on location services when I put a call to locationManager.requestWhenInUseAuthorization() in prepare(for:send) before segue transition is executed.



Can anyone suggest why the turn on location services alert is not displayed in prepare(for:sender)?



Thanks.



//
// CountiesTableVC.swift
// TableViewsApp
//
// Created by Stephen Learmonth on 10/12/2018.
// Copyright © 2018 Stephen Learmonth. All rights reserved.
//

import UIKit
import CoreLocation
import MapKit

class CountiesTableVC: UITableViewController

let england : England = England()
var countiesArray : [String] = ["Northamptonshire",
"Bedfordshire",
"Hertfordshire",
"Staffordshire",
"Essex",
"North Yorkshire",
"Herefordshire",
"Cornwall",
"Dorset",
"Derbyshire",
"Leicestershire",
"Lancashire",
"Cheshire",
"Merseyside",
"Suffolk",
"County Durham",
"Cumbria",
"Gloucestershire",
"Wiltshire",
"Nottinghamshire",
"Devon",
"Somerset",
"Lincolnshire"
]
var sortedCounties : [ String ] = []

var selectedCounty : String? = nil

var currentCoordinate: CLLocationCoordinate2D! = nil
var locationManager = CLLocationManager()

override func viewDidLoad()

super.viewDidLoad()

locationManager.delegate = self
locationManager.desiredAccuracy = kCLLocationAccuracyBestForNavigation
locationManager.distanceFilter = 10.0
//
// print("inside viewDidLoad() BEFORE IF authorizationStatus = (CLLocationManager.authorizationStatus().rawValue)")
//
if CLLocationManager.authorizationStatus() != .authorizedWhenInUse
//
// print("inside viewDidLoad() & IF BEFORE call: authorizationStatus = (CLLocationManager.authorizationStatus().rawValue)")
//
// // prompts user to turn on location services
locationManager.requestWhenInUseAuthorization()
//
// print("inside viewDidLoad() & IF AFTER call: authorizationStatus = (CLLocationManager.authorizationStatus().rawValue)")


sortedCounties = countiesArray.sorted $0 < $1



// MARK: - Table view data source

override func numberOfSections(in tableView: UITableView) -> Int
// #warning Incomplete implementation, return the number of sections
return 1


override func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int
// #warning Incomplete implementation, return the number of rows
return sortedCounties.count



override func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell

let cell = tableView.dequeueReusableCell(withIdentifier: "CountyTableViewCell", for: indexPath) as! CountyTableViewCell

let county = sortedCounties[indexPath.row]
let countySites = england.counties[county]
var siteIsSelectable = false
if (countySites?.isEmpty)! == true

cell.backgroundColor = .gray
cell.isUserInteractionEnabled = false

else

siteIsSelectable = true
cell.backgroundColor = .blue
cell.isUserInteractionEnabled = true



cell.setLabel(cellLabel: sortedCounties[indexPath.row], selectable: siteIsSelectable)

return cell


// In a storyboard-based application, you will often want to do a little preparation before navigation
override func prepare(for segue: UIStoryboardSegue, sender: Any?)

if segue.identifier == "toSitesTableVC"

// if CLLocationManager.authorizationStatus() != .authorizedWhenInUse
////
// print("prepare(for:sender) inside BEFORE: authorizationStatus = (CLLocationManager.authorizationStatus().rawValue)")
////
// locationManager.requestWhenInUseAuthorization()
//
// print("prepare(for:sender) AFTER: authorizationStatus = (CLLocationManager.authorizationStatus().rawValue)")
//
// // authorized location status when app is in use; update current location
// locationManager.startUpdatingLocation()
//
//

let sitesTableVC = segue.destination as? SitesTableVC

if let indexPath = self.tableView.indexPathForSelectedRow

selectedCounty = sortedCounties[indexPath.row]
sitesTableVC?.selectedCounty = selectedCounty
sitesTableVC?.currentCoordinate = currentCoordinate





return





extension CountiesTableVC: CLLocationManagerDelegate

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

// print("inside locationManager(manager:didUpdateLocations")

// get current location if available
guard let currentLocation = locations.last else return

// print("inside locationManager(manager:didUpdateLocations) authorizationStatus = (CLLocationManager.authorizationStatus().rawValue)")

// get coordinates of current user location
currentCoordinate = currentLocation.coordinate

manager.stopUpdatingLocation()



func locationManager(_ manager: CLLocationManager, didChangeAuthorization status: CLAuthorizationStatus)

if status != .authorizedWhenInUse

// print("locationManager(manager:didChangeAuthorization) BEFORE: authorizationStatus = (CLLocationManager.authorizationStatus().rawValue)")
// print("locationManager(manager:didChangeAuthorization) BEFORE: status = (status.rawValue)")

manager.requestWhenInUseAuthorization()

// print("locationManager(manager:didChangeAuthorization) AFTER: authorizationStatus = (CLLocationManager.authorizationStatus().rawValue)")
// print("locationManager(manager:didChangeAuthorization) AFTER: status = (status.rawValue)")



// authorized location status when app is in use; update current location
manager.startUpdatingLocation()

return













share|improve this question














I am building a navigation app that prompts the user to turn on location services. If the user selects no to turning them on and he/she returns back to my app, my app refuses to launch the same prompt to turn on location services when I put a call to locationManager.requestWhenInUseAuthorization() in prepare(for:send) before segue transition is executed.



Can anyone suggest why the turn on location services alert is not displayed in prepare(for:sender)?



Thanks.



//
// CountiesTableVC.swift
// TableViewsApp
//
// Created by Stephen Learmonth on 10/12/2018.
// Copyright © 2018 Stephen Learmonth. All rights reserved.
//

import UIKit
import CoreLocation
import MapKit

class CountiesTableVC: UITableViewController

let england : England = England()
var countiesArray : [String] = ["Northamptonshire",
"Bedfordshire",
"Hertfordshire",
"Staffordshire",
"Essex",
"North Yorkshire",
"Herefordshire",
"Cornwall",
"Dorset",
"Derbyshire",
"Leicestershire",
"Lancashire",
"Cheshire",
"Merseyside",
"Suffolk",
"County Durham",
"Cumbria",
"Gloucestershire",
"Wiltshire",
"Nottinghamshire",
"Devon",
"Somerset",
"Lincolnshire"
]
var sortedCounties : [ String ] = []

var selectedCounty : String? = nil

var currentCoordinate: CLLocationCoordinate2D! = nil
var locationManager = CLLocationManager()

override func viewDidLoad()

super.viewDidLoad()

locationManager.delegate = self
locationManager.desiredAccuracy = kCLLocationAccuracyBestForNavigation
locationManager.distanceFilter = 10.0
//
// print("inside viewDidLoad() BEFORE IF authorizationStatus = (CLLocationManager.authorizationStatus().rawValue)")
//
if CLLocationManager.authorizationStatus() != .authorizedWhenInUse
//
// print("inside viewDidLoad() & IF BEFORE call: authorizationStatus = (CLLocationManager.authorizationStatus().rawValue)")
//
// // prompts user to turn on location services
locationManager.requestWhenInUseAuthorization()
//
// print("inside viewDidLoad() & IF AFTER call: authorizationStatus = (CLLocationManager.authorizationStatus().rawValue)")


sortedCounties = countiesArray.sorted $0 < $1



// MARK: - Table view data source

override func numberOfSections(in tableView: UITableView) -> Int
// #warning Incomplete implementation, return the number of sections
return 1


override func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int
// #warning Incomplete implementation, return the number of rows
return sortedCounties.count



override func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell

let cell = tableView.dequeueReusableCell(withIdentifier: "CountyTableViewCell", for: indexPath) as! CountyTableViewCell

let county = sortedCounties[indexPath.row]
let countySites = england.counties[county]
var siteIsSelectable = false
if (countySites?.isEmpty)! == true

cell.backgroundColor = .gray
cell.isUserInteractionEnabled = false

else

siteIsSelectable = true
cell.backgroundColor = .blue
cell.isUserInteractionEnabled = true



cell.setLabel(cellLabel: sortedCounties[indexPath.row], selectable: siteIsSelectable)

return cell


// In a storyboard-based application, you will often want to do a little preparation before navigation
override func prepare(for segue: UIStoryboardSegue, sender: Any?)

if segue.identifier == "toSitesTableVC"

// if CLLocationManager.authorizationStatus() != .authorizedWhenInUse
////
// print("prepare(for:sender) inside BEFORE: authorizationStatus = (CLLocationManager.authorizationStatus().rawValue)")
////
// locationManager.requestWhenInUseAuthorization()
//
// print("prepare(for:sender) AFTER: authorizationStatus = (CLLocationManager.authorizationStatus().rawValue)")
//
// // authorized location status when app is in use; update current location
// locationManager.startUpdatingLocation()
//
//

let sitesTableVC = segue.destination as? SitesTableVC

if let indexPath = self.tableView.indexPathForSelectedRow

selectedCounty = sortedCounties[indexPath.row]
sitesTableVC?.selectedCounty = selectedCounty
sitesTableVC?.currentCoordinate = currentCoordinate





return





extension CountiesTableVC: CLLocationManagerDelegate

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

// print("inside locationManager(manager:didUpdateLocations")

// get current location if available
guard let currentLocation = locations.last else return

// print("inside locationManager(manager:didUpdateLocations) authorizationStatus = (CLLocationManager.authorizationStatus().rawValue)")

// get coordinates of current user location
currentCoordinate = currentLocation.coordinate

manager.stopUpdatingLocation()



func locationManager(_ manager: CLLocationManager, didChangeAuthorization status: CLAuthorizationStatus)

if status != .authorizedWhenInUse

// print("locationManager(manager:didChangeAuthorization) BEFORE: authorizationStatus = (CLLocationManager.authorizationStatus().rawValue)")
// print("locationManager(manager:didChangeAuthorization) BEFORE: status = (status.rawValue)")

manager.requestWhenInUseAuthorization()

// print("locationManager(manager:didChangeAuthorization) AFTER: authorizationStatus = (CLLocationManager.authorizationStatus().rawValue)")
// print("locationManager(manager:didChangeAuthorization) AFTER: status = (status.rawValue)")



// authorized location status when app is in use; update current location
manager.startUpdatingLocation()

return










ios swift location-services






share|improve this question













share|improve this question











share|improve this question




share|improve this question










asked Mar 6 at 17:46









sjlearmonthsjlearmonth

15




15












  • Please only post relevant code.

    – rmaddy
    Mar 6 at 19:42

















  • Please only post relevant code.

    – rmaddy
    Mar 6 at 19:42
















Please only post relevant code.

– rmaddy
Mar 6 at 19:42





Please only post relevant code.

– rmaddy
Mar 6 at 19:42












2 Answers
2






active

oldest

votes


















0














You can request iOS up to 2 times for location services, If the user cancel to turn on location services both times, then next time app requests requestWhenInUseAuthorization no alert is displayed.



Here you can tell if user has disabled core location by calling CLLocationManager class method locationServicesEnabled. Then you can present your own custom alert to guide user to turn on location services manually from iOS settings app.






share|improve this answer






























    0














    From the documentation:




    When the current authorization status is CLAuthorizationStatus.notDetermined, this method runs asynchronously and prompts the user to grant permission to the app to use location services. The user prompt contains the text from the NSLocationWhenInUseUsageDescription key in your app’s Info.plist file, and the presence of that key is required when calling this method. After the status is determined, the location manager delivers the results to the delegate’s locationManager(_:didChangeAuthorization:) method. If the current authorization status is anything other than CLAuthorizationStatus.notDetermined, this method does nothing and does not call the locationManager(_:didChangeAuthorization:) method.




    (emphasis mine)



    ie. once your user has answered the permission dialog, it will never be shown again.






    share|improve this answer






















      Your Answer






      StackExchange.ifUsing("editor", function ()
      StackExchange.using("externalEditor", function ()
      StackExchange.using("snippets", function ()
      StackExchange.snippets.init();
      );
      );
      , "code-snippets");

      StackExchange.ready(function()
      var channelOptions =
      tags: "".split(" "),
      id: "1"
      ;
      initTagRenderer("".split(" "), "".split(" "), channelOptions);

      StackExchange.using("externalEditor", function()
      // Have to fire editor after snippets, if snippets enabled
      if (StackExchange.settings.snippets.snippetsEnabled)
      StackExchange.using("snippets", function()
      createEditor();
      );

      else
      createEditor();

      );

      function createEditor()
      StackExchange.prepareEditor(
      heartbeatType: 'answer',
      autoActivateHeartbeat: false,
      convertImagesToLinks: true,
      noModals: true,
      showLowRepImageUploadWarning: true,
      reputationToPostImages: 10,
      bindNavPrevention: true,
      postfix: "",
      imageUploader:
      brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
      contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
      allowUrls: true
      ,
      onDemand: true,
      discardSelector: ".discard-answer"
      ,immediatelyShowMarkdownHelp:true
      );



      );













      draft saved

      draft discarded


















      StackExchange.ready(
      function ()
      StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55029272%2fwhy-does-my-app-fail-to-display-the-alert-message-to-turn-on-location-services-i%23new-answer', 'question_page');

      );

      Post as a guest















      Required, but never shown

























      2 Answers
      2






      active

      oldest

      votes








      2 Answers
      2






      active

      oldest

      votes









      active

      oldest

      votes






      active

      oldest

      votes









      0














      You can request iOS up to 2 times for location services, If the user cancel to turn on location services both times, then next time app requests requestWhenInUseAuthorization no alert is displayed.



      Here you can tell if user has disabled core location by calling CLLocationManager class method locationServicesEnabled. Then you can present your own custom alert to guide user to turn on location services manually from iOS settings app.






      share|improve this answer



























        0














        You can request iOS up to 2 times for location services, If the user cancel to turn on location services both times, then next time app requests requestWhenInUseAuthorization no alert is displayed.



        Here you can tell if user has disabled core location by calling CLLocationManager class method locationServicesEnabled. Then you can present your own custom alert to guide user to turn on location services manually from iOS settings app.






        share|improve this answer

























          0












          0








          0







          You can request iOS up to 2 times for location services, If the user cancel to turn on location services both times, then next time app requests requestWhenInUseAuthorization no alert is displayed.



          Here you can tell if user has disabled core location by calling CLLocationManager class method locationServicesEnabled. Then you can present your own custom alert to guide user to turn on location services manually from iOS settings app.






          share|improve this answer













          You can request iOS up to 2 times for location services, If the user cancel to turn on location services both times, then next time app requests requestWhenInUseAuthorization no alert is displayed.



          Here you can tell if user has disabled core location by calling CLLocationManager class method locationServicesEnabled. Then you can present your own custom alert to guide user to turn on location services manually from iOS settings app.







          share|improve this answer












          share|improve this answer



          share|improve this answer










          answered Mar 6 at 18:22









          Manpreet Singh BrarManpreet Singh Brar

          64




          64























              0














              From the documentation:




              When the current authorization status is CLAuthorizationStatus.notDetermined, this method runs asynchronously and prompts the user to grant permission to the app to use location services. The user prompt contains the text from the NSLocationWhenInUseUsageDescription key in your app’s Info.plist file, and the presence of that key is required when calling this method. After the status is determined, the location manager delivers the results to the delegate’s locationManager(_:didChangeAuthorization:) method. If the current authorization status is anything other than CLAuthorizationStatus.notDetermined, this method does nothing and does not call the locationManager(_:didChangeAuthorization:) method.




              (emphasis mine)



              ie. once your user has answered the permission dialog, it will never be shown again.






              share|improve this answer



























                0














                From the documentation:




                When the current authorization status is CLAuthorizationStatus.notDetermined, this method runs asynchronously and prompts the user to grant permission to the app to use location services. The user prompt contains the text from the NSLocationWhenInUseUsageDescription key in your app’s Info.plist file, and the presence of that key is required when calling this method. After the status is determined, the location manager delivers the results to the delegate’s locationManager(_:didChangeAuthorization:) method. If the current authorization status is anything other than CLAuthorizationStatus.notDetermined, this method does nothing and does not call the locationManager(_:didChangeAuthorization:) method.




                (emphasis mine)



                ie. once your user has answered the permission dialog, it will never be shown again.






                share|improve this answer

























                  0












                  0








                  0







                  From the documentation:




                  When the current authorization status is CLAuthorizationStatus.notDetermined, this method runs asynchronously and prompts the user to grant permission to the app to use location services. The user prompt contains the text from the NSLocationWhenInUseUsageDescription key in your app’s Info.plist file, and the presence of that key is required when calling this method. After the status is determined, the location manager delivers the results to the delegate’s locationManager(_:didChangeAuthorization:) method. If the current authorization status is anything other than CLAuthorizationStatus.notDetermined, this method does nothing and does not call the locationManager(_:didChangeAuthorization:) method.




                  (emphasis mine)



                  ie. once your user has answered the permission dialog, it will never be shown again.






                  share|improve this answer













                  From the documentation:




                  When the current authorization status is CLAuthorizationStatus.notDetermined, this method runs asynchronously and prompts the user to grant permission to the app to use location services. The user prompt contains the text from the NSLocationWhenInUseUsageDescription key in your app’s Info.plist file, and the presence of that key is required when calling this method. After the status is determined, the location manager delivers the results to the delegate’s locationManager(_:didChangeAuthorization:) method. If the current authorization status is anything other than CLAuthorizationStatus.notDetermined, this method does nothing and does not call the locationManager(_:didChangeAuthorization:) method.




                  (emphasis mine)



                  ie. once your user has answered the permission dialog, it will never be shown again.







                  share|improve this answer












                  share|improve this answer



                  share|improve this answer










                  answered Mar 6 at 18:36









                  GereonGereon

                  6,79041847




                  6,79041847



























                      draft saved

                      draft discarded
















































                      Thanks for contributing an answer to Stack Overflow!


                      • Please be sure to answer the question. Provide details and share your research!

                      But avoid


                      • Asking for help, clarification, or responding to other answers.

                      • Making statements based on opinion; back them up with references or personal experience.

                      To learn more, see our tips on writing great answers.




                      draft saved


                      draft discarded














                      StackExchange.ready(
                      function ()
                      StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55029272%2fwhy-does-my-app-fail-to-display-the-alert-message-to-turn-on-location-services-i%23new-answer', 'question_page');

                      );

                      Post as a guest















                      Required, but never shown





















































                      Required, but never shown














                      Required, but never shown












                      Required, but never shown







                      Required, but never shown

































                      Required, but never shown














                      Required, but never shown












                      Required, but never shown







                      Required, but never shown







                      Popular posts from this blog

                      Save data to MySQL database using ExtJS and PHP [closed]2019 Community Moderator ElectionHow can I prevent SQL injection in PHP?Which MySQL data type to use for storing boolean valuesPHP: Delete an element from an arrayHow do I connect to a MySQL Database in Python?Should I use the datetime or timestamp data type in MySQL?How to get a list of MySQL user accountsHow Do You Parse and Process HTML/XML in PHP?Reference — What does this symbol mean in PHP?How does PHP 'foreach' actually work?Why shouldn't I use mysql_* functions in PHP?

                      Compiling GNU Global with universal-ctags support Announcing the arrival of Valued Associate #679: Cesar Manara Planned maintenance scheduled April 23, 2019 at 23:30 UTC (7:30pm US/Eastern) Data science time! April 2019 and salary with experience The Ask Question Wizard is Live!Tags for Emacs: Relationship between etags, ebrowse, cscope, GNU Global and exuberant ctagsVim and Ctags tips and trickscscope or ctags why choose one over the other?scons and ctagsctags cannot open option file “.ctags”Adding tag scopes in universal-ctagsShould I use Universal-ctags?Universal ctags on WindowsHow do I install GNU Global with universal ctags support using Homebrew?Universal ctags with emacsHow to highlight ctags generated by Universal Ctags in Vim?

                      Add ONERROR event to image from jsp tldHow to add an image to a JPanel?Saving image from PHP URLHTML img scalingCheck if an image is loaded (no errors) with jQueryHow to force an <img> to take up width, even if the image is not loadedHow do I populate hidden form field with a value set in Spring ControllerStyling Raw elements Generated from JSP tagds with Jquery MobileLimit resizing of images with explicitly set width and height attributeserror TLD use in a jsp fileJsp tld files cannot be resolved