User Notifications

RSS for tag

Push user-facing notifications to the user's device from a server or generate them locally from your app using User Notifications.

Posts under User Notifications tag

158 Posts
Sort by:

Post

Replies

Boosts

Views

Activity

Experiencing Duplicate Notifications Issue Recently By Multiple Users
We recently noticed that our app is receiving duplicate notifications, and this is impacting multiple users, and we verified from our server that we are sending the notifications only once This is a sample payload of the notifications we are sending { "aps": { "alert": { "title": "title", "body": "body" }, "category": "test", "mutable-content": 1 }, "navigateTo": "test", "imageUrl": "test" } Also a user with IOS 17.5.1 reported this issue also
2
0
96
3d
Issue with Locale Updates on Network Extension in iOS
I have implemented a NEPacketTunnelProvider in my app, which sends local notifications to the user when the server is down. While the notifications are displayed successfully, I encountered an issue when changing the system locale settings on iOS. Specifically, the notifications still display in the previous locale, even after the system locale has been changed. The locale of the notifications only updates if I restart the device. I am currently using Locale.current for setting the locale in my notifications. I have also tried using Locale.preferredLanguages, but it seems that the locale does not properly update in real-time.
4
0
86
1d
URLSession download task fails with NSPOSIXErrorDomain error Code=1
I have a Push Notification Service Extension, which is processing notification payload to attach image, if imageUrl is key is present. I use this simple code to perform the download: let downloadTask = URLSession.shared.downloadTask(with: urlRequest) { [weak self] tempURL, response, error in /// parse results... } Notification payload contains "mutable-content" : 1 inside aps. It's entirely randomly will it work or not. When it doesn't work, I get this error: Error Domain=NSPOSIXErrorDomain Code=1 "Operation not permitted" UserInfo={NSErrorFailingURLStringKey=https://w7.pngwing.com/pngs/1005/607/png-transparent-african-elephant-animal-elephant-thumbnail.png, NSErrorFailingURLKey=https://w7.pngwing.com/pngs/1005/607/png-transparent-african-elephant-animal-elephant-thumbnail.png, _NSURLErrorRelatedURLSessionTaskErrorKey=( "LocalDownloadTask <4A847242-2314-4125-99E4-A424CF4B4B7C>.<7>" ), _NSURLErrorFailingURLSessionTaskErrorKey=LocalDownloadTask <4A847242-2314-4125-99E4-A424CF4B4B7C>.<7>} I have no idea what Apple's internal code throws this error, what could possibly go wrong here. This is happening for a while now, I just re-tested on iOS 17.5.1 on 14 Pro. App is compiled using Xcode 15.4 and Swift 5.10, latest SDK. Not sure is it relevant but main iOS app has DataProtection capability set to Complete.
9
0
114
13h
Scheduling Local Notifications with repeat interval
I am building an application where I need to implement a use case where a local notification is set for a specific date / time (e.g 05/6/24 8 PM) to display to the user (e.g. "Take your Meds") and I want him to continue to get that alert every X minutes (e.g. every 2 minutes) until I cancel it (e.g. when the user indicates he has taken his medicene). NOTE: I do NOT want to rely on push notifications from the server for doing the reminders because it needs to work when the device is off the network (like on a plane or a cruise ship in the middle of the ocean or whatever). This would seem to be a pretty common use case, but looking at the previous and existing local notification frameworks, I only see the option to create a calendar based trigger with a boolean repeat (UNCalendarNotificationTrigger) or a time interval based trigger with a boolean repeat (UnTimeIntervalNotificationTrigger), but nothing that combines these in a way that allows me to implement the above stated use case.
1
0
161
3w
Push Notifications
Hi, I am trying to add in a push notification but the send push notifications function does not seem to be working. Can someone help? func sendNotification() { print("Bluetooth device disconnected. Sending notification.") let content = UNMutableNotificationContent() content.title = "Car Disconnected" content.body = "Please key in where you have left your car" content.sound = UNNotificationSound.default // Create a trigger to send the notification immediately let request = UNNotificationRequest(identifier: "BluetoothDisconnected", content: content, trigger: nil) UNUserNotificationCenter.current().add(request) { error in if let error = error { print("Error adding notification request: \(error.localizedDescription)") } else { print("Notification request added successfully.") } } }
1
0
184
3w
Provisional Notifications missing buttons
We are attempting to enable provisional notifications in our app, but some internal users on iOS 17 are reporting that they are not receiving the "Keep" and "Turn off" buttons that provisional notifications are supposed to have - in other words they just come in as regular quiet notifications. I have confirmed that these users are doing a fresh install of our app, and at no point are they ever receiving a permission prompt to turn on notifications. Their UNAuthorizationStatus is correctly being set to provisional. Their notification settings are being set to the following, which seems correct: I have not been able to reproduce this issue on any of my own devices, but these users can do so consistently. What could possibly cause this? Some misconfiguration on our end, our some hidden iOS setting somewhere?
1
0
184
3w
ios push notification not received after getting out of airplane mode
I'm sending a push notification using Noticed Gem during the night when my phone is in airplane mode. When I wake up and disable the airplane mode, I don't get the push notification. These are the settings: ` def ios_format(apn) apn.custom_payload = { universal_link: url } apn.alert = { title: title(recipient), body: message(recipient) } apn.sound = 'default' apn.priority = '10' # Send immediately, bypassing the end ` default expiration is supposed to be 30 days. How can I debug/fix the problem? (with noticed gem) I checked Apple consoleKIT, and I don't see discarded notifications. Thanks
3
0
334
2w
Notification not sending
Hello There!, I'm currently working on an App with an implemented timer. It was initially planned, that the User will get a notification when the timer ends. Everything works fine until the timer ends and the phone doesn't gets any notification... This is my code: import SwiftUI import Combine import UserNotifications struct TimerView: View { @State private var timeRemaining: TimeInterval @State private var timerActive = false @Binding var studyTime: Int @Binding var selectedExam: Exam init(studyTime: Binding<Int>, selectedExam: Binding<Exam>) { _studyTime = studyTime _selectedExam = selectedExam _timeRemaining = State(initialValue: TimeInterval(studyTime.wrappedValue * 60)) } var body: some View { VStack { ZStack { Circle() .trim(from: 0, to: CGFloat(timeRemaining / (TimeInterval(studyTime * 60)))) .stroke(Color.purple, lineWidth: 15) .rotationEffect(.degrees(-90)) .animation(.linear(duration: 1)) .padding(40) Text("\(timeRemaining.formattedTime)") .font(.system(size: 50)) } Button(action: { self.timerActive.toggle() }) { Text(timerActive ? "Stop" : "Start") .font(.title) .padding() } .foregroundColor(.white) .background(timerActive ? Color.red : Color.green) .cornerRadius(10) .padding() } .onReceive(timer) { _ in guard self.timerActive else { return } if self.timeRemaining > 0 { self.timeRemaining -= 1 } else { self.timerActive = false sendNotification() } print("Time Remaining: \(self.timeRemaining)") } .navigationTitle($selectedExam.wrappedValue.subject) .navigationBarBackButtonHidden(true) .onDisappear { // Actions if the timer View disappears } } var timer: AnyPublisher<Date, Never> { Timer.TimerPublisher(interval: 1.0, runLoop: .main, mode: .default) .autoconnect() .eraseToAnyPublisher() } func sendNotification() { let content = UNMutableNotificationContent() content.title = "Lernzeit vorbei" content.body = "Deine Lernzeit für \(selectedExam.subject) ist abgelaufen!" content.sound = UNNotificationSound.default let trigger = UNTimeIntervalNotificationTrigger(timeInterval: 1, repeats: false) let request = UNNotificationRequest(identifier: "timerNotification", content: content, trigger: trigger) UNUserNotificationCenter.current().add(request) { error in if let error = error { print("Fehler beim Hinzufügen der Benachrichtigung zur Warteschlange: \(error.localizedDescription)") } else { print("Benachrichtigung zur Warteschlange hinzugefügt") } } } } extension TimeInterval { var formattedTime: String { let minutes = Int(self) / 60 % 60 let seconds = Int(self) % 60 return String(format: "%02i:%02i", minutes, seconds) } } I looked it up and the app is allowed to send every type of notification... (this is initialized in another part of the code)
2
0
237
3w
Hide local notification alert when app is terminated.
I schedule a local notification to remind me to check in at work at 8 am if I am not already checked in, the code is working fine when app is in foreground, but when I kill the app, it alway show alert no matter if I already checked in or not. func userNotificationCenter(_ center: UNUserNotificationCenter, willPresent notification: UNNotification, withCompletionHandler completionHandler: @escaping (UNNotificationPresentationOptions) -> Void) { let isCheckedIn = AppManager.shared.isCheckedIn() if isCheckedIn { completionHandler([]) } else { completionHandler([.list, .sound, .banner]) } }
0
0
168
May ’24
apn-environment in Testfligh stuck on Production
Steps to reproduce: Install & Launch App When push notifications are registered, the push notification token received is a "production" push notification token rather than a "development" push notification token. We are trying to test on the sandbox environment with development push notification tokens, however the apn-environment for all builds we release via TestFlight are being set to "production". We wish to distribute builds via TestFlight with apn-environment set to "development". At the moment we have only found one way to run the app with apn-environment set to "development" which is to "Export" a Debug build, then manually install it on a device via iTunes on Windows machines. This method is not efficient or considered seamless enough for non-technical testers and stakeholders. They require a seamless way to receive Debug builds via TestFlight without resorting to other third-party platforms which allow us to manually upload the "Exported Debug build". If anyone knows how to upload a "Debug" build to Testflight which will allow the user to receive a sandbox development push token with "apn-environment" set to development I would really appreciate it.
1
0
232
May ’24
watchOS: Notification never shows up on watch face and rarely appears as a banner at all
Hi, I'm triggering a notification from the audio interruption handler (but also have a debug button set to trigger it manually) and it frequently does not show up. I don't think I have ever seen it show up when the watch face is off. I have created a singleton class to trigger this notification as follows. Note that I use a UUID in the identifier because an old thread here suggests this is necessary, but it makes no difference as far as I can tell. Any ideas? I'd like this notification to be reliable. I'm also surprised that with trigger set to nil, it does not trigger instantaneously. Any help would be much appreciated! Thanks, -- B. import Foundation import UserNotifications class NotificationSender: NSObject, UNUserNotificationCenterDelegate { static let shared = NotificationSender() override init() { super.init() let center = UNUserNotificationCenter.current() center.requestAuthorization(options: [.sound, .badge]) { granted, error in if granted { print("Notification permission granted") } else { print("Notification permission denied") } } center.delegate = self // Define the action to open the app let openAction = UNNotificationAction(identifier: "openAction", title: "Open App", options: [.foreground]) // Add the action to the notification content let category = UNNotificationCategory(identifier: "resumeAudioCategory", actions: [openAction], intentIdentifiers: [], options: []) center.setNotificationCategories([category]) } func sendNotification() { let center = UNUserNotificationCenter.current() let content = UNMutableNotificationContent() content.title = "Recording Interrupted" content.body = "You will need to restart it manually." content.categoryIdentifier = "resumeAudioCategory" // Create the notification request //let trigger = UNTimeIntervalNotificationTrigger(timeInterval: 5, repeats: false) let request = UNNotificationRequest(identifier: "ResumeAudioNotification-\(UUID().uuidString)", content: content, trigger: nil) center.add(request) { error in if let error = error { print("Error adding notification request: \(error)") } } } // Handle notification when the app is in the foreground func userNotificationCenter(_ center: UNUserNotificationCenter, willPresent notification: UNNotification, withCompletionHandler completionHandler: @escaping (UNNotificationPresentationOptions) -> Void) { // Display the notification while the app is in the foreground completionHandler([.sound, .badge, .banner, .list]) } // Handle notification response func userNotificationCenter(_ center: UNUserNotificationCenter, didReceive response: UNNotificationResponse, withCompletionHandler completionHandler: @escaping () -> Void) { // Handle the user's response to the notification // For example, navigate to a specific screen in your app completionHandler() } }
0
0
237
Apr ’24
Use iBeacon to wake up my app from terminated state
Hello, I developed an application that uses iBeacons to create events, however when the app is in the terminated state I notice that part of my code is activated but the rest of the process is not activated ex : ranging beacon and notification. Is there a way to completely wake up my app when it is in terminated state or at least send a notification to the user to inform them that the app must be opened to put it back in background state so that the app working correctly?
0
0
262
Apr ’24
Encountering 400 TopicDisallowed Error with APNS for Specific App
Hello Apple Developer Community, I am reaching out for insights regarding an issue we're facing with Apple Push Notification Service (APNS). Despite successful implementation and functioning for other apps, we are consistently receiving a 400 TopicDisallowed error when trying to send push notifications to one specific app. Here's a detailed overview: Issue Summary: Push notifications sent from our server to a specific app result in a 400 TopicDisallowed error from APNS. This problem is unique to this app; notifications to other apps with similar configurations are successful. Successful Tests via Apple CloudKit Console: Notably, when using the Apple CloudKit Push Notification Console, push notifications to the problematic app are sent successfully, indicating the app's basic setup is configured correctly. Key Details: The topic field in the push notification request matches the app's bundle ID exactly. The app is downloaded from the App Store, and we are using the production environment on our server. Payload structure, APNS endpoint, and APNS Auth Key are consistent across all apps we manage. Device tokens for the problematic app validate successfully using the tool in the push notification console. Detailed server-side logging has not revealed significant differences between successful and unsuccessful push notification requests. Given these factors, we are struggling to identify the root cause of this specific issue. I am wondering if anyone in the community has faced a similar problem or could offer any insights. Any help or guidance would be immensely appreciated. Thank you in advance!
1
0
410
Apr ’24
Mac OS LSUIElement app does not display notifications
I made a simple applescript app to run a shell script and display a notification when it ends, it runs pretty well but I did't want the app appearing in the dock, so I added LSUIElement = true in the info.plist, and now the script runs but the app does not notify. Is there a way to have a background app (does not appear in the dock) with the ability to display notifications?
0
0
294
Apr ’24
Open URL from NotificationContentExtension
I have a NotificationContentExtension, to create a custom view for a notification. This view contains several links (crucially, these are not defined as . The desired behavior is to open the url in a webview in my main app. However, using self.extensionContext.open opens the url in safari. Given that UIApplication.shared is not available in an extension, how should I go about opening a url in my main app from a notification?
0
0
322
Apr ’24
Is there a way for the app currently playing music or voice in the background to know when a Critical Alert or push comes?
Is there a way for the app currently playing music or voice in the background to know when a Critical Alert or push comes? Currently, my app contains code that stops playback when a call comes in while music or voice is playing in the background. So, if a call comes in during playback, it stops normally. However, there is a phenomenon in which playback cannot be stopped when a Critical Alert or push comes. When a Critical Alert or push comes to the device, is there a way in the code for the app currently playing music or voice in the background or foreground to know at that moment? We are not sending out Critical Alerts or pushes. I would like to know how to resolve the situation when receiving a Critical Alert or push sent to all users in one country.
1
0
395
Apr ’24
"Get device information" command is not working.
Hello Forum, If I send the device the "DeviceInformationCommand.Command.RequestType= DeviceInformation" command and "InstalledApplicationListCommand.Command.RequestType = InstalledApplicationList" command , it can be sent successfully, but I don't get a response from the device. https://developer.apple.com/documentation/devicemanagement/get_device_information ------------- our log ---------------------- general.log.5:[2024/03/27 13:23:30] (172.31.54.87) I #TaskUpdateInformationHandler - did:14379, udid:63a6d7edc9f1128808aaee49d80e9539b5fd9cdd, mdm_task_uuids:['0aa5f838-1891-4a9b-b4fd-9d7c0aa365d3', '3f401ea8-be87-499b-a4be-fea2b1dab379'], result:ok, cid:117 general.log.5:[2024/03/28 03:06:34] (172.31.76.98) I #TaskUpdateInformationHandler - did:14379, udid:63a6d7edc9f1128808aaee49d80e9539b5fd9cdd, mdm_task_uuids:['c46b8523-40cd-4c7e-8a5d-0e49c9d26106', '8a99b664-df27-4bc9-8f41-fe39e3a7f3bc'], result:ok, cid:117 It is transmitted successfully to the Apple MDM server, but there is no response from the device. However, policy distribution such as PushSetting works normally. I would like to get some document or help that I can refer to. Thank you.
0
0
336
Mar ’24