Notification Center

RSS for tag

Create and manage app extensions that implement Today widgets using Notification Center.

Posts under Notification Center tag

200 Posts

Post

Replies

Boosts

Views

Activity

Request IOS Audio Driver change
Hello, I have been creating an audio recording app that records audio in the background. For example, you are just starting to pull over in your car, or are walking down an alley, you hit "record" and the app will record in the background, allowing you to use your phone otherwise like normal while you are going through the tense time. I have noticed that, on any audio recording app, once you start recording audio, all audible notification tones get muted. I have narrowed the issue down to the IOS audio driver. That said, is there a way to request a revision to this audio driver issue, in the next IOS update? Thanks!
0
0
832
Apr ’23
system preferred language is Icelandic, ios14/15 display push notification by Icelandic, but ios16 display by English
set system preferred language from English to Icelandic(which iOS not support, display English) ios14/15 display push notification by Icelandic, but ios16 display by English, not Icelandic. same app, different display. push notification's Icelandic definition file is localizable.strings. Is there some other setting I miss?
0
0
709
Apr ’23
Command Center media buttons is not syncing with App's media state Swift
I have created a media player plugin and exported it via swift framework for my Unity project, the media player works fine on the app. But, when the App's media state is paused the Command Center media button does not update its still on the pause icon and same as with playing the command center button does not update. I already have initiated the AVAudioSession shared instance and set the category to .playback and have also set the .setActive to true. let audioSession = AVAudioSession .sharedInstance() try audioSession .setCategory( .playback, mode: .default ) print("Playback OK") try audioSession.setActive(true) print("Session is Active") I also have initialised the command center, for handling the play and pause events whenever the buttons are clicked in command center. self.commandCenter.playCommand.isEnabled = true self.commandCenter.playCommand.addTarget { [weak self] (event) -> MPRemoteCommandHandlerStatus in self?.play() return .success } self.commandCenter.pauseCommand.isEnabled = true self.commandCenter.pauseCommand.addTarget { [weak self] (event) -> MPRemoteCommandHandlerStatus in self?.pause() return .success } This is the code for the handling the pause self.nowPlayingInfo[MPNowPlayingInfoPropertyElapsedPlaybackTime] = CMTimeGetSeconds(self.player.currentTime()) self.nowPlayingInfo[MPMediaItemPropertyPlaybackDuration] = CMTimeGetSeconds(self.player.currentItem!.duration); self.nowPlayingInfo[MPNowPlayingInfoPropertyPlaybackRate] = 0 self.nowPlayingInfo[MPNowPlayingInfoPropertyDefaultPlaybackRate] = 0 MPNowPlayingInfoCenter.default().nowPlayingInfo = self.nowPlayingInfo self.player.pause() and This is the code for handling the play self.nowPlayingInfo[MPNowPlayingInfoPropertyElapsedPlaybackTime] = CMTimeGetSeconds(self.player.currentTime()) self.nowPlayingInfo[MPMediaItemPropertyPlaybackDuration] = CMTimeGetSeconds(self.player.currentItem!.duration); self.nowPlayingInfo[MPNowPlayingInfoPropertyPlaybackRate] = 1 self.nowPlayingInfo[MPNowPlayingInfoPropertyDefaultPlaybackRate] = 1 MPNowPlayingInfoCenter.default().nowPlayingInfo = self.nowPlayingInfo; self.player.play() What i am expecting is when i click on pause in the App the command center's button should be the play icon if I click on play the command center's button should be pause icon, but right now nothing is working. Please tell me what I am missing here?
1
0
1.2k
Apr ’23
Scheduling UserNotifications in MessageFilter app extension is throwing an error
I have a MessageFilter app extension embedded in my iOS app and it works great filtering out junk SMS messages. I want to show a local notification whenever a message has moved to the junk folder and I'm trying to do it like so: final class MessageFilterExtension: ILMessageFilterExtension { func handle(_ queryRequest: ILMessageFilterQueryRequest, context: ILMessageFilterExtensionContext, completion: @escaping (ILMessageFilterQueryResponse) -> Void) { let offlineAction = self.offlineAction(for: queryRequest) switch offlineAction { case .allow, .junk, .promotion, .transaction: let response = ILMessageFilterQueryResponse() response.action = offlineAction scheduleLocalNotification(for: keyword) /* -> Here */ completion(response) @unknown default: break } } func scheduleLocalNotification(for keyword: Keyword) { let content = UNMutableNotificationContent() content.title = "Test" content.body = "Test2" content.categoryIdentifier = "FILTER_SMS_BLOCKED" let trigger = UNTimeIntervalNotificationTrigger(timeInterval: 3, repeats: false) let request = UNNotificationRequest(identifier: UUID().uuidString, content: content, trigger: trigger) UNUserNotificationCenter.current().add(request) { [weak self] error in guard let self else { return } if let error { logger.log(level: .os, icon: "💥", "Error scheduling local notification: \(error)") } } } } But I am getting the following error: 🌐 💥 Error scheduling local notification: Error Domain=NSCocoaErrorDomain Code=4099 "The connection to service named com.apple.usernotifications.usernotificationservice was invalidated from this process." UserInfo={NSDebugDescription=The connection to service named com.apple.usernotifications.usernotificationservice was invalidated from this process.} I have setup the Push Notifications entitlement in the main app and in this app extension, and also requested push notifications authorization from the user on the main app. What am I missing here? Thanks!
1
0
904
Apr ’23
Is it possible to schedule a timer in a notification service extension?
I'm trying to fire a timer in a notification service extension, but what would work in the app doesn't work in the extension i.e. Timer.scheduledTimer(timeInterval: 8.0, target: self, selector: #selector(doSomeStuff2), userInfo: nil, repeats: false) or Timer.scheduledTimer(withTimeInterval: 7.0, repeats: false) { timer in ... } and so on, etc. Is that a way of getting a timer to fire in an extension?
1
0
1.4k
Apr ’23
On daylight saving time change
Last night we change hour for daylight saving time (at 2:00 it would be 3:00). So I made a simple test to set an alarm at 2:10 At 1:59, clock jumped logically to 3:00 no alarm At 3:10, alarm rang (in fact I had turned it off and back on, but that has no influence) I set an alarm at 3:15, of course it rang I set a new alarm at 2:20 It rang at 3:20 Conclusion: Clock app "replicates" the alarms between 2:00 and 2:59 into 3:00 - 3:59. Which is great, not to miss any. Question: Is this specific to Clock app or a more general system behaviour for all time events ? If so, there may be a side effect: I set an event A to turn On a light at 2:45 And set event B to turn it Off at 3:15 Then B will occur before A and the light will remain On There is no perfect solution ("warping" 2:00 - 2:59 into a minute at 3:00 would creates other issues). Extra question: What happens on winter time ? Will alarm ring twice at 2:10 ?
0
0
2.3k
Mar ’23
Can we send Local Push Notifications from DeviceActivityMonitor extension?
I'm wondering if we able to send Local Push Notifications from DeviceActivityMonitor extension... If we have to use AppGroups to pass info between an app and the extension, could we post notification though UNNotificationRequest? I also tried to push data through NotificationCenter, also doesn’t work. Can we do so, or did something wrong? Should these cases that I described above work from iOS 16 and above or not? Thank you!
2
0
1.3k
Mar ’23
Send notifications shown at schedule time
We are developing a feature to push remote schedule notification. Right now we implemented with silent remote notification to trigger the app schedule a local notification using data from those silent notifications received. We found the success rate is really low to be able to schedule a notification on time(before our target time) since notification center hold the background notification when app is not running util user launch the app next time. Is there any walk arounds to improve the success rate?
0
0
530
Mar ’23
UNNotificationCenter API arbitrary failures, loses connection with NotificationCenter daemon
Hi. My MacOS application (Obj-C, Cocoa MacOS 10.15 or later) sets itself as delegate for UNNotificationCenter, and implements both - (void)userNotificationCenter:(UNUserNotificationCenter *)center        willPresentNotification:(UNNotification *)notification          withCompletionHandler:(void (^)(UNNotificationPresentationOptions))completionHandler and - (void)userNotificationCenter:(UNUserNotificationCenter *)center didReceiveNotificationResponse:(nonnull UNNotificationResponse *)response          withCompletionHandler:(nonnull void (^)(void))completionHandler It creates and schedules many user-notifications (mostly with no "trigger" meaning - present to the user ASAP and sometimes 2.5 seconds in the future, so to group notifications better. Each notification is also holding som dictionary of "UserInfo" containing some data. My AppDelegates handles user responses (both standard open, cancellation, and "cancel-all") and also custom user-actions I attach to the category. All works well on most Macs and almost always. However - On few Macs, at arbitrary times, users complain that "clicking a notification in Notification Center will not open the app" and that "expected notifications are missing altogether". My logs show the following. Quite frequently I see the following: error log lines: 2023-02-16 17:32:21.413065+0200 0xa58109d Error 0x0 51690 0 <UserNotifications`__104-[UNUserNotificationServiceConnection addNotificationRequest:forBundleIdentifier:withCompletionHandler:]_block_invoke_2.cold.1> myApp: (UserNotifications) [com.apple.UserNotifications:Connections] [com.myCompany.myApp] Adding notification request failed with error: Error Domain=NSCocoaErrorDomain Code=4097 "connection to service on pid 451 named com.apple.usernotifications.usernotificationservice" UserInfo={NSDebugDescription=connection to service on pid 451 named com.apple.usernotifications.usernotificationservice} followed by my own log lines - like this: 2023-02-16 17:32:21.413279+0200 0xa5811b5 Error 0x0 51690 10 <myApp> myApp: [com.myCompany.myApp:UI] NotificationRequest B6096CDE-6229-42AA-A6BC-EBCC06540C53 stage:scanFinished failed to schedule: Error Domain=NSCocoaErrorDomain Code=4097 "connection to service on pid 451 named com.apple.usernotifications.usernotificationservice" UserInfo={NSDebugDescription=connection to service on pid 451 named com.apple.usernotifications.usernotificationservice} Of course - the un-scheduled notification won't appear to the user, but worse - clicks on other, DELIVERED notifications, won't call back my delegate. Strangely enough - few seconds later, sometimes minutes - other attempts to schedule new notifications - succeed without any error. I guess this "connection" is somehow automatically re-established. I looked for information about this error (Domain=NSCocoaErrorDomain Code=4097) and it seems to be pretty generic, and used for many scenarios where connection to some service is lost. Of course my code doesn't maintain any such connection manually/programmatically - I guess it is the [UNUserNotificationCenter currentNotificationCenter] implementation which holds connection to its "daemon" or "agent" or some XPC service. The really bad thing here - is that I DO NOT KNOW how to improve anything here. [UNUserNotificationCenter currentNotificationCenter] Is a singleton, that I can't control, or re-create, to somehow revive the connection There is no way I know of, to tell it to do so, or even to check whether it has a connection. I rely on Notification-Center to maintain my MODEL DATA for scheduled requests, in case my App is relaunched - and now I can't get it. Please advise. this is quite urgent for me. The issue appears more on Big Sur.
0
1
1k
Feb ’23
communication notifications not showing avatar in local notification
import UIKit import Intents class ViewController: UIViewController {   override func viewDidLoad() {     super.viewDidLoad()   }   @IBAction func sendNotification(_ sender: Any) {     var content = UNMutableNotificationContent()     content.title = "Test"     content.subtitle = "Solo"     content.body = "Test"     content.sound = UNNotificationSound.default     content.categoryIdentifier = "categoryName"     var personNameComponents = PersonNameComponents()     personNameComponents.nickname = "Sender Name"     let avatar = INImage(imageData: UIImage(named: "Solo")?.pngData() ?? Data())     let senderPerson = INPerson(       personHandle: INPersonHandle(value: "1233211234", type: .unknown),       nameComponents: personNameComponents,       displayName: "Sender Name",       image: avatar,       contactIdentifier: nil,       customIdentifier: nil,       isMe: false,       suggestionType: .none     )     let intent = INSendMessageIntent(       recipients: .none,       outgoingMessageType: .outgoingMessageText,       content: "Test",       speakableGroupName: INSpeakableString(spokenPhrase: "Sender Name"),       conversationIdentifier: "sampleConversationIdentifier",       serviceName: nil,       sender: senderPerson,       attachments: nil     )     intent.setImage(avatar, forParameterNamed: .sender)     let interaction = INInteraction(intent: intent, response: nil)     interaction.direction = .incoming     interaction.donate(completion: nil)     do {       content = try content.updating(from: intent) as! UNMutableNotificationContent     } catch {       print(error)     }     let trigger = UNTimeIntervalNotificationTrigger(timeInterval: 3, repeats: false)     let request = UNNotificationRequest(identifier: UUID().uuidString, content: content, trigger: trigger)     UNUserNotificationCenter.current().add(request)   } }
0
0
1.1k
Feb ’23
GameKit Push Notifications for GKTurnBasedMatch
I'm trying to add badges to my app icon when GameCenter provides a notification from a GKTurnBasedMatch. There isn't much information about how to do this. One old post suggests implementing an AppDelegate method: https://developer.apple.com/forums/thread/54056 Since my project is in SwiftUI, I tried creating a UIApplicationDelegateAdaptor to support an AppDelegate, and implementing the func application(: didFinishLaunchingWithOptions:) method as follows, attempting to update it to support the newer notification object: func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey : Any]? = nil) -> Bool {         application.registerForRemoteNotifications()         UNUserNotificationCenter.current().requestAuthorization(options: [.badge, .alert, .sound]) { success, error in             // not sure what to do here         }         return true     } This method does seem to get called when the app opens, but badges still do not appear on my app's icon.
0
0
826
Feb ’23
Question about app permissions and push notification filtering/forwarding
I'm doing some product brainstorming and was wondering if its possible (or still possible) to, from an App Store installed app, do something like notification filter from Messages, Email, Gmail, basically both from other App-Store-downloaded apps and system apps. Is that possible? Example: Am I able to detect a message notification from iMessage and do something in my app ? Thanks in advanced, kev
0
0
539
Feb ’23
didRegisterForRemoteNotificationsWithDeviceToken is never called
Hi everyone, Hi have no clue why I can't get my device token anymore. Since the last Xcode update (currently 14.2), didRegisterForRemoteNotificationsWithDeviceToken is never call. It was working before. class AppDelegate: UIResponder, UIApplicationDelegate, UNUserNotificationCenterDelegate, TimerApplicationDelegate {    func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool {     AppDelegate.shared = self     // appearance     NewCashingViewController.setupAppearance()     // user-notification and push-notification     registerForPushNotifications(for: application)     return true   }    func registerForPushNotifications(for application: UIApplication) {     UNUserNotificationCenter.current().delegate = self     UNUserNotificationCenter.current().requestAuthorization(options: [.alert, .sound, .badge]) { [weak self] granted, _ in       print("Permission granted: \(granted)")       guard granted else { return }       self?.getNotificationSettings(for: application)     }   }   func getNotificationSettings(for application: UIApplication) {     UNUserNotificationCenter.current().getNotificationSettings { settings in       print("Notification settings: \(settings)")       guard settings.authorizationStatus == .authorized else { return }       DispatchQueue.main.async { application.registerForRemoteNotifications() }     }   }   func application(_ application: UIApplication, didRegisterForRemoteNotificationsWithDeviceToken deviceToken: Data) {     let tokenParts = deviceToken.map { data in String(format: "%02.2hhx", data) }     let token = tokenParts.joined()     UserDefaults.standard.set(token, forKey: UserDefaultsKeys.deviceToken)     print("Device Token: \(token)")   }    func application(_ application: UIApplication, didFailToRegisterForRemoteNotificationsWithError error: Error) {     print("Failed to register: \(error)")   } } using Xcode 14.2, iOS 14.5 and 16.2 Thank you for your time.
1
0
907
Feb ’23
Notifications not working on Mac Ventura
Notification was working fine but suddenly stopped showing. I tried fixing it by going through: Notification setting. Application notifications setting. Privacy & security. Screen Time. Focus. Restarting and holding the power button to shut down.
Replies
0
Boosts
0
Views
704
Activity
Apr ’23
Request IOS Audio Driver change
Hello, I have been creating an audio recording app that records audio in the background. For example, you are just starting to pull over in your car, or are walking down an alley, you hit "record" and the app will record in the background, allowing you to use your phone otherwise like normal while you are going through the tense time. I have noticed that, on any audio recording app, once you start recording audio, all audible notification tones get muted. I have narrowed the issue down to the IOS audio driver. That said, is there a way to request a revision to this audio driver issue, in the next IOS update? Thanks!
Replies
0
Boosts
0
Views
832
Activity
Apr ’23
system preferred language is Icelandic, ios14/15 display push notification by Icelandic, but ios16 display by English
set system preferred language from English to Icelandic(which iOS not support, display English) ios14/15 display push notification by Icelandic, but ios16 display by English, not Icelandic. same app, different display. push notification's Icelandic definition file is localizable.strings. Is there some other setting I miss?
Replies
0
Boosts
0
Views
709
Activity
Apr ’23
Command Center media buttons is not syncing with App's media state Swift
I have created a media player plugin and exported it via swift framework for my Unity project, the media player works fine on the app. But, when the App's media state is paused the Command Center media button does not update its still on the pause icon and same as with playing the command center button does not update. I already have initiated the AVAudioSession shared instance and set the category to .playback and have also set the .setActive to true. let audioSession = AVAudioSession .sharedInstance() try audioSession .setCategory( .playback, mode: .default ) print("Playback OK") try audioSession.setActive(true) print("Session is Active") I also have initialised the command center, for handling the play and pause events whenever the buttons are clicked in command center. self.commandCenter.playCommand.isEnabled = true self.commandCenter.playCommand.addTarget { [weak self] (event) -> MPRemoteCommandHandlerStatus in self?.play() return .success } self.commandCenter.pauseCommand.isEnabled = true self.commandCenter.pauseCommand.addTarget { [weak self] (event) -> MPRemoteCommandHandlerStatus in self?.pause() return .success } This is the code for the handling the pause self.nowPlayingInfo[MPNowPlayingInfoPropertyElapsedPlaybackTime] = CMTimeGetSeconds(self.player.currentTime()) self.nowPlayingInfo[MPMediaItemPropertyPlaybackDuration] = CMTimeGetSeconds(self.player.currentItem!.duration); self.nowPlayingInfo[MPNowPlayingInfoPropertyPlaybackRate] = 0 self.nowPlayingInfo[MPNowPlayingInfoPropertyDefaultPlaybackRate] = 0 MPNowPlayingInfoCenter.default().nowPlayingInfo = self.nowPlayingInfo self.player.pause() and This is the code for handling the play self.nowPlayingInfo[MPNowPlayingInfoPropertyElapsedPlaybackTime] = CMTimeGetSeconds(self.player.currentTime()) self.nowPlayingInfo[MPMediaItemPropertyPlaybackDuration] = CMTimeGetSeconds(self.player.currentItem!.duration); self.nowPlayingInfo[MPNowPlayingInfoPropertyPlaybackRate] = 1 self.nowPlayingInfo[MPNowPlayingInfoPropertyDefaultPlaybackRate] = 1 MPNowPlayingInfoCenter.default().nowPlayingInfo = self.nowPlayingInfo; self.player.play() What i am expecting is when i click on pause in the App the command center's button should be the play icon if I click on play the command center's button should be pause icon, but right now nothing is working. Please tell me what I am missing here?
Replies
1
Boosts
0
Views
1.2k
Activity
Apr ’23
Scheduling UserNotifications in MessageFilter app extension is throwing an error
I have a MessageFilter app extension embedded in my iOS app and it works great filtering out junk SMS messages. I want to show a local notification whenever a message has moved to the junk folder and I'm trying to do it like so: final class MessageFilterExtension: ILMessageFilterExtension { func handle(_ queryRequest: ILMessageFilterQueryRequest, context: ILMessageFilterExtensionContext, completion: @escaping (ILMessageFilterQueryResponse) -> Void) { let offlineAction = self.offlineAction(for: queryRequest) switch offlineAction { case .allow, .junk, .promotion, .transaction: let response = ILMessageFilterQueryResponse() response.action = offlineAction scheduleLocalNotification(for: keyword) /* -> Here */ completion(response) @unknown default: break } } func scheduleLocalNotification(for keyword: Keyword) { let content = UNMutableNotificationContent() content.title = "Test" content.body = "Test2" content.categoryIdentifier = "FILTER_SMS_BLOCKED" let trigger = UNTimeIntervalNotificationTrigger(timeInterval: 3, repeats: false) let request = UNNotificationRequest(identifier: UUID().uuidString, content: content, trigger: trigger) UNUserNotificationCenter.current().add(request) { [weak self] error in guard let self else { return } if let error { logger.log(level: .os, icon: "💥", "Error scheduling local notification: \(error)") } } } } But I am getting the following error: 🌐 💥 Error scheduling local notification: Error Domain=NSCocoaErrorDomain Code=4099 "The connection to service named com.apple.usernotifications.usernotificationservice was invalidated from this process." UserInfo={NSDebugDescription=The connection to service named com.apple.usernotifications.usernotificationservice was invalidated from this process.} I have setup the Push Notifications entitlement in the main app and in this app extension, and also requested push notifications authorization from the user on the main app. What am I missing here? Thanks!
Replies
1
Boosts
0
Views
904
Activity
Apr ’23
Is it possible to schedule a timer in a notification service extension?
I'm trying to fire a timer in a notification service extension, but what would work in the app doesn't work in the extension i.e. Timer.scheduledTimer(timeInterval: 8.0, target: self, selector: #selector(doSomeStuff2), userInfo: nil, repeats: false) or Timer.scheduledTimer(withTimeInterval: 7.0, repeats: false) { timer in ... } and so on, etc. Is that a way of getting a timer to fire in an extension?
Replies
1
Boosts
0
Views
1.4k
Activity
Apr ’23
How to handle notification action when app is killed
Did receive method is triggered only when the application is not killed, but I need solution how to handle case when i tap to notification actions when app is KILLED, because every time only goes in did finish launch method and launch options is NIL.
Replies
0
Boosts
0
Views
787
Activity
Apr ’23
On daylight saving time change
Last night we change hour for daylight saving time (at 2:00 it would be 3:00). So I made a simple test to set an alarm at 2:10 At 1:59, clock jumped logically to 3:00 no alarm At 3:10, alarm rang (in fact I had turned it off and back on, but that has no influence) I set an alarm at 3:15, of course it rang I set a new alarm at 2:20 It rang at 3:20 Conclusion: Clock app "replicates" the alarms between 2:00 and 2:59 into 3:00 - 3:59. Which is great, not to miss any. Question: Is this specific to Clock app or a more general system behaviour for all time events ? If so, there may be a side effect: I set an event A to turn On a light at 2:45 And set event B to turn it Off at 3:15 Then B will occur before A and the light will remain On There is no perfect solution ("warping" 2:00 - 2:59 into a minute at 3:00 would creates other issues). Extra question: What happens on winter time ? Will alarm ring twice at 2:10 ?
Replies
0
Boosts
0
Views
2.3k
Activity
Mar ’23
Can we send Local Push Notifications from DeviceActivityMonitor extension?
I'm wondering if we able to send Local Push Notifications from DeviceActivityMonitor extension... If we have to use AppGroups to pass info between an app and the extension, could we post notification though UNNotificationRequest? I also tried to push data through NotificationCenter, also doesn’t work. Can we do so, or did something wrong? Should these cases that I described above work from iOS 16 and above or not? Thank you!
Replies
2
Boosts
0
Views
1.3k
Activity
Mar ’23
Send notifications shown at schedule time
We are developing a feature to push remote schedule notification. Right now we implemented with silent remote notification to trigger the app schedule a local notification using data from those silent notifications received. We found the success rate is really low to be able to schedule a notification on time(before our target time) since notification center hold the background notification when app is not running util user launch the app next time. Is there any walk arounds to improve the success rate?
Replies
0
Boosts
0
Views
530
Activity
Mar ’23
Is this possible without a backend server?
The process of the app I'm trying to make is simply like this. It calls the weather API every morning at 7:00 and gives a notification if it rains. Do I need to create a new backend server or is it possible to schedule on iOS?
Replies
0
Boosts
0
Views
942
Activity
Mar ’23
Notifications doesn’t sound
Is anyone else experiencing notifications appearing on iPhone but no sounds? I’ve checked all settings and they seem to be correct. This just started a day ago . I reset the notifications reset the apps .
Replies
1
Boosts
0
Views
522
Activity
Mar ’23
UNNotificationCenter API arbitrary failures, loses connection with NotificationCenter daemon
Hi. My MacOS application (Obj-C, Cocoa MacOS 10.15 or later) sets itself as delegate for UNNotificationCenter, and implements both - (void)userNotificationCenter:(UNUserNotificationCenter *)center        willPresentNotification:(UNNotification *)notification          withCompletionHandler:(void (^)(UNNotificationPresentationOptions))completionHandler and - (void)userNotificationCenter:(UNUserNotificationCenter *)center didReceiveNotificationResponse:(nonnull UNNotificationResponse *)response          withCompletionHandler:(nonnull void (^)(void))completionHandler It creates and schedules many user-notifications (mostly with no "trigger" meaning - present to the user ASAP and sometimes 2.5 seconds in the future, so to group notifications better. Each notification is also holding som dictionary of "UserInfo" containing some data. My AppDelegates handles user responses (both standard open, cancellation, and "cancel-all") and also custom user-actions I attach to the category. All works well on most Macs and almost always. However - On few Macs, at arbitrary times, users complain that "clicking a notification in Notification Center will not open the app" and that "expected notifications are missing altogether". My logs show the following. Quite frequently I see the following: error log lines: 2023-02-16 17:32:21.413065+0200 0xa58109d Error 0x0 51690 0 <UserNotifications`__104-[UNUserNotificationServiceConnection addNotificationRequest:forBundleIdentifier:withCompletionHandler:]_block_invoke_2.cold.1> myApp: (UserNotifications) [com.apple.UserNotifications:Connections] [com.myCompany.myApp] Adding notification request failed with error: Error Domain=NSCocoaErrorDomain Code=4097 "connection to service on pid 451 named com.apple.usernotifications.usernotificationservice" UserInfo={NSDebugDescription=connection to service on pid 451 named com.apple.usernotifications.usernotificationservice} followed by my own log lines - like this: 2023-02-16 17:32:21.413279+0200 0xa5811b5 Error 0x0 51690 10 <myApp> myApp: [com.myCompany.myApp:UI] NotificationRequest B6096CDE-6229-42AA-A6BC-EBCC06540C53 stage:scanFinished failed to schedule: Error Domain=NSCocoaErrorDomain Code=4097 "connection to service on pid 451 named com.apple.usernotifications.usernotificationservice" UserInfo={NSDebugDescription=connection to service on pid 451 named com.apple.usernotifications.usernotificationservice} Of course - the un-scheduled notification won't appear to the user, but worse - clicks on other, DELIVERED notifications, won't call back my delegate. Strangely enough - few seconds later, sometimes minutes - other attempts to schedule new notifications - succeed without any error. I guess this "connection" is somehow automatically re-established. I looked for information about this error (Domain=NSCocoaErrorDomain Code=4097) and it seems to be pretty generic, and used for many scenarios where connection to some service is lost. Of course my code doesn't maintain any such connection manually/programmatically - I guess it is the [UNUserNotificationCenter currentNotificationCenter] implementation which holds connection to its "daemon" or "agent" or some XPC service. The really bad thing here - is that I DO NOT KNOW how to improve anything here. [UNUserNotificationCenter currentNotificationCenter] Is a singleton, that I can't control, or re-create, to somehow revive the connection There is no way I know of, to tell it to do so, or even to check whether it has a connection. I rely on Notification-Center to maintain my MODEL DATA for scheduled requests, in case my App is relaunched - and now I can't get it. Please advise. this is quite urgent for me. The issue appears more on Big Sur.
Replies
0
Boosts
1
Views
1k
Activity
Feb ’23
Spotify Taking Up Entire Lock Screen
Hey, my Spotify is taking up my entire lockscreen. I didn't mind when it's just the small bar, but the album cover is also appearing as a giant image. Any fixes would be appreciated! Note: The original lockscreen does resume when I close Spotify, but it didn't do the entire takeover before, so that's what I'm trying to get rid of.
Replies
1
Boosts
0
Views
1.1k
Activity
Feb ’23
communication notifications not showing avatar in local notification
import UIKit import Intents class ViewController: UIViewController {   override func viewDidLoad() {     super.viewDidLoad()   }   @IBAction func sendNotification(_ sender: Any) {     var content = UNMutableNotificationContent()     content.title = "Test"     content.subtitle = "Solo"     content.body = "Test"     content.sound = UNNotificationSound.default     content.categoryIdentifier = "categoryName"     var personNameComponents = PersonNameComponents()     personNameComponents.nickname = "Sender Name"     let avatar = INImage(imageData: UIImage(named: "Solo")?.pngData() ?? Data())     let senderPerson = INPerson(       personHandle: INPersonHandle(value: "1233211234", type: .unknown),       nameComponents: personNameComponents,       displayName: "Sender Name",       image: avatar,       contactIdentifier: nil,       customIdentifier: nil,       isMe: false,       suggestionType: .none     )     let intent = INSendMessageIntent(       recipients: .none,       outgoingMessageType: .outgoingMessageText,       content: "Test",       speakableGroupName: INSpeakableString(spokenPhrase: "Sender Name"),       conversationIdentifier: "sampleConversationIdentifier",       serviceName: nil,       sender: senderPerson,       attachments: nil     )     intent.setImage(avatar, forParameterNamed: .sender)     let interaction = INInteraction(intent: intent, response: nil)     interaction.direction = .incoming     interaction.donate(completion: nil)     do {       content = try content.updating(from: intent) as! UNMutableNotificationContent     } catch {       print(error)     }     let trigger = UNTimeIntervalNotificationTrigger(timeInterval: 3, repeats: false)     let request = UNNotificationRequest(identifier: UUID().uuidString, content: content, trigger: trigger)     UNUserNotificationCenter.current().add(request)   } }
Replies
0
Boosts
0
Views
1.1k
Activity
Feb ’23
GameKit Push Notifications for GKTurnBasedMatch
I'm trying to add badges to my app icon when GameCenter provides a notification from a GKTurnBasedMatch. There isn't much information about how to do this. One old post suggests implementing an AppDelegate method: https://developer.apple.com/forums/thread/54056 Since my project is in SwiftUI, I tried creating a UIApplicationDelegateAdaptor to support an AppDelegate, and implementing the func application(: didFinishLaunchingWithOptions:) method as follows, attempting to update it to support the newer notification object: func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey : Any]? = nil) -> Bool {         application.registerForRemoteNotifications()         UNUserNotificationCenter.current().requestAuthorization(options: [.badge, .alert, .sound]) { success, error in             // not sure what to do here         }         return true     } This method does seem to get called when the app opens, but badges still do not appear on my app's icon.
Replies
0
Boosts
0
Views
826
Activity
Feb ’23
When should I send notification token to server?
When should I send notification token to server? I am creating an application, but I don't know when I send notification token to server. So, Please tell me that. Japanese: 自作のアプリケーションを作っているのですが、どのタイミングでデバイストークンをサーバーに送信すれば良いでしょうか?
Replies
0
Boosts
0
Views
777
Activity
Feb ’23
Question about app permissions and push notification filtering/forwarding
I'm doing some product brainstorming and was wondering if its possible (or still possible) to, from an App Store installed app, do something like notification filter from Messages, Email, Gmail, basically both from other App-Store-downloaded apps and system apps. Is that possible? Example: Am I able to detect a message notification from iMessage and do something in my app ? Thanks in advanced, kev
Replies
0
Boosts
0
Views
539
Activity
Feb ’23
didRegisterForRemoteNotificationsWithDeviceToken is never called
Hi everyone, Hi have no clue why I can't get my device token anymore. Since the last Xcode update (currently 14.2), didRegisterForRemoteNotificationsWithDeviceToken is never call. It was working before. class AppDelegate: UIResponder, UIApplicationDelegate, UNUserNotificationCenterDelegate, TimerApplicationDelegate {    func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool {     AppDelegate.shared = self     // appearance     NewCashingViewController.setupAppearance()     // user-notification and push-notification     registerForPushNotifications(for: application)     return true   }    func registerForPushNotifications(for application: UIApplication) {     UNUserNotificationCenter.current().delegate = self     UNUserNotificationCenter.current().requestAuthorization(options: [.alert, .sound, .badge]) { [weak self] granted, _ in       print("Permission granted: \(granted)")       guard granted else { return }       self?.getNotificationSettings(for: application)     }   }   func getNotificationSettings(for application: UIApplication) {     UNUserNotificationCenter.current().getNotificationSettings { settings in       print("Notification settings: \(settings)")       guard settings.authorizationStatus == .authorized else { return }       DispatchQueue.main.async { application.registerForRemoteNotifications() }     }   }   func application(_ application: UIApplication, didRegisterForRemoteNotificationsWithDeviceToken deviceToken: Data) {     let tokenParts = deviceToken.map { data in String(format: "%02.2hhx", data) }     let token = tokenParts.joined()     UserDefaults.standard.set(token, forKey: UserDefaultsKeys.deviceToken)     print("Device Token: \(token)")   }    func application(_ application: UIApplication, didFailToRegisterForRemoteNotificationsWithError error: Error) {     print("Failed to register: \(error)")   } } using Xcode 14.2, iOS 14.5 and 16.2 Thank you for your time.
Replies
1
Boosts
0
Views
907
Activity
Feb ’23
Reset notification permissions on macOS
I want to test my UNUserNotificationCenter authorization workflow for my MacOS app. I can't seem to find a way to reset the authorization status to notDetermined again. tccutil doesn't seem to contain any options for this. Any suggestions?
Replies
0
Boosts
0
Views
747
Activity
Feb ’23