Post

Replies

Boosts

Views

Activity

Reply to How to keep a socket server in an iOS app alive when app goes to background or suspended?
Keeping a WebSocket server alive in the background of an iOS app can be a bit tricky, but it's definitely possible to achieve. While enabling background modes like "Audio, Airplay, and Picture in Picture" might keep your app alive in the background, it's important to use these modes for their intended purposes only to comply with Apple's guidelines for App Store submission. Since your app doesn't include audio or airplay features, enabling those background modes might not be the best approach. Instead, consider using the "Background Processing" background mode, which allows your app to perform certain tasks, such as network communication, in the background. Here's a brief outline of how you can accomplish this: Enable the "Background Processing" background mode in your Xcode project settings. Utilize URLSession with background configurations to handle WebSocket communication tasks in the background. Make sure to adhere to Apple's guidelines and best practices for handling background execution, including proper management of background tasks and network connections. By following these steps, you should be able to keep your WebSocket server running in the background of your iOS app without violating Apple's guidelines. This approach will ensure that your app can continue to communicate with other devices even when it's not in the foreground. Hope this helps! Let me know if you have any further questions.
Apr ’24
Reply to MacOS: Hidden Windows cannot be fetched in NSApp
When you hide a window using setIsVisible(false) or orderOut(nil), it indeed removes the window from the list of visible windows returned by NSApp.windows. However, you can still access hidden windows by maintaining your own reference to them. Here's how you can modify your utility method to include both visible and hidden windows: let windows = NSApp.windows for window in windows { if window.identifier == pWindowID { return window } } // If the window is not found among visible windows, try searching among hidden windows let hiddenWindows = NSApp.windows.filter { !$0.isVisible } for window in hiddenWindows { if window.identifier == pWindowID { return window } } return nil } With this modification, the GetWindow function first checks if the window with the given identifier is among the visible windows. If not, it then searches among the hidden windows. This should allow you to find and access both visible and hidden windows using the same utility method.
Apr ’24