Tag: 位置

定期更新位置背景Swift 3.0 iOS 10

我做一个应用程序,当它进入后台我需要发送到服务器一些周期性的数据。 为了从后台唤醒,我使用后台更新的重要位置(较低的电池)。 我注意到,当从wifi / 3g手机细胞或3G时改变手机塔的位置更新,但我的问题是,如果用户不移动(然后手机塔不改变)的位置不更新和应用程序doest醒来,然后我不能发送数据到服务器。 你知道一些方法来解决这个问题吗? 我在AppDelegate文件中执行所有这些操作: class AppDelegate: UIResponder, UIApplicationDelegate , CLLocationManagerDelegate{ var manager = CLLocationManager() func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplicationLaunchOptionsKey: Any]?) -> Bool { manager.desiredAccuracy = kCLLocationAccuracyBest manager.delegate = self manager.requestAlwaysAuthorization() manager.allowsBackgroundLocationUpdates = true return true } func locationManager(_ manager: CLLocationManager, didUpdateLocations locations: [CLLocation]){ sendDataToServer() } func applicationDidEnterBackground(_ application: UIApplication) { […]

用户的位置和电池的消耗

我正在研究侧重于build筑物(校园)中的行人的iOS应用程序。 我已经开发了一个足够好的(我相信)用户的位置更新,但是,我想任何人比我更专家给我一些提示,build议准确的位置,电池的问题等。此外,是否有可能停止位置更新和n秒后再次启动? 是我为了节能而做的一个想法。 目前,应用程序正在检测当前位置,但蓝点(用户)仍在移动,我不喜欢这样。 有什么可以做的? 以下是我的didUpdateToLocation方法: 应用程序正在从一个文件(存储在设备上)读取build筑物的信息 – (void)viewDidLoad{ [super viewDidLoad]; if ([self checkForInternet]) { _locationManager = [[CLLocationManager alloc] init]; _locationManager.delegate = self; _locationManager.distanceFilter = 10.0f; _locationManager.desiredAccuracy = 20.0f; [_locationManager startUpdatingLocation]; } } – (void)locationManager:(CLLocationManager *)manager didUpdateToLocation:(CLLocation *)newLocation fromLocation:(CLLocation *)oldLocation { if (newLocation.horizontalAccuracy > manager.desiredAccuracy) return; [self.mapView removeAnnotations:listOfAnn]; [listOfAnn removeAllObjects]; if ([manager locationServicesEnabled]) { for […]

iOS 8 – 无法获取当前位置,错误域= kCLErrorDomain代码= 0

我有问题得到我的当前位置。 我仍然收到错误: Error Domain=kCLErrorDomain Code=0 "The operation couldn't be completed. (kCLErrorDomain error 0.)" 我已经做了我在这里find的所有东西: 重置iOS模拟器中的内容和设置(模拟器中的地图应用程序显示正确的位置)。 在Xcode的产品>计划>编辑我未标记的允许位置模拟(当我标记它,它模拟例如伦敦)。 我已经添加NSLocationWhenInUseUsageDescription Info.plist文件在我的项目(应用程序要求的位置的权限,我可以看到他们在设置在iOS模拟器)。 我打开了Wi-Fi连接(就像我说的位置服务在Safari,地图,甚至在iOS模拟器中的地图一样正常工作)。 -(void)viewDidLoad { [super viewDidLoad]; self.locationManager = [[CLLocationManager alloc] init]; self.locationManager.delegate = self; if(IS_OS_8_OR_LATER){ NSUInteger code = [CLLocationManager authorizationStatus]; if (code == kCLAuthorizationStatusNotDetermined && ([self.locationManager respondsToSelector:@selector(requestWhenInUseAuthorization)])) { if([[NSBundle mainBundle] objectForInfoDictionaryKey:@"NSLocationWhenInUseUsageDescription"]) { [self.locationManager requestWhenInUseAuthorization]; } else { NSLog(@"Info.plist […]

在CPTBarPlot上定位标签(Core-Plot)

我正在尝试使用Core-Plot更改条形图中标签的默认位置。 我正在使用这个方法: -(CPTLayer *)dataLabelForPlot:(CPTPlot *)plot recordIndex:(NSUInteger)idx; 我回来了: return textLayer = [[CPTTextLayer alloc] initWithText:@"2222" style:textStyle]; 我得到这个结果: 但是我想要显示如下: 任何想法? 我试图find关于文件的答案,但我已经不可能了。

重大的位置变化至less不会每15分钟触发一次

根据苹果文档,重要的位置变化应该至less每15分钟更新位置。 当我明显移动时,确实会收到更新,但在设备静止时不会收到更新。 你有什么更新的经验? 他们至less每15分钟来一次吗? 如果GPS级精度对您的应用程序不是至关重要的,并且您不需要连续跟踪,则可以使用重大更改位置服务。 正确使用重大更改位置服务至关重要,因为它至less每隔15分钟就会唤醒系统和应用程序,即使没有发生位置更改,也会持续运行,直到您停止。

如何从iOS 5的新iPhone上获取历史位置数据(供个人使用)?

它曾经很容易从iPhone上的一个名为consolidated.db的文件中获取历史位置数据(请参阅http://petewarden.github.com/iPhoneTracker/ )。 但是,这在新的iOS系统上更加困难。 你的数据仍然在你的手机上,而且有可能访问它吗? 要清楚,我不想使用位置API; 相反,我想将我的历史位置数据作为我的设备的最终用户。 有任何脚本/应用程序可以为我做这个吗?

Codename一个GPS提供者和当前位置

我正在使用代号为1的iOS应用程序。 我想获得当前位置并通过短信发送。 我从Java Android Studio获得了这个代码,我不知道如何获取当前位置,并检查GPS是否打开。 我在下面尝试,但没有成功(我不知道他们如何启动GPS,并获得位置) LocationManager service = (LocationManager) getSystemService(LOCATION_SERVICE); boolean enabledGPS = service.isProviderEnabled(LocationManager.GPS_PROVIDER); if (!enabledGPS) { //alert GPS is off } LocationManager locationManager = (LocationManager) getSystemService(Context.LOCATION_SERVICE); // Define the criteria how to select the location provider -> use // default Criteria criteria = new Criteria(); provider = locationManager.getBestProvider(criteria, false); Location location = locationManager.getLastKnownLocation(provider); […]

即使应用程序在相同的位置,信标的接近范围也会来回变化

信标接近范围将接近响应更改为近即时 – 即时,即使在ios设备保持在同一地点。 当我接近响应时,我打开一个视图。 我得到了接近的响应来回,近 – 即时然后近。 它一次又一次地显示出来的观点 我们如何解决这个问题。 有没有任何事件处理程序。 谢谢。

IOS获得位置

我有一个UIScrollView里面有很多的button,我试图让他们的位置button点击。 这是我的代码: UIScrollView *scrollView = [[UIScrollView alloc] initWithFrame:CGRectMake(2, 0, 262, 748)]; scrollView.contentSize=CGSizeMake(262, 816); scrollView.bounces=NO; scrollView.delaysContentTouches=YES; buton1 = [[UIButton buttonWithType:UIButtonTypeCustom] retain]; buton1.frame = CGRectMake(2, 0, 262, 102); buton1.bounds = CGRectMake(2, 0, 262.0, 102.0); [buton1 setTag:1]; [buton1 setImage:[UIImage imageNamed:@"left_gride.png"] forState:UIControlStateNormal]; [buton1 addTarget:self action:@selector(buttonClick:) forControlEvents:UIControlEventTouchUpInside]; [scrollView addSubview:buton1]; 和 -(void) buttonClick:(UIButton*)button{ if ([button tag]==1) { NSLog(@"position:%d",buton1.frame.origin.x); } else { […]

在后台模式下的iOS区域监控

我在我的应用程序中使用区域监视,我面临一个问题,我找不到任何答案。 区域监控如何在后台模式下工作? 根据地点意识PG: 每当用户的当前位置穿过边界区域,系统就会为您的应用程序生成适当的区域事件。 如果您的应用程序已经运行,则这些事件直接转到任何当前位置pipe理器对象的委托。 如果您的应用程序没有运行,系统将在后台启动它,以便它可以响应。 现在,这个问题是:我的应用程序处于暂停模式,一个区域已经被input,并且应该传递一个触发器,这个事件是否会直接发送给委托人: locationManager:didEnterRegion: ?? 同样的问题,如果应用程序在后台模式。 换句话说,有什么代码我应该考虑在暂停和后台模式来接收这个事件? 或者iOS将首先启动应用程序,然后将事件直接发送给代理,而不需要BG代码?