mirror of
https://github.com/permissionlesstech/bitchat.git
synced 2026-07-26 01:25:20 +00:00
Enable notifications on macOS
- Add macOS support to NotificationService - Use NSApplication.shared.isActive to check app state on macOS - Move notification logic outside of iOS-only block in ChatViewModel - Notifications now work for both mentions and private messages on macOS - Keep haptic feedback iOS-only as it's not available on macOS
This commit is contained in:
@@ -430,14 +430,19 @@ extension ChatViewModel: BitchatDelegate {
|
||||
messages.append(message)
|
||||
}
|
||||
|
||||
#if os(iOS)
|
||||
// Check if we're mentioned
|
||||
let isMentioned = message.mentions?.contains(nickname) ?? false
|
||||
|
||||
// Send notifications for mentions and private messages when app is in background
|
||||
if isMentioned && message.sender != nickname {
|
||||
NotificationService.shared.sendMentionNotification(from: message.sender, message: message.content)
|
||||
|
||||
} else if message.isPrivate && message.sender != nickname {
|
||||
NotificationService.shared.sendPrivateMessageNotification(from: message.sender, message: message.content)
|
||||
}
|
||||
|
||||
#if os(iOS)
|
||||
// Haptic feedback for iOS only
|
||||
if isMentioned && message.sender != nickname {
|
||||
// Very prominent haptic for @mentions - triple tap with heavy impact
|
||||
let impactFeedback = UIImpactFeedbackGenerator(style: .heavy)
|
||||
impactFeedback.prepare()
|
||||
@@ -450,8 +455,6 @@ extension ChatViewModel: BitchatDelegate {
|
||||
impactFeedback.impactOccurred()
|
||||
}
|
||||
} else if message.isPrivate && message.sender != nickname {
|
||||
NotificationService.shared.sendPrivateMessageNotification(from: message.sender, message: message.content)
|
||||
|
||||
// Heavy haptic for private messages - more pronounced
|
||||
let impactFeedback = UIImpactFeedbackGenerator(style: .heavy)
|
||||
impactFeedback.prepare()
|
||||
|
||||
Reference in New Issue
Block a user