php - Swift - 查找附近运行应用程序的其他用户

标签 php ios swift gps

需要一些逻辑方面的帮助。我在应用程序启动时将应用程序用户的位置信息(纬度、经度)存储在数据库中(并在应用程序使用时定期更新)。

我的应用程序的主要功能是查找附近当前也在运行该应用程序的用户。

仅在数据库中查询邻近范围内的“附近用户”是不够的,因为我需要他们也运行该应用程序。

我不确定如何“知道”用户何时运行该应用程序以及 5 分钟前使用我的应用程序(记录其纬度/经度)然后关闭应用程序的用户。

见过类似的问题(特定于 Android),但没有一个真正涉及“活跃”用户。

(当前使用 Swift 进行编码,使用 PHP 作为我的服务器端语言)

最佳答案

您可以在 AppDelegate 中使用以下方法来管理状态,然后根据状态更改,您可以执行查询或删除用户的资格。

func applicationWillResignActive(application: UIApplication) {
    // Sent when the application is about to move from active to inactive state. This can occur for certain types of temporary interruptions (such as an incoming phone call or SMS message) or when the user quits the application and it begins the transition to the background state.
    // Use this method to pause ongoing tasks, disable timers, and throttle down OpenGL ES frame rates. Games should use this method to pause the game.
}

func applicationDidEnterBackground(application: UIApplication) {
    // Use this method to release shared resources, save user data, invalidate timers, and store enough application state information to restore your application to its current state in case it is terminated later.
    // If your application supports background execution, this method is called instead of applicationWillTerminate: when the user quits.
}

func applicationWillEnterForeground(application: UIApplication) {
    // Called as part of the transition from the background to the active state; here you can undo many of the changes made on entering the background.
}

func applicationDidBecomeActive(application: UIApplication) {
    // Restart any tasks that were paused (or not yet started) while the application was inactive. If the application was previously in the background, optionally refresh the user interface.
}

func applicationWillTerminate(application: UIApplication) {
    // Called when the application is about to terminate. Save data if appropriate. See also applicationDidEnterBackground:.
    // Saves changes in the application's managed object context before the application terminates.

}

关于php - Swift - 查找附近运行应用程序的其他用户,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/31768958/

相关文章:

ios - 滑动即可删除单元格

ios - 如何为 MIDI 事件准确设置时间戳?

php pthread,嵌入式同步工作

php - 在 MySQL/PHP 中查找和存储数据库关系

php - Symfony2 路由器返回端口 80 的绝对 url

ios - Swift 4 中 '(撇号) 的百分比编码输出不正确

ios - 我可以使用 jpg 而不是 png 作为 iOS 网络应用启动图像吗?

ios - 转至 SecondViewController 后数据消失

ios - 使用 geocoder.geocodeAddressString 添加多个注释(递归?)

PHP MySQL "UPDATE"