Usługi lokalizacji nie działają w systemie iOS 8
Moja aplikacja, która działała dobrze na iOS 7, nie działa z zestawem SDK iOS 8.
CLLocationManager
nie zwraca lokalizacji i nie widzę mojej aplikacji w ustawieniach -> usługi lokalizacji albo. Szukałem w Google, ale nic nie znalazłem. Co może być nie tak?
26 answers
Rozwiązałem swój własny problem.
Widocznie w iOS 8 SDK, requestAlwaysAuthorization
(dla lokalizacji w tle) lub requestWhenInUseAuthorization
(Lokalizacja tylko gdy pierwszy plan) wywołanie CLLocationManager
jest potrzebne przed rozpoczęciem aktualizacji lokalizacji.
W polu NSLocationAlwaysUsageDescription
lub NSLocationWhenInUseUsageDescription
musi być również klucz Info.plist
z komunikatem, który ma być wyświetlony w monicie. Dodanie tych rozwiązało mój problem.
EDIT: aby uzyskać więcej informacji, zajrzyj na: Core-Location-Manager-Changes-in-ios-8
Warning: date(): Invalid date.timezone value 'Europe/Kyiv', we selected the timezone 'UTC' for now. in /var/www/agent_stack/data/www/doraprojects.net/template/agent.layouts/content.php on line 54
2016-02-03 03:06:58
Wyrywałam włosy z tym samym problemem. Xcode daje błąd:
Próba uruchomienia
MapKit
aktualizacji lokalizacji bez monitu o autoryzacja lokalizacji. Musi najpierw zadzwonić-[CLLocationManager requestWhenInUseAuthorization]
lub-[CLLocationManager requestAlwaysAuthorization]
.
Ale nawet jeśli zaimplementujesz jedną z powyższych metod, nie zapyta użytkownika, chyba że w informacji jest wpis.plist dla NSLocationAlwaysUsageDescription
lub NSLocationWhenInUseUsageDescription
.
Dodaj następujące linie do swoich informacji.plist, gdzie wartości ciągu reprezentują powód, dla którego musisz dostęp do lokalizacji użytkowników
<key>NSLocationWhenInUseUsageDescription</key>
<string>This application requires location services to work</string>
<key>NSLocationAlwaysUsageDescription</key>
<string>This application requires location services to work</string>
Myślę, że tych wpisów mogło brakować odkąd zacząłem ten projekt w Xcode 5. Zgaduję, że Xcode 6 może dodać domyślne wpisy dla tych kluczy, ale nie zostały potwierdzone.
Więcej informacji na temat tych dwóch ustawień znajdziesz tutaj
Warning: date(): Invalid date.timezone value 'Europe/Kyiv', we selected the timezone 'UTC' for now. in /var/www/agent_stack/data/www/doraprojects.net/template/agent.layouts/content.php on line 54
2016-01-15 17:09:12
Aby upewnić się, że jest wstecznie kompatybilny z iOS 7, należy sprawdzić, czy użytkownik ma system iOS 8 lub iOS 7. Na przykład:
#define IS_OS_8_OR_LATER ([[[UIDevice currentDevice] systemVersion] floatValue] >= 8.0)
//In ViewDidLoad
if(IS_OS_8_OR_LATER) {
[self.locationManager requestAlwaysAuthorization];
}
[self.locationManager startUpdatingLocation];
Warning: date(): Invalid date.timezone value 'Europe/Kyiv', we selected the timezone 'UTC' for now. in /var/www/agent_stack/data/www/doraprojects.net/template/agent.layouts/content.php on line 54
2014-06-27 01:14:05
- (void)startLocationManager
{
locationManager = [[CLLocationManager alloc] init];
locationManager.delegate = self;
locationManager.distanceFilter = kCLDistanceFilterNone; //whenever we move
locationManager.desiredAccuracy = kCLLocationAccuracyBest;
[locationManager startUpdatingLocation];
[locationManager requestWhenInUseAuthorization]; // Add This Line
}
I do Twoich informacji.plik plist
Warning: date(): Invalid date.timezone value 'Europe/Kyiv', we selected the timezone 'UTC' for now. in /var/www/agent_stack/data/www/doraprojects.net/template/agent.layouts/content.php on line 54
2015-10-11 20:34:20
Według dokumentów Apple:
- https://developer.apple.com/documentation/corelocation/requesting_permission_to_use_location_services
- https://developer.apple.com/documentation/corelocation/cllocationmanager/1620562-requestwheninuseauthorization
NSLocationWhenInUseUsageDescription
LUB NSLocationAlwaysUsageDescription
.plik plist jest wymagany. Konieczne jest również poproszenie użytkownika o pozwolenie przed rejestracją w przypadku aktualizacji lokalizacji, poprzez wywołanie [self.myLocationManager requestWhenInUseAuthorization]
lub [self.myLocationManager requestAlwaysAuthorization]
w zależności od potrzeb. Ciąg, który wprowadziłeś do informacji.plist zostanie wyświetlony w następnym oknie dialogowym.
Jeśli użytkownik wyrazi na to zgodę, To będzie jak zwykle. Jeśli odmówią zgody, delegat nie jest informowany o aktualizacjach lokalizacji.
Warning: date(): Invalid date.timezone value 'Europe/Kyiv', we selected the timezone 'UTC' for now. in /var/www/agent_stack/data/www/doraprojects.net/template/agent.layouts/content.php on line 54
2017-06-29 17:06:26
- (void)viewDidLoad
{
[super viewDidLoad];
self.locationManager = [[CLLocationManager alloc] init];
self.locationManager.delegate = self;
if([self.locationManager respondsToSelector:@selector(requestAlwaysAuthorization)]){
NSUInteger code = [CLLocationManager authorizationStatus];
if (code == kCLAuthorizationStatusNotDetermined && ([self.locationManager respondsToSelector:@selector(requestAlwaysAuthorization)] || [self.locationManager respondsToSelector:@selector(requestWhenInUseAuthorization)])) {
// choose one request according to your business.
if([[NSBundle mainBundle] objectForInfoDictionaryKey:@"NSLocationAlwaysUsageDescription"]){
[self.locationManager requestAlwaysAuthorization];
} else if([[NSBundle mainBundle] objectForInfoDictionaryKey:@"NSLocationWhenInUseUsageDescription"]) {
[self.locationManager requestWhenInUseAuthorization];
} else {
NSLog(@"Info.plist does not contain NSLocationAlwaysUsageDescription or NSLocationWhenInUseUsageDescription");
}
}
}
[self.locationManager startUpdatingLocation];
}
> #pragma mark - CLLocationManagerDelegate
- (void)locationManager:(CLLocationManager *)manager didFailWithError:(NSError *)error
{
NSLog(@"didFailWithError: %@", error);
UIAlertView *errorAlert = [[UIAlertView alloc]
initWithTitle:@"Error" message:@"Failed to Get Your Location" delegate:nil cancelButtonTitle:@"OK" otherButtonTitles:nil];
[errorAlert show];
}
- (void)locationManager:(CLLocationManager *)manager didUpdateToLocation:(CLLocation *)newLocation fromLocation:(CLLocation *)oldLocation
{
NSLog(@"didUpdateToLocation: %@", newLocation);
CLLocation *currentLocation = newLocation;
if (currentLocation != nil) {
longitudeLabel.text = [NSString stringWithFormat:@"%.8f", currentLocation.coordinate.longitude];
latitudeLabel.text = [NSString stringWithFormat:@"%.8f", currentLocation.coordinate.latitude];
}
}
W iOS 8 musisz zrobić dwie dodatkowe rzeczy, aby Lokalizacja działała: Dodaj klucz do Twoich informacji.plist i poproś o autoryzację z lokalizacji kierownik prosi o start. Są dwie informacje.klucze plist do nowego autoryzacja lokalizacji. Jeden lub oba te klucze są wymagane. Jeśli nie ma żadnych kluczy, można zadzwonić do startUpdatingLocation, ale kierownik lokalizacji nie chce zacząć. Nie wyśle porażki wiadomość do delegata (ponieważ nigdy zaczęło się, nie może fail). Nie powiedzie się również, jeśli dodasz jeden lub oba klucze, ale zapomnisz aby wyraźnie zażądać autoryzacji. Więc pierwszą rzeczą, którą musisz zrobić jest dodanie jednego lub obu następujących kluczy do informacji.plik plist:
- NSLocationWhenInUseUsageDescription
- NSLocationAlwaysUsageDescription
Oba te klucze biorą łańcuch
Który jest opisem, dlaczego potrzebujesz usług lokalizacji. Możesz wpisz ciąg znaków jak "Lokalizacja jest wymagana, aby dowiedzieć się, gdzie jesteś" które, podobnie jak w iOS 7, można zlokalizować w InfoPlist.plik strings.
Warning: date(): Invalid date.timezone value 'Europe/Kyiv', we selected the timezone 'UTC' for now. in /var/www/agent_stack/data/www/doraprojects.net/template/agent.layouts/content.php on line 54
2015-06-22 05:02:53
Moje rozwiązanie, które można skompilować w Xcode 5:
#ifdef __IPHONE_8_0
NSUInteger code = [CLLocationManager authorizationStatus];
if (code == kCLAuthorizationStatusNotDetermined && ([self.locationManager respondsToSelector:@selector(requestAlwaysAuthorization)] || [self.locationManager respondsToSelector:@selector(requestWhenInUseAuthorization)])) {
// choose one request according to your business.
if([[NSBundle mainBundle] objectForInfoDictionaryKey:@"NSLocationAlwaysUsageDescription"]){
[self.locationManager requestAlwaysAuthorization];
} else if([[NSBundle mainBundle] objectForInfoDictionaryKey:@"NSLocationWhenInUseUsageDescription"]) {
[self.locationManager requestWhenInUseAuthorization];
} else {
NSLog(@"Info.plist does not contain NSLocationAlwaysUsageDescription or NSLocationWhenInUseUsageDescription");
}
}
#endif
[self.locationManager startUpdatingLocation];
Warning: date(): Invalid date.timezone value 'Europe/Kyiv', we selected the timezone 'UTC' for now. in /var/www/agent_stack/data/www/doraprojects.net/template/agent.layouts/content.php on line 54
2014-11-29 12:03:36
Stary kod do pytania o lokalizację nie będzie działał w iOS 8. Możesz wypróbować tę metodę autoryzacji lokalizacji:
- (void)requestAlwaysAuthorization
{
CLAuthorizationStatus status = [CLLocationManager authorizationStatus];
// If the status is denied or only granted for when in use, display an alert
if (status == kCLAuthorizationStatusAuthorizedWhenInUse || status == kCLAuthorizationStatusDenied) {
NSString *title;
title = (status == kCLAuthorizationStatusDenied) ? @"Location services are off" : @"Background location is not enabled";
NSString *message = @"To use background location you must turn on 'Always' in the Location Services Settings";
UIAlertView *alertView = [[UIAlertView alloc] initWithTitle:title
message:message
delegate:self
cancelButtonTitle:@"Cancel"
otherButtonTitles:@"Settings", nil];
[alertView show];
}
// The user has not enabled any location services. Request background authorization.
else if (status == kCLAuthorizationStatusNotDetermined) {
[self.locationManager requestAlwaysAuthorization];
}
}
- (void)alertView:(UIAlertView *)alertView clickedButtonAtIndex:(NSInteger)buttonIndex
{
if (buttonIndex == 1) {
// Send the user to the Settings for this app
NSURL *settingsURL = [NSURL URLWithString:UIApplicationOpenSettingsURLString];
[[UIApplication sharedApplication] openURL:settingsURL];
}
}
Warning: date(): Invalid date.timezone value 'Europe/Kyiv', we selected the timezone 'UTC' for now. in /var/www/agent_stack/data/www/doraprojects.net/template/agent.layouts/content.php on line 54
2014-11-29 12:04:26
W iOS 8 musisz zrobić dwie dodatkowe rzeczy, aby Lokalizacja działała: dodać klucz do swoich informacji.plist i zażądać autoryzacji od menedżera lokalizacji z prośbą o uruchomienie
Info.plist:
<key>NSLocationUsageDescription</key>
<string>I need location</string>
<key>NSLocationAlwaysUsageDescription</key>
<string>I need location</string>
<key>NSLocationWhenInUseUsageDescription</key>
<string>I need location</string>
Dodaj to do swojego kodu
if (IS_OS_8_OR_LATER)
{
[locationmanager requestWhenInUseAuthorization];
[locationmanager requestAlwaysAuthorization];
}
Warning: date(): Invalid date.timezone value 'Europe/Kyiv', we selected the timezone 'UTC' for now. in /var/www/agent_stack/data/www/doraprojects.net/template/agent.layouts/content.php on line 54
2018-04-18 05:14:35
Jeden wspólny błąd dla programistów Swift:
Najpierw upewnij się, że dodajesz wartość do pliku plist dla NSLocationWhenInUseUsageDescription
LUB NSLocationAlwaysUsageDescription
.
Jeśli nadal nie widzisz wyskakującego okna z prośbą o autoryzację, sprawdź, czy umieszczasz linię var locationManager = CLLocationManager()
w metodzie kontrolera widoku viewDidLoad
. Jeśli to zrobisz, to nawet jeśli zadzwonisz locationManager.requestWhenInUseAuthorization()
, nic się nie pojawi. Dzieje się tak dlatego, że po uruchomieniu viewDidLoad zmienna locationManager jest dealokowana (usuwana).
The rozwiązaniem jest zlokalizowanie linii var locationManager = CLLocationManager()
na szczycie metody klasowej.
Warning: date(): Invalid date.timezone value 'Europe/Kyiv', we selected the timezone 'UTC' for now. in /var/www/agent_stack/data/www/doraprojects.net/template/agent.layouts/content.php on line 54
2015-02-17 22:40:17
Przed [locationManager startUpdatingLocation];
Dodaj żądanie usługi lokalizacji iOS8:
if([locationManager respondsToSelector:@selector(requestAlwaysAuthorization)])
[locationManager requestAlwaysAuthorization];
Edytuj Info.plist
i dodaj klucz {[3] } z wartością ciągu znaków, która będzie wyświetlana użytkownikowi (na przykład, We do our best to preserve your battery life.
)
Jeśli aplikacja wymaga usług lokalizacji tylko wtedy, gdy aplikacja jest otwarta, zastąp:
requestAlwaysAuthorization
z requestWhenInUseAuthorization
i
NSLocationAlwaysUsageDescription
z NSLocationWhenInUseUsageDescription
.
Warning: date(): Invalid date.timezone value 'Europe/Kyiv', we selected the timezone 'UTC' for now. in /var/www/agent_stack/data/www/doraprojects.net/template/agent.layouts/content.php on line 54
2014-11-29 12:06:32
Pracowałem nad aplikacją, która została zaktualizowana do iOS 8 i usługi lokalizacji przestały działać. Prawdopodobnie dostaniesz i błąd w obszarze debugowania w ten sposób:
Trying to start MapKit location updates without prompting for location authorization. Must call -[CLLocationManager requestWhenInUseAuthorization] or -[CLLocationManager requestAlwaysAuthorization] first.
NSLocationAlwaysUsageDescription
do swoich informacji.plist:
Zauważ, że nie wypełniłem wartości tego klucza. To nadal działa, i nie jestem zaniepokojony, ponieważ jest to aplikacja w domu. Jest też już tytuł z prośbą o korzystanie z usług lokalizacji, więc nie chciałem robić wszystko zbędne.
Następnie utworzyłem warunkowy dla iOS 8:
if ([self.locationManager respondsToSelector:@selector(requestAlwaysAuthorization)]) {
[_locationManager requestAlwaysAuthorization];
}
Następnie metoda locationManager:didChangeAuthorizationStatus:
jest wywołaniem:
- (void)locationManager:(CLLocationManager *)manager didChangeAuthorizationStatus: (CLAuthorizationStatus)status
{
[self gotoCurrenLocation];
}
A teraz wszystko działa dobrze. Jak zawsze, Sprawdź dokumentację .Warning: date(): Invalid date.timezone value 'Europe/Kyiv', we selected the timezone 'UTC' for now. in /var/www/agent_stack/data/www/doraprojects.net/template/agent.layouts/content.php on line 54
2014-11-29 12:09:31
Rozwiązanie ze wsteczną kompatybilnością:
SEL requestSelector = NSSelectorFromString(@"requestWhenInUseAuthorization");
if ([CLLocationManager authorizationStatus] == kCLAuthorizationStatusNotDetermined &&
[self.locationManager respondsToSelector:requestSelector]) {
[self.locationManager performSelector:requestSelector withObject:NULL];
} else {
[self.locationManager startUpdatingLocation];
}
Setup nslocationwheninuseusagedescription key in your Info.plist
Warning: date(): Invalid date.timezone value 'Europe/Kyiv', we selected the timezone 'UTC' for now. in /var/www/agent_stack/data/www/doraprojects.net/template/agent.layouts/content.php on line 54
2014-09-11 06:37:31
Rozwiązanie z kompatybilnością wsteczną, która nie wyświetla ostrzeżeń Xcode:
SEL requestSelector = NSSelectorFromString(@"requestWhenInUseAuthorization");
if ([CLLocationManager authorizationStatus] == kCLAuthorizationStatusNotDetermined &&
[self.locationManager respondsToSelector:requestSelector]) {
((void (*)(id, SEL))[self.locationManager methodForSelector:requestSelector])(self.locationManager, requestSelector);
[self.locationManager startUpdatingLocation];
} else {
[self.locationManager startUpdatingLocation];
}
Konfiguracja NSLocationWhenInUseUsageDescription
klucz w twoim Info.plist
.
Dla iOS w wersji 11.0 + :
Setup NSLocationAlwaysAndWhenInUseUsageDescription
klucz w twoim Info.plist
. wraz z innymi 2 kluczami.
Warning: date(): Invalid date.timezone value 'Europe/Kyiv', we selected the timezone 'UTC' for now. in /var/www/agent_stack/data/www/doraprojects.net/template/agent.layouts/content.php on line 54
2018-04-18 05:16:56
To jest problem z ios 8 Dodaj to do swojego kodu
if (IS_OS_8_OR_LATER)
{
[locationmanager requestWhenInUseAuthorization];
[locationmanager requestAlwaysAuthorization];
}
I do informacji.plist:
<key>NSLocationUsageDescription</key>
<string>I need location</string>
<key>NSLocationAlwaysUsageDescription</key>
<string>I need location</string>
<key>NSLocationWhenInUseUsageDescription</key>
<string>I need location</string>
Warning: date(): Invalid date.timezone value 'Europe/Kyiv', we selected the timezone 'UTC' for now. in /var/www/agent_stack/data/www/doraprojects.net/template/agent.layouts/content.php on line 54
2015-09-02 07:20:20
Aby uzyskać dostęp do lokalizacji użytkownika w iOS 8 musisz dodać,
NSLocationAlwaysUsageDescription in the Info.plist
To poprosi użytkownika o pozwolenie na uzyskanie ich bieżącej lokalizacji.
Warning: date(): Invalid date.timezone value 'Europe/Kyiv', we selected the timezone 'UTC' for now. in /var/www/agent_stack/data/www/doraprojects.net/template/agent.layouts/content.php on line 54
2014-11-17 04:49:38
Dla osób używających Xamarin , musiałem dodać klucz NSLocationWhenInUseUsageDescription
do informacji.plist ręcznie, ponieważ nie był dostępny w rozwijanych Rozwijaniach w Xamarin 5.5.3 Build 6 lub XCode 6.1 - tylko NSLocationUsageDescription
był na liście, a to spowodowało, że CLLocationManager
nadal zawodził po cichu.
Warning: date(): Invalid date.timezone value 'Europe/Kyiv', we selected the timezone 'UTC' for now. in /var/www/agent_stack/data/www/doraprojects.net/template/agent.layouts/content.php on line 54
2014-11-21 16:51:19
Objective - C Procedure Postępuj zgodnie z poniższymi instrukcjami:
Dla iOS-11 Dla iOS 11 spójrz na tę odpowiedź: iOS 11 dostęp do lokalizacji
Trzeba dodać dwa klucze do plist i podać wiadomość jak na poniższym obrazku:
1. NSLocationAlwaysAndWhenInUseUsageDescription
2. NSLocationWhenInUseUsageDescription
3. NSLocationAlwaysUsageDescription
NSLocationWhenInUseUsageDescription
locationManager = [[CLLocationManager alloc] init];
locationManager.delegate = self;
locationManager.desiredAccuracy = kCLLocationAccuracyThreeKilometers;
if([locationManager respondsToSelector:@selector(requestWhenInUseAuthorization)]){
[locationManager requestWhenInUseAuthorization];
}else{
[locationManager startUpdatingLocation];
}
Metody Delegowania
#pragma mark - Lolcation Update
- (void)locationManager:(CLLocationManager *)manager didFailWithError:(NSError *)error
{
NSLog(@"didFailWithError: %@", error);
UIAlertView *errorAlert = [[UIAlertView alloc]
initWithTitle:@"Error" message:@"Failed to Get Your Location" delegate:nil cancelButtonTitle:@"OK" otherButtonTitles:nil];
[errorAlert show];
}
-(void)locationManager:(CLLocationManager *)manager didChangeAuthorizationStatus:(CLAuthorizationStatus)status
{
switch (status) {
case kCLAuthorizationStatusNotDetermined:
case kCLAuthorizationStatusRestricted:
case kCLAuthorizationStatusDenied:
{
// do some error handling
}
break;
default:{
[locationManager startUpdatingLocation];
}
break;
}
}
- (void)locationManager:(CLLocationManager *)manager
didUpdateLocations:(NSArray *)locations
{
CLLocation *location = [locations lastObject];
userLatitude = [NSString stringWithFormat:@"%f", location.coordinate.latitude] ;
userLongitude = [NSString stringWithFormat:@"%f",location.coordinate.longitude];
[locationManager stopUpdatingLocation];
}
Procedura Swift
Postępuj zgodnie z poniższym Instrukcja:
Dla iOS-11 Dla iOS 11 spójrz na tę odpowiedź: iOS 11 dostęp do lokalizacji
Trzeba dodać dwa klucze do plist i podać wiadomość jak na poniższym obrazku:
1. NSLocationAlwaysAndWhenInUseUsageDescription
2. NSLocationWhenInUseUsageDescription
3. NSLocationAlwaysUsageDescription
import CoreLocation
class ViewController: UIViewController ,CLLocationManagerDelegate {
var locationManager = CLLocationManager()
//MARK- Update Location
func updateMyLocation(){
locationManager.delegate = self;
locationManager.desiredAccuracy = kCLLocationAccuracyThreeKilometers;
if locationManager.respondsToSelector(#selector(CLLocationManager.requestWhenInUseAuthorization)){
locationManager.requestWhenInUseAuthorization()
}
else{
locationManager.startUpdatingLocation()
}
}
Metody Delegowania
//MARK: Location Update
func locationManager(manager: CLLocationManager, didFailWithError error: NSError) {
NSLog("Error to update location :%@",error)
}
func locationManager(manager: CLLocationManager, didChangeAuthorizationStatus status: CLAuthorizationStatus) {
switch status {
case .NotDetermined: break
case .Restricted: break
case .Denied:
NSLog("do some error handling")
break
default:
locationManager.startUpdatingLocation()
}
}
func locationManager(manager: CLLocationManager, didUpdateLocations locations: [CLLocation]) {
let location = locations.last! as CLLocation
var latitude = location.coordinate.latitude
var longitude = location.coordinate.longitude
}
Warning: date(): Invalid date.timezone value 'Europe/Kyiv', we selected the timezone 'UTC' for now. in /var/www/agent_stack/data/www/doraprojects.net/template/agent.layouts/content.php on line 54
2018-05-17 08:43:14
// ** Don't forget to add NSLocationWhenInUseUsageDescription in MyApp-Info.plist and give it a string
self.locationManager = [[CLLocationManager alloc] init];
self.locationManager.delegate = self;
// Check for iOS 8. Without this guard the code will crash with "unknown selector" on iOS 7.
if ([self.locationManager respondsToSelector:@selector(requestWhenInUseAuthorization)]) {
[self.locationManager requestWhenInUseAuthorization];
}
[self.locationManager startUpdatingLocation];
// Location Manager Delegate Methods
- (void)locationManager:(CLLocationManager *)manager didUpdateLocations:(NSArray *)locations
{
NSLog(@"%@", [locations lastObject]);
}
Warning: date(): Invalid date.timezone value 'Europe/Kyiv', we selected the timezone 'UTC' for now. in /var/www/agent_stack/data/www/doraprojects.net/template/agent.layouts/content.php on line 54
2014-11-18 13:58:39
Mały pomocnik dla wszystkich, którzy mają więcej niż jedną informację.plik plist...
find . -name Info.plist | xargs -I {} /usr/libexec/PlistBuddy -c 'Add NSLocationWhenInUseUsageDescription string' {}
Doda potrzebny znacznik do wszystkich informacji.pliki plist w bieżącym katalogu (i podfolderach).
Inny to:
find . -name Info.plist | xargs -I {} /usr/libexec/PlistBuddy -c 'Set NSLocationWhenInUseUsageDescription $YOURDESCRIPTION' {}
Doda twój opis do wszystkich plików.
Warning: date(): Invalid date.timezone value 'Europe/Kyiv', we selected the timezone 'UTC' for now. in /var/www/agent_stack/data/www/doraprojects.net/template/agent.layouts/content.php on line 54
2014-11-29 12:05:47
Przechowuj Klucze Cocoa Informacje zawsze na wyciągnięcie ręki dla tych aktualizacji, oto link:
Enjoy.
Warning: date(): Invalid date.timezone value 'Europe/Kyiv', we selected the timezone 'UTC' for now. in /var/www/agent_stack/data/www/doraprojects.net/template/agent.layouts/content.php on line 54
2015-07-30 23:51:02
Dostaję podobny błąd w iOS9 (praca z Xcode 7 i Swift 2): próba uruchomienia aktualizacji lokalizacji MapKit bez monitu o autoryzację lokalizacji. Musi najpierw wywołać - [cllocationmanager request wheninuseauthorization] lub - [cllocationmanager requestAlwaysAuthorization]. Śledziłem tutorial, ale tutor używał iOS8 i Swift 1.2. Są pewne zmiany w Xcode 7 i Swift 2, znalazłem ten kod i działa dobrze dla mnie (jeśli ktoś potrzebuje Pomoc):
import UIKit
import MapKit
import CoreLocation
class MapViewController: UIViewController, MKMapViewDelegate, CLLocationManagerDelegate {
// MARK: Properties
@IBOutlet weak var mapView: MKMapView!
let locationManager = CLLocationManager()
override func viewDidLoad() {
super.viewDidLoad()
self.locationManager.delegate = self
self.locationManager.desiredAccuracy = kCLLocationAccuracyBest
self.locationManager.requestWhenInUseAuthorization()
self.locationManager.startUpdatingLocation()
self.mapView.showsUserLocation = true
}
// MARK: - Location Delegate Methods
func locationManager(manager: CLLocationManager, didUpdateLocations locations: [CLLocation]) {
let location = locations.last
let center = CLLocationCoordinate2D(latitude: location!.coordinate.latitude, longitude: location!.coordinate.longitude)
let region = MKCoordinateRegion(center: center, span: MKCoordinateSpan(latitudeDelta: 1, longitudeDelta: 1))
self.mapView.setRegion(region, animated: true)
}
func locationManager(manager: CLLocationManager, didFailWithError error: NSError) {
print("Errors: " + error.localizedDescription)
}
}
W końcu dodałem to do info.plist:
Information Property List: NSLocationWhenInUseUsageDescription
Wartość: Aplikacja potrzebuje serwerów lokalizacji dla personelu Warning: date(): Invalid date.timezone value 'Europe/Kyiv', we selected the timezone 'UTC' for now. in /var/www/agent_stack/data/www/doraprojects.net/template/agent.layouts/content.php on line 54
2015-12-29 17:19:13
W celu uzyskania dostępu do lokalizacji użytkowników w systemie iOS. Musisz dodać dwa klucze
NSLocationWhenInUseUsageDescription
NSLocationAlwaysUsageDescription
W Info.plik plist.
<key>NSLocationWhenInUseUsageDescription</key>
<string>Because I want to know where you are!</string>
<key>NSLocationAlwaysUsageDescription</key>
<string>Want to know where you are!</string>
Zobacz poniższy obrazek.
Warning: date(): Invalid date.timezone value 'Europe/Kyiv', we selected the timezone 'UTC' for now. in /var/www/agent_stack/data/www/doraprojects.net/template/agent.layouts/content.php on line 54
2017-06-17 03:35:03
Dodaj klucz
NSLocationWhenInUseUsageDescription
lubNSLocationAlwaysUsageDescription
(użycie GPS w tle) z łańcuchem proszącym o użycie GPS na każdyminfo.plist
z każdego celu.-
Poproś o pozwolenie biegając:
[self initlocationmanager:locationManager];
Gdzie initLocationManager
jest:
// asks for GPS authorization on iOS 8
-(void) initLocationManager:(CLLocationManager *) locationManager{
locationManager = [[CLLocationManager alloc]init];
if([locationManager respondsToSelector:@selector(requestAlwaysAuthorization)])
[locationManager requestAlwaysAuthorization];
}
Pamiętaj, że jeśli klawiszy nie ma na każdym info.plist
dla każdego celu aplikacja nie zapyta użytkownika. if
zapewnia kompatybilność z iOS 7, a metoda respondsToSelector:
gwarantuje przyszłą kompatybilność raczej niż tylko rozwiązanie problemu dla iOS 7 i 8.
Warning: date(): Invalid date.timezone value 'Europe/Kyiv', we selected the timezone 'UTC' for now. in /var/www/agent_stack/data/www/doraprojects.net/template/agent.layouts/content.php on line 54
2014-11-16 22:04:17
Problem polegał na tym, że klasa, która była CLLocationManagerDelegate
, była prywatna, co uniemożliwiało wywołanie wszystkich metod delegatów. Myślę, że to nie jest bardzo powszechna sytuacja, ale pomyślałem, że wspomnę o tym na wypadek, gdyby t komuś pomógł.
Warning: date(): Invalid date.timezone value 'Europe/Kyiv', we selected the timezone 'UTC' for now. in /var/www/agent_stack/data/www/doraprojects.net/template/agent.layouts/content.php on line 54
2015-07-07 05:34:57
Dodaję te klucze w InfoPlist.strings
w iOS 8.4, iPad mini 2.To też działa. Nie ustawiam żadnego klucza, np. NSLocationWhenInUseUsageDescription
, w moim Info.plist
.
InfoPlist.ciągi :
"NSLocationWhenInUseUsageDescription" = "I need GPS information....";
Na podstawie tego wątku , powiedział, as in iOS 7
, można zlokalizować w InfoPlist.struny. W moim teście klucze te można skonfigurować bezpośrednio w pliku InfoPlist.strings
.
Więc pierwszą rzeczą, którą musisz zrobić, to dodać jeden lub oba > następujące klucze do swoich informacji.plik plist:
- NSLocationWhenInUseUsageDescription
- NSLocationAlwaysUsageDescription
Oba te klucze przyjmują ciąg znaków, który jest opisem, dlaczego ty potrzebujesz usług lokalizacyjnych. Możesz wprowadzić ciąg znaków jak " lokalizacja jest wymagane, aby dowiedzieć się, gdzie jesteś", który, jak w iOS 7 , może być zlokalizowane w InfoPlist.plik strings.
UPDATE:
Myślę @IOS
'metoda s jest lepsza. Dodaj klucz do Info.plist
z pustą wartością i dodaj zlokalizowane ciągi do InfoPlist.strings
.
Warning: date(): Invalid date.timezone value 'Europe/Kyiv', we selected the timezone 'UTC' for now. in /var/www/agent_stack/data/www/doraprojects.net/template/agent.layouts/content.php on line 54
2017-05-23 12:10:41