mirror of
https://github.com/permissionlesstech/bitchat.git
synced 2026-07-26 03:05:19 +00:00
Remove app state checks to fix thread issues
- Completely remove UIApplication/NSApplication state checks - Let NotificationDelegate handle foreground presentation - All notifications now sent regardless of app state - Fixes all thread checker warnings
This commit is contained in:
@@ -30,23 +30,9 @@ class NotificationService {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func sendLocalNotification(title: String, body: String, identifier: String) {
|
func sendLocalNotification(title: String, body: String, identifier: String) {
|
||||||
// Everything must be on main thread to check app state
|
// For now, skip app state check entirely to avoid thread issues
|
||||||
|
// The NotificationDelegate will handle foreground presentation
|
||||||
DispatchQueue.main.async {
|
DispatchQueue.main.async {
|
||||||
#if os(iOS)
|
|
||||||
guard UIApplication.shared.applicationState != .active else {
|
|
||||||
// App is active/foreground, skipping notification
|
|
||||||
print("📱 Skipping notification - app is in foreground")
|
|
||||||
return
|
|
||||||
}
|
|
||||||
#elseif os(macOS)
|
|
||||||
guard !NSApplication.shared.isActive else {
|
|
||||||
// App is active/foreground, skipping notification
|
|
||||||
print("📱 Skipping notification - app is in foreground")
|
|
||||||
return
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
|
|
||||||
// App is in background/inactive, create and send notification
|
|
||||||
let content = UNMutableNotificationContent()
|
let content = UNMutableNotificationContent()
|
||||||
content.title = title
|
content.title = title
|
||||||
content.body = body
|
content.body = body
|
||||||
@@ -61,6 +47,8 @@ class NotificationService {
|
|||||||
UNUserNotificationCenter.current().add(request) { error in
|
UNUserNotificationCenter.current().add(request) { error in
|
||||||
if let error = error {
|
if let error = error {
|
||||||
print("📱 Error sending local notification: \(error)")
|
print("📱 Error sending local notification: \(error)")
|
||||||
|
} else {
|
||||||
|
print("📱 Local notification sent: \(title)")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user