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

PDFViewVisiblePagesChanged iOS 16
Hi, we have an application that observes PDFViewVisiblePagesChanged and PDFViewPageChanged notifications for detecting the scroll state of a PDFView NotificationCenter.default.addObserver(self,                                                 selector: #selector(handleOnScroll),                                                name: Notification.Name.PDFViewVisiblePagesChanged,                                                 object: nil) NotificationCenter.default.addObserver(self,                                                 selector: #selector(handleOnScroll),                                                name: Notification.Name.PDFViewPageChanged,                                                 object: nil) With iOS14 this worked like a charm, the notification gets triggered immediately when the user starts scrolling the pdf. In iOS16 we have issues, it seems that the notifications get triggered/send only after the scrolling has been completed/stopped. Can anybody confirm this? Has anybody a solution how we can detect a scrolling PDFView using a different method? Background: While the PDF is scrolling other elements of the UI need to be disabled. Thanks Jürgen
0
0
1.1k
Feb ’23
Could Widget receive remote notifications
I try to receive remote notifications in widgets(implemented through WidgetKit), but failed. It known that enable remote notifications should register first by calling UIApplication.shared.registerForRemoteNotifications() but in widget cannot calling shared, it is available in widgets @property(class, nonatomic, readonly) UIApplication *sharedApplication NS_EXTENSION_UNAVAILABLE_IOS("Use view controller based solutions where appropriate instead."); and if try to init a UIApplication(by UIApplication()), the app will crash for more than one UIApplication instance.
1
0
2.0k
Feb ’23
Can UserNotifications be used in a command line program?
I have a cli program which does a thing for a while, and I'd like it to post a notification on the screen when it's done. Note that because it's a standalone program, not an app, it doesn't have a bundle, per se. I tried to use UserNotifications, but I get an immediate error with the line let center = UNUserNotificationCenter.current() With the error: Terminating app due to uncaught exception 'NSInternalInconsistencyException', reason: 'bundleProxyForCurrentProcess is nil: mainBundle.bundleURL My entire program to produce this bug: import Foundation import UserNotifications let center = UNUserNotificationCenter.current() print("Hello, World!")
1
1
999
Feb ’23
Widget in iOS app not shown as Mac Catalyst app
I wish to support Mac with my iPhone/iPad app using Mac Catalyst. Our app shows widgets on iPhone/iPad home screen properly. Using Mac Catalyst is straight forward (except to exclude all ActivityKit codes). However, although the app shows up and work perfectly, I can't see the widgets in notification center. Separate compile the widget extensions show no errors but nothing is shown. Also tried build separately, drag into Applications folder, run the build and the widgets are not shown. Any suggestions? Using the Xcode 14.2 and macOS 13.1.
2
0
1.8k
Feb ’23
iOS 16 Popup request notification permission can be display multi times?
I'm having a problem in iOS. When popup request notification permission display then I dismiss pop up by button home or navigation bar (Not click to Allow or Don't Allow) => Not display setting Notification in app setting (Status not determined) => request notifications permission again => Popup displayed again. I can not find any doc about this behavior. Is this a change in iOS 16? Has anyone had this problem? Thank you for your interest.
0
0
924
Feb ’23
How to handle audio session interruptions while recording video
While recording a video, if an interruption occurs such as an incoming call or an alarm sound, the camera frezees and the video is not saved. I would like to handle this situation interrupting the video and saving it or removing the audio while it keeps recording. But after the interruption starts and the event is recognized, the variables regarding the video already recorded are reinitialized, causing the app not to save anything. This is part of the CameraManager class: var captureSession: AVCaptureSession? public func fileOutput(_: AVCaptureFileOutput, didStartRecordingTo _: URL, from _: [AVCaptureConnection]) { NotificationCenter.default.addObserver(self, selector: #selector(sessionInterruptionBegin), name: .AVCaptureSessionWasInterrupted, object: captureSession) NotificationCenter.default.addObserver(self, selector: #selector(sessionInterruptionEnd),name: .AVCaptureSessionInterruptionEnded, object: captureSession) NotificationCenter.default.addObserver(self, selector: #selector(audioSessionInterrupted), name: AVAudioSession.interruptionNotification, object: AVAudioSession.sharedInstance) print("STO PASSANDO DA AVCaptureFileOutputRecordingDelegate") captureSession?.beginConfiguration() if flashMode != .off { _updateIlluminationMode(flashMode) } captureSession?.commitConfiguration() //at this point captureSession starts collecting data about the video } extension CameraManager { @objc func sessionInterruptionBegin(notification: Notification) { print("Capture Session Interruption begin Notification!") guard let reasonNumber = notification.userInfo?[AVCaptureSessionInterruptionReasonKey] as? NSNumber else { return } let reason = AVCaptureSession.InterruptionReason(rawValue: reasonNumber.intValue) switch reason { case .audioDeviceInUseByAnotherClient: removeAudioInput() default: break } } func addAudioInput() throws { if audioDeviceInput != nil { return } removeAudioInput() print("Adding audio input...") captureSession?.beginConfiguration() guard let audioDevice = AVCaptureDevice.default(for: .audio) else { throw NSError() } audioDeviceInput = try AVCaptureDeviceInput(device: audioDevice) guard captureSession!.canAddInput(audioDeviceInput!) else { throw NSError() } captureSession?.addInput(audioDeviceInput!) captureSession?.automaticallyConfiguresApplicationAudioSession = false captureSession?.commitConfiguration() } func removeAudioInput() { //when the code reaches this point audioDeviceInput is reinitialized so the audio session is not removed from the recording //captureSession is not filled with the data about the video recorded guard let audioInput = audioDeviceInput else { return } captureSession?.beginConfiguration() captureSession?.removeInput(audioInput) audioDeviceInput = nil captureSession?.commitConfiguration() } @objc func sessionInterruptionEnd(notification: Notification) { print("Capture Session Interruption end Notification!") guard let reasonNumber = notification.userInfo?[AVCaptureSessionInterruptionReasonKey] as? NSNumber else { return } let reason = AVCaptureSession.InterruptionReason(rawValue: reasonNumber.intValue) switch reason { case .audioDeviceInUseByAnotherClient: // add audio again because we removed it when we received the interruption. configureAudioSession() default: // don't do anything, iOS will automatically resume session break } } @objc func audioSessionInterrupted(notification: Notification) { print("Audio Session Interruption Notification!") guard let userInfo = notification.userInfo, let typeValue = userInfo[AVAudioSessionInterruptionTypeKey] as? UInt, let type = AVAudioSession.InterruptionType(rawValue: typeValue) else { return } switch type { case .began: print("The Audio Session was interrupted!") removeAudioInput() case .ended: print("The Audio Session interruption has ended.") guard let optionsValue = userInfo[AVAudioSessionInterruptionOptionKey] as? UInt else { return } let options = AVAudioSession.InterruptionOptions(rawValue: optionsValue) if options.contains(.shouldResume) { print("Resuming interrupted Audio Session...") // restart audio session because interruption is over configureAudioSession() } else { print("Cannot resume interrupted Audio Session!") } @unknown default: () } } func configureAudioSession() { let start = DispatchTime.now() do { try self.addAudioInput() let audioSession = AVAudioSession.sharedInstance() if audioSession.category != .playAndRecord { // allow background music playback try audioSession.setCategory(AVAudioSession.Category.playAndRecord, options: [.mixWithOthers, .allowBluetoothA2DP, .defaultToSpeaker]) } // activate current audio session because camera is active try audioSession.setActive(true) } catch let error as NSError { switch error.code { case 561_017_449: print(error.description) default: print(error.description) } self.removeAudioInput() } let end = DispatchTime.now() let nanoTime = end.uptimeNanoseconds - start.uptimeNanoseconds print("Configured Audio session in \(Double(nanoTime) / 1_000_000)ms!") } }
0
0
2.0k
Jan ’23
Noticeable delay before keyboard appears
Ever since using Xcode 14 SDK to compile, the iOS keyboard takes a long, variable, time to appear when focusing a UITextField or UITextView. I can confirm that using the previous SDK, the notification keyboardWillShow fires instantly, while in the current 14 SDK it takes a considerable amount of time, and not just the first time the keyboard opens. It always dismisses instantly. Is there any way to make the keyboard appear more quickly? Sometimes UI needs to move in sync with the keyboard and we need to know the keyboard height ASAP so it doesn't feel delayed. Even without needing the notification sooner, my app feels more delayed in general since selecting a text view takes longer for the keyboard to appear. Is there any way to debug why, or speed this up? It seems in the Notes app the keyboard appears instantly.
1
0
1.9k
Jan ’23
Device token has returned without Permissions.
I'm facing an issue about Push Notification with Notification Service Extension (NSE). Steps: Allow Push Permissions and a valid device_token has been returned. The Push Notification come successfully and has handled by NSE. The NSE take some seconds for complete. When a Push is coming and the NSE is processing (not call contentHandler yet). Quickly delete the app. Then, we reinstall the app. Now, we can see: A content of push was called to didReceiveRemoteNotification of AppDelegate of main app (Not NSE). A valid device token has been returned to didRegisterForRemoteNotificationsWithDeviceToken without calling registerForRemoteNotifications and any Permissions. We can use this device_token to push. I can see it on: iOS 16.3 (Beta), iOS 16.1.1 (Final)... I can check the Permissions of the Push Notification before use the device_token. But It doesn't make sense. Do we have some best solutions for this? Thanks.
0
0
1.2k
Jan ’23
NotificationCenter.default not trigger UserDefaults.didChangeNotification at extension widget?
expect: app update UserDefaults use group value. widget use NotificationCenter.default observe same group UserDefaults, then reloadTimeline actual: successfully set no reload happen, and I try set same key to another value inside the selector function to test whether it's been called. provided the selector not work. steps: click a app button to set a key of UserDefaults back home , widget no change - expect it update view based one new value rebuild widget , can see the ui use new value - prove set call successfully but notification of UserDefaults.didChangeNotification not send host app : UserDefaults(suiteName: "group.a") store?.setValue("a", forKey: "target") widget: class NotiWatch {    init(){         NotificationCenter.default.addObserver(self, selector: #selector(onchange), name: UserDefaults.didChangeNotification, object: nil)     }     @objc func onchange(notification: NSNotification) {         UserDefaults(suiteName: "group.a")?.set("cccc", forKey: "target") WidgetCenter.shared.reloadAllTimelines()     }     deinit{         NotificationCenter.default.removeObserver(self, name: UserDefaults.didChangeNotification, object: nil)     } } struct Provider: TimelineProvider {     let def:UserDefaults? ;     let watcher = NotiWatch()     init(){         let fmt = DateFormatter()         fmt.dateFormat = "yyyy-MM-dd HH:mm"         dd = fmt.date(from: "2070-12-20 23:59")!         def = UserDefaults(suiteName: "group.a") ;     }     var dd =  Date()     func placeholder(in context: Context) -> SimpleEntry {         SimpleEntry(date: Date(), unit: "Y",left: 0,tar: "")     }     func getSnapshot(  in context: Context, completion: @escaping (SimpleEntry) -> ()) {         let date = Date()         let left = dd.timeIntervalSince(date).minutes         let entry = SimpleEntry(date: date, unit: "M",left: left,tar: "")                   completion(entry)     }     func getTimeline( in context: Context, completion: @escaping (Timeline<Entry>) -> ()) {         var entries: [SimpleEntry] = []         // Generate a timeline consisting of five entries an hour apart, starting from the current date.         let tar = def?.string(forKey: "target") ?? ""         let currentDate = Date()         for offset in 0 ..< 60 {             let entryDate = Calendar.current.date(byAdding: .minute, value: offset, to: currentDate)!                          let left = dd.timeIntervalSince(entryDate).minutes             let entry = SimpleEntry(date: currentDate, unit: "minutes",left:left,tar: tar)             entries.append(entry)         }         let timeline = Timeline(entries: entries, policy: .atEnd)         completion(timeline)     } }
2
0
1.2k
Dec ’22
Triggering a local notification based on connectivity while the app is not active
I'm working on an business tool app that supports offline work in areas without network access. while the offline activity is logged and saved locally, I need users to log in online in order for the app to report the offline activity audit back to the backend as soon as possible (once the phone has network access again) so the data is available to their managers. I am trying to find a way to trigger a local notification to remind the user of this required action once the phone regains connectivity, even if the app is in the background or not in memory at all. looking at the 4 available types of UNNotificationTrigger - the recommended way to trigger pending local notification, none of them supports the required functionality. using background capabilities also doesn't seem to be the correct way to approach this. In looking for similar questions online, couldn't find one addressing a similar scenario. Any ideas on how this can be achieved?
1
0
934
Dec ’22
Delivere push notification can't be removed every time from the lock screen
Our application uses UserNotificationCenter to deliver notifications of missed calls to the lock screen. Some times we need to remove this notification. I've tried to use removeDeliveredNotificationsWithIdentifiers APIs to remove the exact notification, but approximately in 10% tests it doesn't work. The issue happens when the app is in background, the user receives a APNS call, but answers on it from other endpoint, so for the app this call is missed. But after call history update it should be marked as answered and a missed call notification should be removed. From console logs I've found that for a good case system logs an attempt to remove a notification: default 14:31:03.376780+0100 [com.myapp] Removing 1 delivered notifications with identifiers ( "7C1E-73F2" ) SpringBoard default 14:31:03.377662+0100 [com.myapp] Removing delivered notifications SpringBoard default 14:31:03.388840+0100 Saving file at /var/mobile/Library/UserNotifications/6E65DC61-BF32-468B-B1A3-CD5B10F811BA/DeliveredNotifications.plist with 0 items SpringBoard default 14:31:03.399219+0100 kExcludedFromBackupXattrName set on path: SpringBoard error 14:31:03.400708+0100 No data found at /var/mobile/Library/UserNotifications/6E65DC61-BF32-468B-B1A3-CD5B10F811BA/PendingNotifications.plist SpringBoard default 14:31:03.400930+0100 [com.myapp] Load 0 pending notification dictionaries SpringBoard default 14:31:03.401433+0100 [com.myapp] Withdrawing notification 7C1E-73F2 SpringBoard default 14:31:03.402173+0100 BBDataProvider: Withdraw bulletin in section com.myapp publisher bulletin ID MissedCallCategory66071282 SpringBoard default 14:31:03.402455+0100 BBServer: Withdraw bulletin: 366E6C8B-DA60-4054-8CD2-238C3B95F7B3 SpringBoard default 14:31:03.402590+0100 Server has been asked to remove bulletin: 366E6C8B-DA60-4054-8CD2-238C3B95F7B3 SpringBoard default 14:31:03.403140+0100 Sending remove bulletin with transactionID 2, bulletin 366E6C8B-DA60-4054-8CD2-238C3B95F7B3 SpringBoard default 14:31:03.410509+0100 Sending remove bulletin with transactionID 2, bulletin 366E6C8B-DA60-4054-8CD2-238C3B95F7B3 SpringBoard default 14:31:03.411015+0100 Can't send remove bulletin. No transactionID for bulletin 366E6C8B-DA60-4054-8CD2-238C3B95F7B3 SpringBoard default 14:31:03.411335+0100 Sending remove bulletin with transactionID 2, bulletin 366E6C8B-DA60-4054-8CD2-238C3B95F7B3 SpringBoard default 14:31:03.412400+0100 really enqueueing bulletin \ In a bad case there's no logs, system just did nothing. I've tried to use removeAllDeliveredNotifications it works, but it could remove other notification, which should be present, this not a case here. There're some suggestions to use delays in code to adjust system's behavior, but it didn't help, still not fully stable. https://stackoverflow.com/questions/53697279/why-are-notifications-not-removed-with-removedeliverednotifications Is there anything what could be done from the app side to void this issue?
0
0
1.2k
Dec ’22
iPad iOS 16.1.2 No Content
So both me and the girlfriend are running the same iPad’s and iOS. We can’t make a photo widget, here is the steps I tried to fix it: Click on Settings -> (tap on your User ID). Click on iCloud -> Photos -> turn off Sync this iPad. Click on General -> Shut Down (turn off iPad). Turn on iPad, Click on Settings -> (tap on User ID). Click on iCloud -> Photos turn Sync this iPad back on (you will see: in Cloud [ Updating ] Status [ syncing items ]. Click on main screen until you see + in the upper right corner. Click on photos (you should see photos)
0
0
1.2k
Dec ’22
Mail push notifications
For several times I asked Apple engineers to fix the problem with push notifications from iCloud email in native mail app. They partly did it - but when I’m offline for hour or more, I don’t receive them. At the same time if there’s a new mail which was sent less than hour during this period it will push more old notification. I’ve checked it in the following versions: iOS 16.1.2; iPadOS 16.1.2. Seems that the problem is close to being solved, but not for 100% yet. Who’s the same problem?
1
0
903
Dec ’22
How observe Userdefault changes for com.apple.configuration.managed
I have an app which uses MDM settings pushed from Miradore. I can read out the settings using: NSDictionary *serverConfig = [[NSUserDefaults standardUserDefaults] dictionaryForKey:"com.apple.configuration.managed"]; I want to add an observer to only trigger a function when "com.apple.configuration.managed" is changed and no other NSUserDefaults value. Currently the observer is triggered for all NSUserDefaults changes. The code for this that I have is: [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(readDefaultsValues:) name:NSUserDefaultsDidChangeNotification object:nil]; Does anyone know how to only observe changes to "com.apple.configuration.managed"?
0
0
1.7k
Dec ’22
Silencing some push notifications locally from the app
My use case : i want the app to completely silence a given received alert push notification, based on information the app has locally (completely remove it, and never even display it. Not just change the sound or badge). So far i found no way of doing that : notification service extension doesn't let you remove the notification entirely, just change its content. Using "background / content" notification type then creating the notification locally doesn't work, since "background" notification type is unreliable by design. voip notifications are banned from being used as a general-purpose background notification mechanism since iOS13 Help would be greatly appreciated.
4
0
4.9k
Nov ’22
How to maintain the badge count in push notification?
Hello team, We have implemented push notification in our app. We are not supporting the in app badge count but we are showing the app icon badge count.  We are trying to increase the badge count for the received notifications count parallely it should decrease while opening the app by clicking on the notification or it should decrease while clearing the notification.  Also we are trying to achieve the overall badge count to reset to zero while clearing the notification from the notification center… Please let us know the possible way to achieve this. Thanks In Advance!!
0
0
1.4k
Nov ’22
PDFViewVisiblePagesChanged iOS 16
Hi, we have an application that observes PDFViewVisiblePagesChanged and PDFViewPageChanged notifications for detecting the scroll state of a PDFView NotificationCenter.default.addObserver(self,                                                 selector: #selector(handleOnScroll),                                                name: Notification.Name.PDFViewVisiblePagesChanged,                                                 object: nil) NotificationCenter.default.addObserver(self,                                                 selector: #selector(handleOnScroll),                                                name: Notification.Name.PDFViewPageChanged,                                                 object: nil) With iOS14 this worked like a charm, the notification gets triggered immediately when the user starts scrolling the pdf. In iOS16 we have issues, it seems that the notifications get triggered/send only after the scrolling has been completed/stopped. Can anybody confirm this? Has anybody a solution how we can detect a scrolling PDFView using a different method? Background: While the PDF is scrolling other elements of the UI need to be disabled. Thanks Jürgen
Replies
0
Boosts
0
Views
1.1k
Activity
Feb ’23
Could Widget receive remote notifications
I try to receive remote notifications in widgets(implemented through WidgetKit), but failed. It known that enable remote notifications should register first by calling UIApplication.shared.registerForRemoteNotifications() but in widget cannot calling shared, it is available in widgets @property(class, nonatomic, readonly) UIApplication *sharedApplication NS_EXTENSION_UNAVAILABLE_IOS("Use view controller based solutions where appropriate instead."); and if try to init a UIApplication(by UIApplication()), the app will crash for more than one UIApplication instance.
Replies
1
Boosts
0
Views
2.0k
Activity
Feb ’23
Can UserNotifications be used in a command line program?
I have a cli program which does a thing for a while, and I'd like it to post a notification on the screen when it's done. Note that because it's a standalone program, not an app, it doesn't have a bundle, per se. I tried to use UserNotifications, but I get an immediate error with the line let center = UNUserNotificationCenter.current() With the error: Terminating app due to uncaught exception 'NSInternalInconsistencyException', reason: 'bundleProxyForCurrentProcess is nil: mainBundle.bundleURL My entire program to produce this bug: import Foundation import UserNotifications let center = UNUserNotificationCenter.current() print("Hello, World!")
Replies
1
Boosts
1
Views
999
Activity
Feb ’23
Widget in iOS app not shown as Mac Catalyst app
I wish to support Mac with my iPhone/iPad app using Mac Catalyst. Our app shows widgets on iPhone/iPad home screen properly. Using Mac Catalyst is straight forward (except to exclude all ActivityKit codes). However, although the app shows up and work perfectly, I can't see the widgets in notification center. Separate compile the widget extensions show no errors but nothing is shown. Also tried build separately, drag into Applications folder, run the build and the widgets are not shown. Any suggestions? Using the Xcode 14.2 and macOS 13.1.
Replies
2
Boosts
0
Views
1.8k
Activity
Feb ’23
iOS 16 Popup request notification permission can be display multi times?
I'm having a problem in iOS. When popup request notification permission display then I dismiss pop up by button home or navigation bar (Not click to Allow or Don't Allow) => Not display setting Notification in app setting (Status not determined) => request notifications permission again => Popup displayed again. I can not find any doc about this behavior. Is this a change in iOS 16? Has anyone had this problem? Thank you for your interest.
Replies
0
Boosts
0
Views
924
Activity
Feb ’23
How to handle audio session interruptions while recording video
While recording a video, if an interruption occurs such as an incoming call or an alarm sound, the camera frezees and the video is not saved. I would like to handle this situation interrupting the video and saving it or removing the audio while it keeps recording. But after the interruption starts and the event is recognized, the variables regarding the video already recorded are reinitialized, causing the app not to save anything. This is part of the CameraManager class: var captureSession: AVCaptureSession? public func fileOutput(_: AVCaptureFileOutput, didStartRecordingTo _: URL, from _: [AVCaptureConnection]) { NotificationCenter.default.addObserver(self, selector: #selector(sessionInterruptionBegin), name: .AVCaptureSessionWasInterrupted, object: captureSession) NotificationCenter.default.addObserver(self, selector: #selector(sessionInterruptionEnd),name: .AVCaptureSessionInterruptionEnded, object: captureSession) NotificationCenter.default.addObserver(self, selector: #selector(audioSessionInterrupted), name: AVAudioSession.interruptionNotification, object: AVAudioSession.sharedInstance) print("STO PASSANDO DA AVCaptureFileOutputRecordingDelegate") captureSession?.beginConfiguration() if flashMode != .off { _updateIlluminationMode(flashMode) } captureSession?.commitConfiguration() //at this point captureSession starts collecting data about the video } extension CameraManager { @objc func sessionInterruptionBegin(notification: Notification) { print("Capture Session Interruption begin Notification!") guard let reasonNumber = notification.userInfo?[AVCaptureSessionInterruptionReasonKey] as? NSNumber else { return } let reason = AVCaptureSession.InterruptionReason(rawValue: reasonNumber.intValue) switch reason { case .audioDeviceInUseByAnotherClient: removeAudioInput() default: break } } func addAudioInput() throws { if audioDeviceInput != nil { return } removeAudioInput() print("Adding audio input...") captureSession?.beginConfiguration() guard let audioDevice = AVCaptureDevice.default(for: .audio) else { throw NSError() } audioDeviceInput = try AVCaptureDeviceInput(device: audioDevice) guard captureSession!.canAddInput(audioDeviceInput!) else { throw NSError() } captureSession?.addInput(audioDeviceInput!) captureSession?.automaticallyConfiguresApplicationAudioSession = false captureSession?.commitConfiguration() } func removeAudioInput() { //when the code reaches this point audioDeviceInput is reinitialized so the audio session is not removed from the recording //captureSession is not filled with the data about the video recorded guard let audioInput = audioDeviceInput else { return } captureSession?.beginConfiguration() captureSession?.removeInput(audioInput) audioDeviceInput = nil captureSession?.commitConfiguration() } @objc func sessionInterruptionEnd(notification: Notification) { print("Capture Session Interruption end Notification!") guard let reasonNumber = notification.userInfo?[AVCaptureSessionInterruptionReasonKey] as? NSNumber else { return } let reason = AVCaptureSession.InterruptionReason(rawValue: reasonNumber.intValue) switch reason { case .audioDeviceInUseByAnotherClient: // add audio again because we removed it when we received the interruption. configureAudioSession() default: // don't do anything, iOS will automatically resume session break } } @objc func audioSessionInterrupted(notification: Notification) { print("Audio Session Interruption Notification!") guard let userInfo = notification.userInfo, let typeValue = userInfo[AVAudioSessionInterruptionTypeKey] as? UInt, let type = AVAudioSession.InterruptionType(rawValue: typeValue) else { return } switch type { case .began: print("The Audio Session was interrupted!") removeAudioInput() case .ended: print("The Audio Session interruption has ended.") guard let optionsValue = userInfo[AVAudioSessionInterruptionOptionKey] as? UInt else { return } let options = AVAudioSession.InterruptionOptions(rawValue: optionsValue) if options.contains(.shouldResume) { print("Resuming interrupted Audio Session...") // restart audio session because interruption is over configureAudioSession() } else { print("Cannot resume interrupted Audio Session!") } @unknown default: () } } func configureAudioSession() { let start = DispatchTime.now() do { try self.addAudioInput() let audioSession = AVAudioSession.sharedInstance() if audioSession.category != .playAndRecord { // allow background music playback try audioSession.setCategory(AVAudioSession.Category.playAndRecord, options: [.mixWithOthers, .allowBluetoothA2DP, .defaultToSpeaker]) } // activate current audio session because camera is active try audioSession.setActive(true) } catch let error as NSError { switch error.code { case 561_017_449: print(error.description) default: print(error.description) } self.removeAudioInput() } let end = DispatchTime.now() let nanoTime = end.uptimeNanoseconds - start.uptimeNanoseconds print("Configured Audio session in \(Double(nanoTime) / 1_000_000)ms!") } }
Replies
0
Boosts
0
Views
2.0k
Activity
Jan ’23
Asking Permission to Use Notifications Message
Hello ; I have to translate this message but there is not any key in infoplist also targets info. it doesnt change when I add a key in the Info.plist or Infoplist.string. How can I translate it ?
Replies
1
Boosts
0
Views
832
Activity
Jan ’23
[macos ,swiftui ] How to observe the new notification event?
I want to make a Dock application for my self . So I need to get the running application's badge count , then can show it on the Dock , let user know there has new notifications . but now , I want to ask ,how swift can observe the new notification event ? I am new at this .
Replies
0
Boosts
0
Views
1.4k
Activity
Jan ’23
One signal integration
Build input file cannot be found: '/../.../.../../../Build/Products/Debug-iphonesimulator/OneSignalNotificationServiceExtension.appex/OneSignalNotificationServiceExtension'. Did you forget to declare this file as an output of a script phase or custom build rule which produces it? Please anyone help me solve this issue
Replies
0
Boosts
1
Views
798
Activity
Jan ’23
Noticeable delay before keyboard appears
Ever since using Xcode 14 SDK to compile, the iOS keyboard takes a long, variable, time to appear when focusing a UITextField or UITextView. I can confirm that using the previous SDK, the notification keyboardWillShow fires instantly, while in the current 14 SDK it takes a considerable amount of time, and not just the first time the keyboard opens. It always dismisses instantly. Is there any way to make the keyboard appear more quickly? Sometimes UI needs to move in sync with the keyboard and we need to know the keyboard height ASAP so it doesn't feel delayed. Even without needing the notification sooner, my app feels more delayed in general since selecting a text view takes longer for the keyboard to appear. Is there any way to debug why, or speed this up? It seems in the Notes app the keyboard appears instantly.
Replies
1
Boosts
0
Views
1.9k
Activity
Jan ’23
Device token has returned without Permissions.
I'm facing an issue about Push Notification with Notification Service Extension (NSE). Steps: Allow Push Permissions and a valid device_token has been returned. The Push Notification come successfully and has handled by NSE. The NSE take some seconds for complete. When a Push is coming and the NSE is processing (not call contentHandler yet). Quickly delete the app. Then, we reinstall the app. Now, we can see: A content of push was called to didReceiveRemoteNotification of AppDelegate of main app (Not NSE). A valid device token has been returned to didRegisterForRemoteNotificationsWithDeviceToken without calling registerForRemoteNotifications and any Permissions. We can use this device_token to push. I can see it on: iOS 16.3 (Beta), iOS 16.1.1 (Final)... I can check the Permissions of the Push Notification before use the device_token. But It doesn't make sense. Do we have some best solutions for this? Thanks.
Replies
0
Boosts
0
Views
1.2k
Activity
Jan ’23
NotificationCenter.default not trigger UserDefaults.didChangeNotification at extension widget?
expect: app update UserDefaults use group value. widget use NotificationCenter.default observe same group UserDefaults, then reloadTimeline actual: successfully set no reload happen, and I try set same key to another value inside the selector function to test whether it's been called. provided the selector not work. steps: click a app button to set a key of UserDefaults back home , widget no change - expect it update view based one new value rebuild widget , can see the ui use new value - prove set call successfully but notification of UserDefaults.didChangeNotification not send host app : UserDefaults(suiteName: "group.a") store?.setValue("a", forKey: "target") widget: class NotiWatch {    init(){         NotificationCenter.default.addObserver(self, selector: #selector(onchange), name: UserDefaults.didChangeNotification, object: nil)     }     @objc func onchange(notification: NSNotification) {         UserDefaults(suiteName: "group.a")?.set("cccc", forKey: "target") WidgetCenter.shared.reloadAllTimelines()     }     deinit{         NotificationCenter.default.removeObserver(self, name: UserDefaults.didChangeNotification, object: nil)     } } struct Provider: TimelineProvider {     let def:UserDefaults? ;     let watcher = NotiWatch()     init(){         let fmt = DateFormatter()         fmt.dateFormat = "yyyy-MM-dd HH:mm"         dd = fmt.date(from: "2070-12-20 23:59")!         def = UserDefaults(suiteName: "group.a") ;     }     var dd =  Date()     func placeholder(in context: Context) -> SimpleEntry {         SimpleEntry(date: Date(), unit: "Y",left: 0,tar: "")     }     func getSnapshot(  in context: Context, completion: @escaping (SimpleEntry) -> ()) {         let date = Date()         let left = dd.timeIntervalSince(date).minutes         let entry = SimpleEntry(date: date, unit: "M",left: left,tar: "")                   completion(entry)     }     func getTimeline( in context: Context, completion: @escaping (Timeline<Entry>) -> ()) {         var entries: [SimpleEntry] = []         // Generate a timeline consisting of five entries an hour apart, starting from the current date.         let tar = def?.string(forKey: "target") ?? ""         let currentDate = Date()         for offset in 0 ..< 60 {             let entryDate = Calendar.current.date(byAdding: .minute, value: offset, to: currentDate)!                          let left = dd.timeIntervalSince(entryDate).minutes             let entry = SimpleEntry(date: currentDate, unit: "minutes",left:left,tar: tar)             entries.append(entry)         }         let timeline = Timeline(entries: entries, policy: .atEnd)         completion(timeline)     } }
Replies
2
Boosts
0
Views
1.2k
Activity
Dec ’22
Triggering a local notification based on connectivity while the app is not active
I'm working on an business tool app that supports offline work in areas without network access. while the offline activity is logged and saved locally, I need users to log in online in order for the app to report the offline activity audit back to the backend as soon as possible (once the phone has network access again) so the data is available to their managers. I am trying to find a way to trigger a local notification to remind the user of this required action once the phone regains connectivity, even if the app is in the background or not in memory at all. looking at the 4 available types of UNNotificationTrigger - the recommended way to trigger pending local notification, none of them supports the required functionality. using background capabilities also doesn't seem to be the correct way to approach this. In looking for similar questions online, couldn't find one addressing a similar scenario. Any ideas on how this can be achieved?
Replies
1
Boosts
0
Views
934
Activity
Dec ’22
Delivere push notification can't be removed every time from the lock screen
Our application uses UserNotificationCenter to deliver notifications of missed calls to the lock screen. Some times we need to remove this notification. I've tried to use removeDeliveredNotificationsWithIdentifiers APIs to remove the exact notification, but approximately in 10% tests it doesn't work. The issue happens when the app is in background, the user receives a APNS call, but answers on it from other endpoint, so for the app this call is missed. But after call history update it should be marked as answered and a missed call notification should be removed. From console logs I've found that for a good case system logs an attempt to remove a notification: default 14:31:03.376780+0100 [com.myapp] Removing 1 delivered notifications with identifiers ( "7C1E-73F2" ) SpringBoard default 14:31:03.377662+0100 [com.myapp] Removing delivered notifications SpringBoard default 14:31:03.388840+0100 Saving file at /var/mobile/Library/UserNotifications/6E65DC61-BF32-468B-B1A3-CD5B10F811BA/DeliveredNotifications.plist with 0 items SpringBoard default 14:31:03.399219+0100 kExcludedFromBackupXattrName set on path: SpringBoard error 14:31:03.400708+0100 No data found at /var/mobile/Library/UserNotifications/6E65DC61-BF32-468B-B1A3-CD5B10F811BA/PendingNotifications.plist SpringBoard default 14:31:03.400930+0100 [com.myapp] Load 0 pending notification dictionaries SpringBoard default 14:31:03.401433+0100 [com.myapp] Withdrawing notification 7C1E-73F2 SpringBoard default 14:31:03.402173+0100 BBDataProvider: Withdraw bulletin in section com.myapp publisher bulletin ID MissedCallCategory66071282 SpringBoard default 14:31:03.402455+0100 BBServer: Withdraw bulletin: 366E6C8B-DA60-4054-8CD2-238C3B95F7B3 SpringBoard default 14:31:03.402590+0100 Server has been asked to remove bulletin: 366E6C8B-DA60-4054-8CD2-238C3B95F7B3 SpringBoard default 14:31:03.403140+0100 Sending remove bulletin with transactionID 2, bulletin 366E6C8B-DA60-4054-8CD2-238C3B95F7B3 SpringBoard default 14:31:03.410509+0100 Sending remove bulletin with transactionID 2, bulletin 366E6C8B-DA60-4054-8CD2-238C3B95F7B3 SpringBoard default 14:31:03.411015+0100 Can't send remove bulletin. No transactionID for bulletin 366E6C8B-DA60-4054-8CD2-238C3B95F7B3 SpringBoard default 14:31:03.411335+0100 Sending remove bulletin with transactionID 2, bulletin 366E6C8B-DA60-4054-8CD2-238C3B95F7B3 SpringBoard default 14:31:03.412400+0100 really enqueueing bulletin \ In a bad case there's no logs, system just did nothing. I've tried to use removeAllDeliveredNotifications it works, but it could remove other notification, which should be present, this not a case here. There're some suggestions to use delays in code to adjust system's behavior, but it didn't help, still not fully stable. https://stackoverflow.com/questions/53697279/why-are-notifications-not-removed-with-removedeliverednotifications Is there anything what could be done from the app side to void this issue?
Replies
0
Boosts
0
Views
1.2k
Activity
Dec ’22
iPad iOS 16.1.2 No Content
So both me and the girlfriend are running the same iPad’s and iOS. We can’t make a photo widget, here is the steps I tried to fix it: Click on Settings -> (tap on your User ID). Click on iCloud -> Photos -> turn off Sync this iPad. Click on General -> Shut Down (turn off iPad). Turn on iPad, Click on Settings -> (tap on User ID). Click on iCloud -> Photos turn Sync this iPad back on (you will see: in Cloud [ Updating ] Status [ syncing items ]. Click on main screen until you see + in the upper right corner. Click on photos (you should see photos)
Replies
0
Boosts
0
Views
1.2k
Activity
Dec ’22
Mail push notifications
For several times I asked Apple engineers to fix the problem with push notifications from iCloud email in native mail app. They partly did it - but when I’m offline for hour or more, I don’t receive them. At the same time if there’s a new mail which was sent less than hour during this period it will push more old notification. I’ve checked it in the following versions: iOS 16.1.2; iPadOS 16.1.2. Seems that the problem is close to being solved, but not for 100% yet. Who’s the same problem?
Replies
1
Boosts
0
Views
903
Activity
Dec ’22
How observe Userdefault changes for com.apple.configuration.managed
I have an app which uses MDM settings pushed from Miradore. I can read out the settings using: NSDictionary *serverConfig = [[NSUserDefaults standardUserDefaults] dictionaryForKey:"com.apple.configuration.managed"]; I want to add an observer to only trigger a function when "com.apple.configuration.managed" is changed and no other NSUserDefaults value. Currently the observer is triggered for all NSUserDefaults changes. The code for this that I have is: [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(readDefaultsValues:) name:NSUserDefaultsDidChangeNotification object:nil]; Does anyone know how to only observe changes to "com.apple.configuration.managed"?
Replies
0
Boosts
0
Views
1.7k
Activity
Dec ’22
Web push notification
A website created for Android that incorporates a push notification function does not work even when accessed with Safari on OS Ventura 13.0.1. I don't know what the problem is and what is needed, so please let me know if you have any examples or samples.
Replies
0
Boosts
0
Views
646
Activity
Dec ’22
Silencing some push notifications locally from the app
My use case : i want the app to completely silence a given received alert push notification, based on information the app has locally (completely remove it, and never even display it. Not just change the sound or badge). So far i found no way of doing that : notification service extension doesn't let you remove the notification entirely, just change its content. Using "background / content" notification type then creating the notification locally doesn't work, since "background" notification type is unreliable by design. voip notifications are banned from being used as a general-purpose background notification mechanism since iOS13 Help would be greatly appreciated.
Replies
4
Boosts
0
Views
4.9k
Activity
Nov ’22
How to maintain the badge count in push notification?
Hello team, We have implemented push notification in our app. We are not supporting the in app badge count but we are showing the app icon badge count.  We are trying to increase the badge count for the received notifications count parallely it should decrease while opening the app by clicking on the notification or it should decrease while clearing the notification.  Also we are trying to achieve the overall badge count to reset to zero while clearing the notification from the notification center… Please let us know the possible way to achieve this. Thanks In Advance!!
Replies
0
Boosts
0
Views
1.4k
Activity
Nov ’22