簡體   English   中英

Swift-查找附近正在運行應用程序的其他用戶

[英]Swift - Find other users running app nearby

需要邏輯方面的幫助。 我會在應用啟動時將應用用戶的位置信息(緯度,經度)存儲在數據庫中(並在使用過程中定期更新)。

我的應用程序的主要功能是查找附近當前也在運行該應用程序的用戶。

僅查詢鄰近范圍內的“附近的用戶”是不夠的,因為我需要他們也運行該應用程序。

我不確定如何“知道”用戶何時運行該應用程序,而不是5分鍾前使用我的應用程序的用戶(記錄其經度/緯度),然后關閉該應用程序。

看到類似的問題(特定於Android),但沒有一個真正涉及“活躍”用戶。

(當前使用Swift作為我的服務器端語言以Swift編碼)

您可以在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.

}

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM