UI refresh fixes, and QR code

This commit is contained in:
Philipp Heckel 2023-11-05 14:00:28 -05:00
parent 1c43d7f5c6
commit ea26378e29
11 changed files with 41 additions and 31 deletions

View file

@ -206,6 +206,7 @@
94B736D4284AF9B2003D69FB /* SettingsView.swift */,
94B736D6284AF9BE003D69FB /* MainView.swift */,
9474F20728331F3900CDE4DD /* NotificationListView.swift */,
E278CB322AECECCA004B9143 /* QRScannerUIView.swift */,
);
path = Views;
sourceTree = "<group>";
@ -245,7 +246,6 @@
94867142283EC9950093C7A4 /* Actions.swift */,
948671462841B0B20093C7A4 /* NotificationContent.swift */,
948671492841D0CE0093C7A4 /* ActionExecutor.swift */,
E278CB322AECECCA004B9143 /* QRScannerUIView.swift */,
);
path = Utils;
sourceTree = "<group>";
@ -550,14 +550,13 @@
isa = XCBuildConfiguration;
buildSettings = {
ALWAYS_EMBED_SWIFT_STANDARD_LIBRARIES = YES;
APP_BASE_URL = "http://192.168.1.8";
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
ASSETCATALOG_COMPILER_GLOBAL_ACCENT_COLOR_NAME = AccentColor;
CODE_SIGN_ENTITLEMENTS = ntfy/ntfy.entitlements;
CODE_SIGN_STYLE = Automatic;
CURRENT_PROJECT_VERSION = 3;
DEVELOPMENT_ASSET_PATHS = "\"ntfy/Assets/Preview Content\"";
DEVELOPMENT_TEAM = MZWHX5Z44T;
DEVELOPMENT_TEAM = YXQ4AMS4B4;
ENABLE_PREVIEWS = YES;
GENERATE_INFOPLIST_FILE = YES;
INFOPLIST_FILE = ntfy/Info.plist;
@ -574,7 +573,7 @@
"@executable_path/Frameworks",
);
MARKETING_VERSION = 1.2;
PRODUCT_BUNDLE_IDENTIFIER = com.tcaputi.ntfy;
PRODUCT_BUNDLE_IDENTIFIER = io.heckel.ntfy;
PRODUCT_NAME = "$(TARGET_NAME)";
SWIFT_EMIT_LOC_STRINGS = YES;
SWIFT_VERSION = 5.0;
@ -586,14 +585,13 @@
isa = XCBuildConfiguration;
buildSettings = {
ALWAYS_EMBED_SWIFT_STANDARD_LIBRARIES = YES;
APP_BASE_URL = "http://192.168.1.8";
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
ASSETCATALOG_COMPILER_GLOBAL_ACCENT_COLOR_NAME = AccentColor;
CODE_SIGN_ENTITLEMENTS = ntfy/ntfy.entitlements;
CODE_SIGN_STYLE = Automatic;
CURRENT_PROJECT_VERSION = 3;
DEVELOPMENT_ASSET_PATHS = "\"ntfy/Assets/Preview Content\"";
DEVELOPMENT_TEAM = MZWHX5Z44T;
DEVELOPMENT_TEAM = YXQ4AMS4B4;
ENABLE_PREVIEWS = YES;
GENERATE_INFOPLIST_FILE = YES;
INFOPLIST_FILE = ntfy/Info.plist;
@ -610,7 +608,7 @@
"@executable_path/Frameworks",
);
MARKETING_VERSION = 1.2;
PRODUCT_BUNDLE_IDENTIFIER = com.tcaputi.ntfy;
PRODUCT_BUNDLE_IDENTIFIER = io.heckel.ntfy;
PRODUCT_NAME = "$(TARGET_NAME)";
SWIFT_EMIT_LOC_STRINGS = YES;
SWIFT_VERSION = 5.0;
@ -621,11 +619,10 @@
9474F1ED282F3FFD00CDE4DD /* Debug */ = {
isa = XCBuildConfiguration;
buildSettings = {
APP_BASE_URL = "http://192.168.1.7";
CODE_SIGN_ENTITLEMENTS = ntfyNSE/ntfyNSE.entitlements;
CODE_SIGN_STYLE = Automatic;
CURRENT_PROJECT_VERSION = 3;
DEVELOPMENT_TEAM = MZWHX5Z44T;
DEVELOPMENT_TEAM = YXQ4AMS4B4;
GENERATE_INFOPLIST_FILE = YES;
INFOPLIST_FILE = ntfyNSE/Info.plist;
INFOPLIST_KEY_CFBundleDisplayName = ntfyNSE;
@ -637,7 +634,7 @@
"@executable_path/../../Frameworks",
);
MARKETING_VERSION = 1.2;
PRODUCT_BUNDLE_IDENTIFIER = com.tcaputi.ntfy.ntfyNSE;
PRODUCT_BUNDLE_IDENTIFIER = io.heckel.ntfy.ntfyNSE;
PRODUCT_NAME = "$(TARGET_NAME)";
SKIP_INSTALL = YES;
SWIFT_EMIT_LOC_STRINGS = YES;
@ -649,11 +646,10 @@
9474F1EE282F3FFD00CDE4DD /* Release */ = {
isa = XCBuildConfiguration;
buildSettings = {
APP_BASE_URL = "http://192.168.1.7";
CODE_SIGN_ENTITLEMENTS = ntfyNSE/ntfyNSE.entitlements;
CODE_SIGN_STYLE = Automatic;
CURRENT_PROJECT_VERSION = 3;
DEVELOPMENT_TEAM = MZWHX5Z44T;
DEVELOPMENT_TEAM = YXQ4AMS4B4;
GENERATE_INFOPLIST_FILE = YES;
INFOPLIST_FILE = ntfyNSE/Info.plist;
INFOPLIST_KEY_CFBundleDisplayName = ntfyNSE;
@ -665,7 +661,7 @@
"@executable_path/../../Frameworks",
);
MARKETING_VERSION = 1.2;
PRODUCT_BUNDLE_IDENTIFIER = com.tcaputi.ntfy.ntfyNSE;
PRODUCT_BUNDLE_IDENTIFIER = io.heckel.ntfy.ntfyNSE;
PRODUCT_NAME = "$(TARGET_NAME)";
SKIP_INSTALL = YES;
SWIFT_EMIT_LOC_STRINGS = YES;

View file

@ -58,7 +58,7 @@
launchAutomaticallySubstyle = "2">
<RemoteRunnable
runnableDebuggingMode = "0"
BundleIdentifier = "com.tcaputi.ntfy"
BundleIdentifier = "io.heckel.ntfy"
RemotePath = "/var/containers/Bundle/Application/508E12DE-12D7-4A45-8D44-B351AFC4BF23/ntfy.app">
</RemoteRunnable>
<MacroExpansion>
@ -77,7 +77,6 @@
savedToolIdentifier = ""
useCustomWorkingDirectory = "NO"
debugDocumentVersioning = "YES"
askForAppToLaunch = "Yes"
launchAutomaticallySubstyle = "2">
<BuildableProductRunnable
runnableDebuggingMode = "0">

View file

@ -161,8 +161,21 @@ extension AppDelegate: UNUserNotificationCenterDelegate {
extension AppDelegate: MessagingDelegate {
func messaging(_ messaging: Messaging, didReceiveRegistrationToken fcmToken: String?) {
Log.d(tag, "Firebase token received: \(String(describing: fcmToken))")
// We wait until we have a registration token before subscribing to our pollTopic
// Subscribe to ~poll topic
Messaging.messaging().subscribe(toTopic: pollTopic)
// Re-subscribe to Firebase for all topics
let store = Store.shared
store.getSubscriptions()?.forEach{ subscription in
if let baseUrl = subscription.baseUrl, let topic = subscription.topic {
Log.d(tag, "Re-subscribing to topic \(baseUrl)/\(topic)")
if baseUrl == Config.appBaseUrl {
Messaging.messaging().subscribe(toTopic: topic)
} else {
Messaging.messaging().subscribe(toTopic: topicHash(baseUrl: baseUrl, topic: topic))
}
}
}
}
}

View file

@ -5,7 +5,7 @@ import Firebase
@main
struct AppMain: App {
private let tag = "main"
private let tag = "AppMain"
@UIApplicationDelegateAdaptor(AppDelegate.self) var delegate: AppDelegate
@StateObject private var store = Store.shared

View file

@ -2,8 +2,9 @@ import CoreData
import SwiftUI
class NotificationsObservable: NSObject, ObservableObject {
private let tag = "NotificationsObservable"
private var subscriptionID: NSManagedObjectID
private lazy var fetchedResultsController: NSFetchedResultsController<Notification> = {
let fetchRequest: NSFetchRequest<Notification> = Notification.fetchRequest()
@ -28,7 +29,7 @@ class NotificationsObservable: NSObject, ObservableObject {
try self.fetchedResultsController.performFetch()
self.notifications = self.fetchedResultsController.fetchedObjects ?? []
} catch {
print("Failed to fetch notifications.")
Log.w(tag, "Failed to fetch notifications \(error)")
}
}
}

View file

@ -7,7 +7,7 @@ import Combine
class Store: ObservableObject {
static let shared = Store()
static let tag = "Store"
static let appGroup = "group.com.tcaputi.ntfy" // Must match app group of ntfy = ntfyNSE targets
static let appGroup = "group.io.heckel.ntfy" // Must match app group of ntfy = ntfyNSE targets
static let modelName = "ntfy" // Must match .xdatamodeld folder
static let prefKeyDefaultBaseUrl = "defaultBaseUrl"
@ -80,7 +80,7 @@ class Store: ObservableObject {
subscription.baseUrl = baseUrl
subscription.topic = topic
DispatchQueue.main.sync {
print("----------> SAVING SUBSCRIPTION \(topic)")
Log.d(Store.tag, "Storing subscription baseUrl=\(baseUrl), topic=\(topic)")
try? context.save()
}
return subscription
@ -121,7 +121,7 @@ class Store: ObservableObject {
notification.subscription = subscription
subscription.addToNotifications(notification)
subscription.lastNotificationId = message.id
print("--------> STORING NOTIFICATION")
Log.d(Store.tag, "Storing notifcation with ID \(notification.id ?? "<unknown>")")
try context.save()
} catch let error {
Log.w(Store.tag, "Cannot store notification (fromMessage)", error)

View file

@ -2,6 +2,7 @@ import CoreData
import SwiftUI
class SubscriptionsObservable: NSObject, ObservableObject {
private let tag = "SubscriptionsObservable"
override init() {
super.init()
@ -18,10 +19,10 @@ class SubscriptionsObservable: NSObject, ObservableObject {
controller.delegate = self
do {
print("-----------> FETCHING SUBSCRIPTIONS")
Log.d(tag, "Fetching subscriptions")
try controller.performFetch()
} catch {
print("Failed to fetch items: \(error)")
Log.w(tag, "Failed to fetch items: \(error)", error)
}
return controller
@ -35,10 +36,10 @@ class SubscriptionsObservable: NSObject, ObservableObject {
controller.delegate = self
do {
print("-----------> FETCHING NOTIFICATIONS")
Log.d(tag, "Fetching notifications")
try controller.performFetch()
} catch {
print("Failed to fetch notifications: \(error)")
Log.w(tag, "Failed to fetch notifications: \(error)", error)
}
return controller
@ -51,7 +52,7 @@ class SubscriptionsObservable: NSObject, ObservableObject {
extension SubscriptionsObservable: NSFetchedResultsControllerDelegate {
func controllerDidChangeContent(_ controller: NSFetchedResultsController<NSFetchRequestResult>) {
print("-----------> FETCHING NOTIFICATIONS")
Log.d(tag, "Fetching notifications")
DispatchQueue.main.async {
self.objectWillChange.send()
}

View file

@ -1,7 +1,7 @@
import Foundation
struct Log {
private static let dateFormat = "yyyy-MM-dd hh:mm:ss.SSSSSSZ"
private static let dateFormat = "yy-MM-dd hh:mm:ss.SSS"
private static let dateFormatter: DateFormatter = {
let formatter = DateFormatter()
formatter.dateFormat = dateFormat

View file

@ -6,7 +6,7 @@
<string>development</string>
<key>com.apple.security.application-groups</key>
<array>
<string>group.com.tcaputi.ntfy</string>
<string>group.io.heckel.ntfy</string>
</array>
</dict>
</plist>

View file

@ -6,7 +6,7 @@
<string>development</string>
<key>com.apple.security.application-groups</key>
<array>
<string>group.com.tcaputi.ntfy</string>
<string>group.io.heckel.ntfy</string>
</array>
</dict>
</plist>