简体   繁体   English

迅速,当应用程序被杀死时将用户的当前位置发送到服务器

[英]In swift, send User’s current location to server while app is killed

I am creating a Taxi Driver application in swift.我正在快速创建出租车司机应用程序。 I need to send the driver's current location to the server by every 30 sec even app is killed.即使应用程序被杀死,我也需要每 30 秒将驱动程序的当前位置发送到服务器。 I found the solution while the app is in the foreground or background state.我在应用程序处于前台或后台状态时找到了解决方案。 But I am not able to send location to server while app is killed.但是当应用程序被杀死时,我无法将位置发送到服务器。 I tried with VOIP push and startMonitoringSignificantLocationChanges .尝试使用 VOIP 推送startMonitoringSignificantLocationChanges

  1. When the app is killed and VOIP push receives by every 30 sec, I can get the user's location but, I am not able to call API and send a location to the server.当应用程序被终止并且每 30 秒接收一次VOIP推送时,我可以获得用户的位置,但是,我无法调用 API 并将位置发送到服务器。 Can anyone have a solution for sending data to the server while the app is killed?任何人都可以在应用程序被终止时将数据发送到服务器的解决方案吗?

  2. Using startMonitoringSignificantLocationChanges while the app is killed I am able to send location to the server, but it takes 5 to 10 minutes to get user's updated location while he/she is driving.在应用程序被终止时使用startMonitoringSignificantLocationChanges我能够将位置发送到服务器,但需要 5 到 10 分钟才能在他/她开车时获取用户的更新位置。 I tried physically by traveling from one location to another location so many times.我多次尝试从一个地方到另一个地方旅行。 Apple doc tells that location updates when user's position changes by a significant amount, such as 500 meters. Apple 文档告诉当用户的位置发生显着变化(例如 500 米)时,位置会更新。 But in reality, it updates by 5km to 7km traveling.但实际上,它会更新 5 公里到 7 公里的行程。 Can anyone have a solution for it?任何人都可以解决它吗?

App refresh is good idea but iOS allows only 35 to 40 seconds in background to wake up your app in background so you should call your functions in this period of time.. here is good example for location based background tasks Usage应用程序刷新是好主意,但iOS的允许在后台只有35到40秒唤醒在后台您的应用程序,所以你应该打电话给你的功能在这一段时间..这里是基于位置的后台任务很好的例子用法

and and and apple document says if you use silent push notification.和和和苹果文档说如果你使用静默推送通知。 However, the system does not automatically launch your app if the user has force-quit it..refer this但是,如果用户强制退出,系统不会自动启动您的应用程序..请参阅

“If your app is terminated either by a user or by the system, the system doesn't automatically restart your app when new location updates arrive. “如果您的应用程序被用户或系统终止,当新的位置更新到达时,系统不会自动重新启动您的应用程序。 A user must explicitly relaunch your app before the delivery of location updates resumes.用户必须明确重新启动您的应用程序,然后才能恢复位置更新的交付。 The only way to have your app relaunched automatically is to use region monitoring or significant-change location service.让您的应用程序自动重新启动的唯一方法是使用区域监控或重大变化的位置服务。 However, when a user disables the Background App Refresh setting either globally or specifically for your app, the system doesn't relaunch your app for any location events, including significant change or region monitoring events.但是,当用户全局或专门为您的应用禁用后台应用刷新设置时,系统不会针对任何位置事件(包括重大更改或区域监控事件)重新启动您的应用。 Further, while Background App Refresh is off your app won't receive significant change or region monitoring events even when it's in the foreground.”此外,当后台应用刷新关闭时,您的应用即使在前台也不会收到重大更改或区域监控事件。” more... 更多的...

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

相关问题 当app在后台时,我可以将用户的当前位置发送到服务器吗? - Can I send user's current location to server, when app is in background? 在iOS中后台运行应用程序时将用户位置发送到服务器 - Send user location to server while app in background in ios 尝试获取当前位置时快速用户的位置问题 - swift user's location issue when trying to get current location 当应用程序被杀时,位置不会在行走时更新 - Location not updating while walking, when app is killed 为“超本地”应用程序获取用户位置(也处于被杀死状态)的适当方法 - Appropriate way to get user's location(also in killed state) for an “hyperlocal” app 在后台 Swift 中发送用户的位置 - Send Location of User in Background Swift 如何通过iphone应用程序中的代码获取用户的当前位置? - How to get the user's current location by code in iphone app? 当应用程序在后台时将用户的位置转发到服务器(Swift/iOS) - Forwarding user's location to server when application is in the background (Swift/iOS) 使用Swift获取用户位置来制作应用 - Making an app using swift that gets user's location 获取用户的当前位置 - Fetching the user's current location
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM