简体   繁体   English

当应用程序在后台时如何停止位置服务?

[英]How to stop location services when the app is in background?

In my app I load some sites in UIWebView.在我的应用程序中,我在 UIWebView 中加载了一些网站。 Some of these sites use location services.其中一些网站使用位置服务。

My problem is, that while viewing one of these sites, when the app goes to background, the location services are still on.我的问题是,在查看其中一个站点时,当应用程序进入后台时,位置服务仍然处于打开状态。 Since my app didn't turn them on - I don't know what to do.由于我的应用程序没有打开它们 - 我不知道该怎么做。

The current solution I have is loading a blank page when going to background, then loading the original site back when moving to foreground.我目前的解决方案是在进入后台时加载一个空白页面,然后在移动到前台时加载原始站点。 It works, but the blank page is visible to the user, when viewing the app - which isn't very good.它可以工作,但是在查看应用程序时,用户可以看到空白页面 - 这不是很好。

Does anyone have other ideas?有没有人有其他想法?

You can go to location services in settings and turn off any apps using location services.您可以 go 在settingslocation services并关闭任何使用定位服务的应用程序。 Mine was thumb speak that was running and sucking battery life down.我的是拇指说话,它正在运行并缩短电池寿命。

You can quit the app instead of sending in background.您可以退出应用程序而不是在后台发送。 Or you can cancel webView request when the app goes in background.或者您可以在应用程序进入后台时取消 webView 请求。

Is it important that the app remains intact when you return from multitasking?当您从多任务处理中返回时,应用程序保持完整是否重要?

If not in 100%, I think you should try to load a blank page just when about to multitask.如果不是 100%,我认为您应该尝试在即将进行多任务处理时加载一个空白页面。

When coming back, the user might have a different location fix, so you'll need to refresh the page anyway..回来时,用户可能有不同的位置修复,所以无论如何你都需要刷新页面..

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 如何从终止状态调试应该由位置服务启动的iPhone应用程序到后台? - How do I debug an iPhone app that's supposed to be launched by location services, into the background, from a terminated state? 位置服务设置为“开”时应用程序崩溃 - App crashes when location services set to “On” 应用程序进入后台或手机锁定时如何获取位置? - How to get location when app goes to background or phone is locked? 应用程序终止时,位置服务不会停止 - Location services don't stop when application is terminated 如何在应用程序中导航到位置服务设置 - How to navigate to Location Services setting in an app 仅在应用程序处于后台时才获取位置更新 - Getting Location Update only when app is in Background 要求位置服务许可时,iPhone应用程序崩溃 - iPhone app crashes when asking for Location Services permission 应用程序在后台运行时如何获取室内位置X和Y位置? - How to get indoor location X and Y postion when app runs in Background? 即使应用程序在后台运行,如何使用swift在ios中获取位置更新 - How to get location update in ios using swift even when the app is running in background 进入后台模式时,如何在应用中更新位置管理器和计时器? - How can i update location manager and a timer in my app when it goes to background mode?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM