Post

Replies

Boosts

Views

Activity

Watch Device Name
I'm testing an app I'm developing on a real device: Watch Series 7 running watchOS 9.0.2. I have a WKExtensionDelegateAdaptor variable in the @main struct. I'm trying to print the name of the watch as found in Settings > General > About > Name. However, all I get is "Apple Watch" even though the name of the watch is "My Watch 7." I'm not sure if this has changed but not documented. Code is below: import SwiftUI @main struct TheApp: App {     @WKExtensionDelegateAdaptor private var extensionDelegate: ExtensionDelegate     var body: some Scene {         WindowGroup {             HomeView()         }     } } import WatchKit class ExtensionDelegate: WKExtensionDelegate { func applicationDidFinishLaunching() { print("Device name: \(WKInterfaceDevice.current().name)") } }
3
0
2.0k
Oct ’22
Local Notifications add request
I have a loop where I construct UNNotificationRequest instances and add them to the UNUserNotificationCenter. The add method does not generate an error, but neither does it seem to actually add the requests. I have inspected each request generated and they all seem to well formed, each id is unique, each date is unique. Authorization status is granted. I must be missing something. Thank you. See code:                  for oneEntry in allEntries {             guard let triggerDate = oneEntry.triggerDate,                 let id = oneEntry.id else { return }             let components = Calendar.current.dateComponents(in: .current, from: triggerDate)             let trigger = UNCalendarNotificationTrigger(dateMatching: components, repeats: false)             let content = UNMutableNotificationContent()             content.title = "University of XXXXXXX"             content.body = "Message body goes here"             content.badge = 0             content.sound = .default             let request = UNNotificationRequest(identifier: id, content: content, trigger: trigger)             UNUserNotificationCenter.current().add(request) { (error) in                 if let error = error {                     print(error.localizedDescription)                 }                 else {                     print("Added 1 notification to center")                     UNUserNotificationCenter.current().getPendingNotificationRequests { (allRequests) in                         print(allRequests.count)                     }                 }             }         }     }
0
0
650
Jul ’20