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
User Notifications
RSS for tagPush 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
157 Posts
Sort by:
Post
Replies
Boosts
Views
Activity
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.
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.
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.
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.")
}
}
}
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?
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
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)
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])
}
}
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.
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()
}
}
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?
Hello fellow developers, I am creating an application and it contains critical alerts and for that I have given the permissions but unable to find any implementations. I am using Flutter environment to develop my application and want that the application should emit a sound even if it is silent or in 'Do Not Disturb' mode.
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!
I noticed that the numbers given for the individual states do not add up; i.e. if I add everything other than "Received by APNs" I get what amounts to ~95% of that. Is that expected? And if so what happened to the remaining 5%?
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?
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?
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.
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.
After the update to iOS 17, tapping on message notification shown on CarPlay Dashboard is navigating to the CarPlay app instead of announcing the message notification.
Announce Notifications turned ON
Announce Messages turned ON
Announce New Messages option is selected
Other apps message notifications are announced as expected when tapping on the notification implying that the settings are set as required.
Enabled com.apple.developer.carplay-communication
Class CustomCarPlaySceneDelegate: UIResponder, CPTemplateApplicationSceneDelegate {
func templateApplicationScene(_ templateApplicationScene: CPTemplateApplicationScene,
didConnect interfaceController: CPInterfaceController)
func templateApplicationScene(_ templateApplicationScene: CPTemplateApplicationScene,
didDisconnectInterfaceController interfaceController: CPInterfaceController)
func scene(_ scene: UIScene, willContinueUserActivityWithType userActivityType: String)
}