mirror of
https://github.com/permissionlesstech/bitchat.git
synced 2026-07-25 01:45:20 +00:00
Merge pull request #295 from permissionlesstech/network-notifications
Add network availability notifications
This commit is contained in:
@@ -193,18 +193,18 @@
|
||||
3FA8FF26ABDC1C642A8C7AE5 /* BitchatMessageTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = BitchatMessageTests.swift; sourceTree = "<group>"; };
|
||||
527EB217EFDFAD4CF1C91F07 /* bitchat.entitlements */ = {isa = PBXFileReference; lastKnownFileType = text.plist.entitlements; path = bitchat.entitlements; sourceTree = "<group>"; };
|
||||
53D535D9CE0B875F47402290 /* BinaryProtocolTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = BinaryProtocolTests.swift; sourceTree = "<group>"; };
|
||||
61F92EBA29C47C0FCC482F1F /* bitchatShareExtension.appex */ = {isa = PBXFileReference; includeInIndex = 0; lastKnownFileType = "wrapper.extensionkit-extension"; path = bitchatShareExtension.appex; sourceTree = BUILT_PRODUCTS_DIR; };
|
||||
61F92EBA29C47C0FCC482F1F /* bitchatShareExtension.appex */ = {isa = PBXFileReference; explicitFileType = "wrapper.app-extension"; includeInIndex = 0; path = bitchatShareExtension.appex; sourceTree = BUILT_PRODUCTS_DIR; };
|
||||
6E2446380E7A44E49A35B664 /* IdentityModels.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = IdentityModels.swift; sourceTree = "<group>"; };
|
||||
763E0DBA9492A654FC0CDCB9 /* AppInfoView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AppInfoView.swift; sourceTree = "<group>"; };
|
||||
8DE9CDF66D4E52D268851048 /* MessagePaddingTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = MessagePaddingTests.swift; sourceTree = "<group>"; };
|
||||
8F3A7C058C2C8E1A06C8CF8B /* bitchat_macOS.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; name = bitchat_macOS.app; path = bitchat.app; sourceTree = BUILT_PRODUCTS_DIR; };
|
||||
8F3A7C058C2C8E1A06C8CF8B /* bitchat.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = bitchat.app; sourceTree = BUILT_PRODUCTS_DIR; };
|
||||
95F16C3A4A5621C74461D8D3 /* LaunchScreen.storyboard */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; path = LaunchScreen.storyboard; sourceTree = "<group>"; };
|
||||
96D0D41CA19EE5A772AA8434 /* bitchat.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = bitchat.app; sourceTree = BUILT_PRODUCTS_DIR; };
|
||||
9AC141774F6671FCDC347DC7 /* LinkPreviewView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = LinkPreviewView.swift; sourceTree = "<group>"; };
|
||||
A08E03AA0C63E97C91749AEC /* ContentView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ContentView.swift; sourceTree = "<group>"; };
|
||||
A2136C3E22D02D4A8DBE7EAB /* BinaryProtocol.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = BinaryProtocol.swift; sourceTree = "<group>"; };
|
||||
AA4D7595A613F7ED3B386132 /* MessageRetryService.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = MessageRetryService.swift; sourceTree = "<group>"; };
|
||||
C0DB1DE27F0AAB5092663E8E /* bitchatTests_iOS.xctest */ = {isa = PBXFileReference; includeInIndex = 0; lastKnownFileType = wrapper.cfbundle; path = bitchatTests_iOS.xctest; sourceTree = BUILT_PRODUCTS_DIR; };
|
||||
C0DB1DE27F0AAB5092663E8E /* bitchatTests_iOS.xctest */ = {isa = PBXFileReference; explicitFileType = wrapper.cfbundle; includeInIndex = 0; path = bitchatTests_iOS.xctest; sourceTree = BUILT_PRODUCTS_DIR; };
|
||||
C1B378C16594575FCC7F9C75 /* ShareViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ShareViewController.swift; sourceTree = "<group>"; };
|
||||
CB043CA5EEB9AC8B07D61E97 /* OptimizedBloomFilter.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = OptimizedBloomFilter.swift; sourceTree = "<group>"; };
|
||||
D5C3D880FF8AE1673B20E1E3 /* BluetoothMeshService.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = BluetoothMeshService.swift; sourceTree = "<group>"; };
|
||||
@@ -293,7 +293,7 @@
|
||||
isa = PBXGroup;
|
||||
children = (
|
||||
96D0D41CA19EE5A772AA8434 /* bitchat.app */,
|
||||
8F3A7C058C2C8E1A06C8CF8B /* bitchat_macOS.app */,
|
||||
8F3A7C058C2C8E1A06C8CF8B /* bitchat.app */,
|
||||
61F92EBA29C47C0FCC482F1F /* bitchatShareExtension.appex */,
|
||||
C0DB1DE27F0AAB5092663E8E /* bitchatTests_iOS.xctest */,
|
||||
03C57F452B55FD0FD8F51421 /* bitchatTests_macOS.xctest */,
|
||||
@@ -392,7 +392,7 @@
|
||||
packageProductDependencies = (
|
||||
);
|
||||
productName = bitchat_macOS;
|
||||
productReference = 8F3A7C058C2C8E1A06C8CF8B /* bitchat_macOS.app */;
|
||||
productReference = 8F3A7C058C2C8E1A06C8CF8B /* bitchat.app */;
|
||||
productType = "com.apple.product-type.application";
|
||||
};
|
||||
47FF23248747DD7CB666CB91 /* bitchatTests_macOS */ = {
|
||||
@@ -475,7 +475,7 @@
|
||||
isa = PBXProject;
|
||||
attributes = {
|
||||
BuildIndependentTargetsInParallel = YES;
|
||||
LastUpgradeCheck = 1430;
|
||||
LastUpgradeCheck = 1640;
|
||||
TargetAttributes = {
|
||||
0576A29205865664C0937536 = {
|
||||
DevelopmentTeam = L3N5LHJD5Y;
|
||||
@@ -704,7 +704,6 @@
|
||||
CODE_SIGNING_ALLOWED = YES;
|
||||
CODE_SIGNING_REQUIRED = YES;
|
||||
CODE_SIGN_STYLE = Automatic;
|
||||
DEVELOPMENT_TEAM = L3N5LHJD5Y;
|
||||
INFOPLIST_FILE = bitchatTests/Info.plist;
|
||||
IPHONEOS_DEPLOYMENT_TARGET = 16.0;
|
||||
LD_RUNPATH_SEARCH_PATHS = (
|
||||
@@ -727,7 +726,6 @@
|
||||
CODE_SIGNING_ALLOWED = YES;
|
||||
CODE_SIGNING_REQUIRED = YES;
|
||||
CODE_SIGN_STYLE = Automatic;
|
||||
DEVELOPMENT_TEAM = L3N5LHJD5Y;
|
||||
INFOPLIST_FILE = bitchatTests/Info.plist;
|
||||
IPHONEOS_DEPLOYMENT_TARGET = 16.0;
|
||||
LD_RUNPATH_SEARCH_PATHS = (
|
||||
@@ -751,7 +749,7 @@
|
||||
CODE_SIGNING_REQUIRED = YES;
|
||||
CODE_SIGN_STYLE = Automatic;
|
||||
COMBINE_HIDPI_IMAGES = YES;
|
||||
DEVELOPMENT_TEAM = L3N5LHJD5Y;
|
||||
DEAD_CODE_STRIPPING = YES;
|
||||
INFOPLIST_FILE = bitchatTests/Info.plist;
|
||||
LD_RUNPATH_SEARCH_PATHS = (
|
||||
"$(inherited)",
|
||||
@@ -774,7 +772,6 @@
|
||||
CODE_SIGN_ALLOW_ENTITLEMENTS_MODIFICATION = YES;
|
||||
CODE_SIGN_ENTITLEMENTS = bitchatShareExtension/bitchatShareExtension.entitlements;
|
||||
CODE_SIGN_STYLE = Automatic;
|
||||
DEVELOPMENT_TEAM = L3N5LHJD5Y;
|
||||
INFOPLIST_FILE = bitchatShareExtension/Info.plist;
|
||||
IPHONEOS_DEPLOYMENT_TARGET = 16.0;
|
||||
LD_RUNPATH_SEARCH_PATHS = (
|
||||
@@ -799,7 +796,6 @@
|
||||
CODE_SIGN_ENTITLEMENTS = bitchat/bitchat.entitlements;
|
||||
CODE_SIGN_IDENTITY = "iPhone Developer";
|
||||
CODE_SIGN_STYLE = Automatic;
|
||||
DEVELOPMENT_TEAM = L3N5LHJD5Y;
|
||||
ENABLE_PREVIEWS = YES;
|
||||
INFOPLIST_FILE = bitchat/Info.plist;
|
||||
INFOPLIST_KEY_CFBundleDisplayName = bitchat;
|
||||
@@ -829,7 +825,7 @@
|
||||
CODE_SIGNING_REQUIRED = YES;
|
||||
CODE_SIGN_STYLE = Automatic;
|
||||
COMBINE_HIDPI_IMAGES = YES;
|
||||
DEVELOPMENT_TEAM = L3N5LHJD5Y;
|
||||
DEAD_CODE_STRIPPING = YES;
|
||||
INFOPLIST_FILE = bitchatTests/Info.plist;
|
||||
LD_RUNPATH_SEARCH_PATHS = (
|
||||
"$(inherited)",
|
||||
@@ -854,7 +850,6 @@
|
||||
CODE_SIGN_ENTITLEMENTS = bitchat/bitchat.entitlements;
|
||||
CODE_SIGN_IDENTITY = "iPhone Developer";
|
||||
CODE_SIGN_STYLE = Automatic;
|
||||
DEVELOPMENT_TEAM = L3N5LHJD5Y;
|
||||
ENABLE_PREVIEWS = YES;
|
||||
INFOPLIST_FILE = bitchat/Info.plist;
|
||||
INFOPLIST_KEY_CFBundleDisplayName = bitchat;
|
||||
@@ -886,7 +881,7 @@
|
||||
CODE_SIGN_ENTITLEMENTS = "bitchat/bitchat-macOS.entitlements";
|
||||
CODE_SIGN_STYLE = Automatic;
|
||||
COMBINE_HIDPI_IMAGES = YES;
|
||||
DEVELOPMENT_TEAM = L3N5LHJD5Y;
|
||||
DEAD_CODE_STRIPPING = YES;
|
||||
ENABLE_PREVIEWS = YES;
|
||||
INFOPLIST_FILE = bitchat/Info.plist;
|
||||
LD_RUNPATH_SEARCH_PATHS = (
|
||||
@@ -896,6 +891,7 @@
|
||||
MACOSX_DEPLOYMENT_TARGET = 13.0;
|
||||
PRODUCT_BUNDLE_IDENTIFIER = chat.bitchat;
|
||||
PRODUCT_NAME = bitchat;
|
||||
REGISTER_APP_GROUPS = YES;
|
||||
SDKROOT = macosx;
|
||||
SWIFT_VERSION = 5.0;
|
||||
};
|
||||
@@ -936,9 +932,12 @@
|
||||
CLANG_WARN__DUPLICATE_METHOD_MATCH = YES;
|
||||
COPY_PHASE_STRIP = NO;
|
||||
CURRENT_PROJECT_VERSION = 1;
|
||||
DEAD_CODE_STRIPPING = YES;
|
||||
DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym";
|
||||
DEVELOPMENT_TEAM = L3N5LHJD5Y;
|
||||
ENABLE_NS_ASSERTIONS = NO;
|
||||
ENABLE_STRICT_OBJC_MSGSEND = YES;
|
||||
ENABLE_USER_SCRIPT_SANDBOXING = YES;
|
||||
GCC_C_LANGUAGE_STANDARD = gnu11;
|
||||
GCC_NO_COMMON_BLOCKS = YES;
|
||||
GCC_WARN_64_TO_32_BIT_CONVERSION = YES;
|
||||
@@ -969,7 +968,7 @@
|
||||
CODE_SIGN_ENTITLEMENTS = "bitchat/bitchat-macOS.entitlements";
|
||||
CODE_SIGN_STYLE = Automatic;
|
||||
COMBINE_HIDPI_IMAGES = YES;
|
||||
DEVELOPMENT_TEAM = L3N5LHJD5Y;
|
||||
DEAD_CODE_STRIPPING = YES;
|
||||
ENABLE_PREVIEWS = YES;
|
||||
INFOPLIST_FILE = bitchat/Info.plist;
|
||||
LD_RUNPATH_SEARCH_PATHS = (
|
||||
@@ -979,6 +978,7 @@
|
||||
MACOSX_DEPLOYMENT_TARGET = 13.0;
|
||||
PRODUCT_BUNDLE_IDENTIFIER = chat.bitchat;
|
||||
PRODUCT_NAME = bitchat;
|
||||
REGISTER_APP_GROUPS = YES;
|
||||
SDKROOT = macosx;
|
||||
SWIFT_VERSION = 5.0;
|
||||
};
|
||||
@@ -1019,9 +1019,12 @@
|
||||
CLANG_WARN__DUPLICATE_METHOD_MATCH = YES;
|
||||
COPY_PHASE_STRIP = NO;
|
||||
CURRENT_PROJECT_VERSION = 1;
|
||||
DEAD_CODE_STRIPPING = YES;
|
||||
DEBUG_INFORMATION_FORMAT = dwarf;
|
||||
DEVELOPMENT_TEAM = L3N5LHJD5Y;
|
||||
ENABLE_STRICT_OBJC_MSGSEND = YES;
|
||||
ENABLE_TESTABILITY = YES;
|
||||
ENABLE_USER_SCRIPT_SANDBOXING = YES;
|
||||
GCC_C_LANGUAGE_STANDARD = gnu11;
|
||||
GCC_DYNAMIC_NO_PIC = NO;
|
||||
GCC_NO_COMMON_BLOCKS = YES;
|
||||
@@ -1057,7 +1060,6 @@
|
||||
CODE_SIGN_ALLOW_ENTITLEMENTS_MODIFICATION = YES;
|
||||
CODE_SIGN_ENTITLEMENTS = bitchatShareExtension/bitchatShareExtension.entitlements;
|
||||
CODE_SIGN_STYLE = Automatic;
|
||||
DEVELOPMENT_TEAM = L3N5LHJD5Y;
|
||||
INFOPLIST_FILE = bitchatShareExtension/Info.plist;
|
||||
IPHONEOS_DEPLOYMENT_TARGET = 16.0;
|
||||
LD_RUNPATH_SEARCH_PATHS = (
|
||||
|
||||
@@ -35,6 +35,12 @@
|
||||
<string>bitchat uses Bluetooth to create a secure mesh network for chatting with nearby users.</string>
|
||||
<key>NSBluetoothPeripheralUsageDescription</key>
|
||||
<string>bitchat uses Bluetooth to discover and connect with other bitchat users nearby.</string>
|
||||
<key>UIBackgroundModes</key>
|
||||
<array>
|
||||
<string>bluetooth-central</string>
|
||||
<string>bluetooth-peripheral</string>
|
||||
<string>remote-notification</string>
|
||||
</array>
|
||||
<key>UILaunchStoryboardName</key>
|
||||
<string>LaunchScreen</string>
|
||||
<key>UISupportedInterfaceOrientations</key>
|
||||
|
||||
@@ -81,6 +81,11 @@ class BluetoothMeshService: NSObject {
|
||||
private let maxTTL: UInt8 = 7 // Maximum hops for long-distance delivery
|
||||
private var announcedToPeers = Set<String>() // Track which peers we've announced to
|
||||
private var announcedPeers = Set<String>() // Track peers who have already been announced
|
||||
private var hasNotifiedNetworkAvailable = false // Track if we've notified about network availability
|
||||
private var lastNetworkNotificationTime: Date? // Track when we last sent a network notification
|
||||
private var networkBecameEmptyTime: Date? // Track when the network became empty
|
||||
private let networkNotificationCooldown: TimeInterval = 300 // 5 minutes between notifications
|
||||
private let networkEmptyResetDelay: TimeInterval = 60 // 1 minute before resetting notification flag
|
||||
private var intentionalDisconnects = Set<String>() // Track peripherals we're disconnecting intentionally
|
||||
private var peerLastSeenTimestamps = LRUCache<String, Date>(maxSize: 100) // Bounded cache for peer timestamps
|
||||
private var cleanupTimer: Timer? // Timer to clean up stale peers
|
||||
@@ -599,6 +604,8 @@ class BluetoothMeshService: NSObject {
|
||||
activePeers.removeAll()
|
||||
}
|
||||
announcedPeers.removeAll()
|
||||
// For normal disconnect, respect the timing
|
||||
networkBecameEmptyTime = Date()
|
||||
|
||||
// Clear announcement tracking
|
||||
announcedToPeers.removeAll()
|
||||
@@ -1231,6 +1238,10 @@ class BluetoothMeshService: NSObject {
|
||||
peripheralRSSI.removeAll()
|
||||
announcedToPeers.removeAll()
|
||||
announcedPeers.removeAll()
|
||||
// For emergency/panic, reset immediately
|
||||
hasNotifiedNetworkAvailable = false
|
||||
networkBecameEmptyTime = nil
|
||||
lastNetworkNotificationTime = nil
|
||||
processedMessages.removeAll()
|
||||
incomingFragments.removeAll()
|
||||
fragmentMetadata.removeAll()
|
||||
@@ -1331,6 +1342,29 @@ class BluetoothMeshService: NSObject {
|
||||
|
||||
if !peersToRemove.isEmpty {
|
||||
notifyPeerListUpdate()
|
||||
|
||||
// Mark when network became empty, but don't reset flag immediately
|
||||
let currentNetworkSize = collectionsQueue.sync { activePeers.count }
|
||||
if currentNetworkSize == 0 && networkBecameEmptyTime == nil {
|
||||
networkBecameEmptyTime = Date()
|
||||
}
|
||||
}
|
||||
|
||||
// Check if we should reset the notification flag
|
||||
if let emptyTime = networkBecameEmptyTime {
|
||||
let currentNetworkSize = collectionsQueue.sync { activePeers.count }
|
||||
if currentNetworkSize == 0 {
|
||||
// Network is still empty, check if enough time has passed
|
||||
let timeSinceEmpty = Date().timeIntervalSince(emptyTime)
|
||||
if timeSinceEmpty >= networkEmptyResetDelay {
|
||||
// Reset the flag after network has been empty for the delay period
|
||||
hasNotifiedNetworkAvailable = false
|
||||
// Keep the empty time set so we don't immediately notify again
|
||||
}
|
||||
} else {
|
||||
// Network is no longer empty, clear the empty time
|
||||
networkBecameEmptyTime = nil
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2079,6 +2113,33 @@ class BluetoothMeshService: NSObject {
|
||||
}
|
||||
self.notifyPeerListUpdate(immediate: true)
|
||||
|
||||
// Send network available notification if appropriate
|
||||
let currentNetworkSize = collectionsQueue.sync { self.activePeers.count }
|
||||
if currentNetworkSize > 0 {
|
||||
// Clear empty time since network is active
|
||||
networkBecameEmptyTime = nil
|
||||
|
||||
if !hasNotifiedNetworkAvailable {
|
||||
// Check if enough time has passed since last notification
|
||||
let now = Date()
|
||||
var shouldSendNotification = true
|
||||
|
||||
if let lastNotification = lastNetworkNotificationTime {
|
||||
let timeSinceLastNotification = now.timeIntervalSince(lastNotification)
|
||||
if timeSinceLastNotification < networkNotificationCooldown {
|
||||
// Too soon to send another notification
|
||||
shouldSendNotification = false
|
||||
}
|
||||
}
|
||||
|
||||
if shouldSendNotification {
|
||||
hasNotifiedNetworkAvailable = true
|
||||
lastNetworkNotificationTime = now
|
||||
NotificationService.shared.sendNetworkAvailableNotification(peerCount: currentNetworkSize)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
DispatchQueue.main.async {
|
||||
// Check if this is a favorite peer and send notification
|
||||
// Note: This might not work immediately if key exchange hasn't happened yet
|
||||
@@ -2928,6 +2989,12 @@ extension BluetoothMeshService: CBCentralManagerDelegate {
|
||||
DispatchQueue.main.async {
|
||||
self.delegate?.didDisconnectFromPeer(peerID)
|
||||
}
|
||||
|
||||
// Mark when network became empty, but don't reset flag immediately
|
||||
let currentNetworkSize = collectionsQueue.sync { activePeers.count }
|
||||
if currentNetworkSize == 0 && networkBecameEmptyTime == nil {
|
||||
networkBecameEmptyTime = Date()
|
||||
}
|
||||
}
|
||||
self.notifyPeerListUpdate()
|
||||
}
|
||||
|
||||
@@ -20,43 +20,33 @@ class NotificationService {
|
||||
private init() {}
|
||||
|
||||
func requestAuthorization() {
|
||||
UNUserNotificationCenter.current().requestAuthorization(options: [.alert, .sound, .badge]) { granted, _ in
|
||||
UNUserNotificationCenter.current().requestAuthorization(options: [.alert, .sound, .badge]) { granted, error in
|
||||
if granted {
|
||||
// Permission granted
|
||||
} else {
|
||||
// Permission denied
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func sendLocalNotification(title: String, body: String, identifier: String) {
|
||||
// Check if app is in foreground
|
||||
#if os(iOS)
|
||||
guard UIApplication.shared.applicationState != .active else {
|
||||
// App is active/foreground, skipping notification
|
||||
return
|
||||
}
|
||||
// App state checked, sending notification
|
||||
#elseif os(macOS)
|
||||
// On macOS, check if app is active
|
||||
guard !NSApplication.shared.isActive else {
|
||||
// App is active/foreground, skipping notification
|
||||
return
|
||||
}
|
||||
// App is not active, sending notification
|
||||
#endif
|
||||
|
||||
let content = UNMutableNotificationContent()
|
||||
content.title = title
|
||||
content.body = body
|
||||
content.sound = .default
|
||||
|
||||
let request = UNNotificationRequest(
|
||||
identifier: identifier,
|
||||
content: content,
|
||||
trigger: nil // Deliver immediately
|
||||
)
|
||||
|
||||
UNUserNotificationCenter.current().add(request) { _ in
|
||||
// Notification added
|
||||
// For now, skip app state check entirely to avoid thread issues
|
||||
// The NotificationDelegate will handle foreground presentation
|
||||
DispatchQueue.main.async {
|
||||
let content = UNMutableNotificationContent()
|
||||
content.title = title
|
||||
content.body = body
|
||||
content.sound = .default
|
||||
|
||||
let request = UNNotificationRequest(
|
||||
identifier: identifier,
|
||||
content: content,
|
||||
trigger: nil // Deliver immediately
|
||||
)
|
||||
|
||||
UNUserNotificationCenter.current().add(request) { _ in
|
||||
// Notification added
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -77,10 +67,48 @@ class NotificationService {
|
||||
}
|
||||
|
||||
func sendFavoriteOnlineNotification(nickname: String) {
|
||||
let title = "⭐ \(nickname) is online"
|
||||
let body = "wanna get in there?"
|
||||
let identifier = "favorite-online-\(UUID().uuidString)"
|
||||
// Send directly without checking app state for favorites
|
||||
DispatchQueue.main.async {
|
||||
let content = UNMutableNotificationContent()
|
||||
content.title = "⭐ \(nickname) is online!"
|
||||
content.body = "wanna get in there?"
|
||||
content.sound = .default
|
||||
|
||||
let request = UNNotificationRequest(
|
||||
identifier: "favorite-online-\(UUID().uuidString)",
|
||||
content: content,
|
||||
trigger: nil
|
||||
)
|
||||
|
||||
UNUserNotificationCenter.current().add(request) { _ in
|
||||
// Notification added
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func sendNetworkAvailableNotification(peerCount: Int) {
|
||||
let title = "👥 bitchatters nearby!"
|
||||
let body = peerCount == 1 ? "1 person around" : "\(peerCount) people around"
|
||||
let identifier = "network-available-\(Date().timeIntervalSince1970)"
|
||||
|
||||
sendLocalNotification(title: title, body: body, identifier: identifier)
|
||||
// For network notifications, we want to show them even in foreground
|
||||
// No app state check - let the notification delegate handle presentation
|
||||
DispatchQueue.main.async {
|
||||
let content = UNMutableNotificationContent()
|
||||
content.title = title
|
||||
content.body = body
|
||||
content.sound = .default
|
||||
content.interruptionLevel = .timeSensitive // Make it more prominent
|
||||
|
||||
let request = UNNotificationRequest(
|
||||
identifier: identifier,
|
||||
content: content,
|
||||
trigger: nil // Deliver immediately
|
||||
)
|
||||
|
||||
UNUserNotificationCenter.current().add(request) { _ in
|
||||
// Notification added
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -18,7 +18,7 @@ struct AppInfoView: View {
|
||||
|
||||
// MARK: - Constants
|
||||
private enum Strings {
|
||||
static let appName = "bitchat"
|
||||
static let appName = "bitchat/"
|
||||
static let tagline = "mesh sidegroupchat"
|
||||
|
||||
enum Features {
|
||||
|
||||
Reference in New Issue
Block a user