Joe Scotto desires to attract extra consideration to this query:
I wish to bypass the ~13 second notification delay that watchOS has when a companion app put in. I’d slightly keep away from setting a hard-coded delay once I schedule the notification and as an alternative simply have native notifications work the best way they need to. The system that units the notification ought to deal with it and that is it.
I’ve a watchOS and iOS app which might be set to run independently from each other, I can set up every individually and there’s no reliance on one another with something like WKSession.
The problem I am having is that when I’ve each the iOS and watchOS app put in, if my iPhone is unlocked, the notification will probably be delayed about 13 seconds on the watch. If I lock my telephone or uninstall the iOS app, notifications will present instantly on the watch. In line with Apple, that is how notifications are presently dealt with when the companion app is put in.
That is my code to schedule the notification:
func scheduleNotification(secondsFromNow: Double, title: String = “”, physique: String = “”) {
let uuid = UUID().uuidString
let content material = UNMutableNotificationContent()
content material.title = title
content material.physique = physique
content material.sound = UNNotificationSound.default
let set off = UNTimeIntervalNotificationTrigger(timeInterval: secondsFromNow, repeats: false)
let request = UNNotificationRequest(identifier: uuid, content material: content material, set off: set off)
// Request authorization once more in case person dismissed earlier than
self.requestAuthorization()
// Schedule the notification
if Config.notificationsEnabled() {
userNotificationCenter.add(request) { error in
if let error = error {
print(“Error scheduling notification: (error)”)
}
}
}
}
Is there a manner I can change this so the notification will show solely on the system it is scheduled from with out this delay? I’ve additionally tried utilizing WatchConnectivity to schedule a notification on each units with the identical identifier as recommended right here however the concern continues to be the identical the place the watch notification is delayed.
Lastly I will add that every app is totally standalone and doesn’t depend on one another in any manner. All notifications are native to the system (iOS or watchOS) that the app is working on.