简体   繁体   English

是否可以在iPhone的后台跟踪用户并将其位置发送到服务器?

[英]Is it possible to track users and send their locations to a sever in the background on iPhone?

I keep reading conflicting things on doing this. 我一直在阅读与此矛盾的东西。 I want to create an app that matches users based on location by sending their location to my server every x minutes to see if there are any other users nearby, but the users obviously won't have the app open all day and will not be able to see if there are any other users nearby unless they both have the app open in the foreground. 我想创建一个根据位置与用户匹配的应用程序,方法是每隔X分钟将其位置发送到我的服务器,以查看附近是否还有其他用户,但是这些用户显然不会整天打开应用程序,因此无法看看附近是否还有其他用户,除非他们俩都在前台打开了该应用程序。 For instance, if I open the app in the morning and then it goes to the background, my server will have my last location as wherever I was when I had the app in the foreground in the morning, but I want my server to know wherever the user is every x number of minutes and they would obviously consent to this kind of monitoring. 例如,如果我在早上打开应用程序然后转到后台,则我的服务器将拥有我早上在前台放置应用程序时所处位置的最后一个位置,但是我希望服务器知道任何位置用户每x分钟数,他们显然会同意这种监视。 Proximity would be very importance, hence the need for accurate and continual location updates. 接近度非常重要,因此需要准确且连续的位置更新。

Is this type of app even possible or would I have problems with the background post requests? 这种类型的应用程序是否有可能,或者我的后台发帖请求有问题吗?

I was thinking that a simple solution might be to simply track all the data in the background and then submit all the coordinates that were collected in the background whenever the user brings it to the foreground, but this would not allow people to see other users that are nearby until the other users bring their apps to the foreground and submit where they've been as well. 我在想一个简单的解决方案可能是简单地跟踪后台的所有数据,然后每当用户将其带到前台时提交在后台收集的所有坐标,但这将使人们无法看到其他用户。在附近,直到其他用户将他们的应用程序带到前台并提交他们去过的地方。

Basically, if two people are in the same location, I'd like the person with the app in the foreground (person A) to be able to see the person with the app in the background (person B), even if person B hasn't had the app in the foreground for a while. 基本上,如果两个人位于同一位置,我希望前景中具有应用程序的人(人A)能够看到背景中具有应用程序的人(人B),即使人B避难所暂时没有该应用了。 I'm thinking this will require a timer and background location/network activity, but need to know how to go about it. 我认为这将需要计时器和后台位置/网络活动,但需要知道如何进行。 Thanks 谢谢

No, Its not possible. 不,不可能。 When you put your app in background your app will be in idel state. 当您将应用程序置于后台时,您的应用程序将处于idel状态。 Hence you cannot track the location of the users who have kept the app in background. 因此,您无法跟踪将应用程序保留在后台的用户的位置。 Maye be you can have some predefined location sets alrdy. 也许您可以拥有一些预定义的位置集。 So that when ever other users (AZ) come across that location thet will notify the actual user. 这样,当其他用户(AZ)遇到该位置时,它们就会通知实际用户。

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

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM