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

157 Posts
Sort by:

Post

Replies

Boosts

Views

Activity

Send ImagePreview within firebase cloud messaging to iOS
Is there a way to to add a key for imageURL below that shows as image preview on the right side of a push notification or do i need to create a Notification Content Extension to make it work? `const message = { apns: { payload: { aps: { 'mutable-content': 1, alert: { title: title, body: body, image: imageURL, }, }, }, fcm_options: { image: imageURL, }, }, data: { articleId: articleId, 'media-url': imageURL, }, tokens: tokens, };` I'm getting the image through, but just if the user long presses on the push notification and then it appears below, but i want it to look like in the screenshot: Thanks
3
0
200
Oct ’24
Not getting push after installing a test version
Hi After uploading a problematic version of our app to TestFlight my iphone does not get push notification anymore for our app. Other users are not affected. I deleted the app and installed the version from the appstore and still i do not get push notifications to the app. anyone that installed the version on testflight can't get push notification even if they went back to the original version from the app store. also tried to shutdown / startup the phone... no change. Any idea what went wrong and how to fix it?
3
0
224
Oct ’24
Generating and receiving token for Push Notifications stopped working
Hi, hope you're all doing well. I have a real brain-cracker here... Have been looking into this for the past 20 hours, but can't figure it out. We built an iPhone app that essentially functions as a shell around a PWA Web-App using WebView. The tricky part here to set things up was getting the Push Notifications to work. Eventually we got this working though (with help of Firebase), and the app has been working great for the past 7 months. Now, all of a sudden as it seems, when users first open up the app, there's no FCM token generated and passed on to the WebView instance running javascript. Or at least, the listening event ('push-token') no longer gets fired. Users who already have their FCM token generated and stored earlier on, receive push notifications without any issues. It's just that no new FCM tokens seem to be generated - or at least no longer passed to the WebView's javascript code. I know this for a fact as my tests turn out that the following event (present in my PWA Web-App JS code) no longer gets fired. Again, this worked fine before. I have NOT updated the native app since 6-7 months. `/* LISTEN FOR FCM (PUSH MESSAGES) TOKEN FROM NATIVE (IOS) SHELL: */ window.addEventListener('push-token', function(event) { //alert("Push Token registration event called from native shell"); if (event && event.detail) { var token = event.detail; window.fcmPushMessageToken = token; localStorage.setItem('fcmPushMessageToken', token); //alert("Received FCM token: " + token); registerDeviceForPushMessages(); } });` Hereé the part in my native iOS code that used to call this event from within the native iOS shell: func handleFCMToken(){ DispatchQueue.main.async(execute: { Messaging.messaging().token { token, error in if let error = error { print("Error fetching FCM registration token: \(error)") checkViewAndEvaluate(event: "push-token", detail: "ERROR GET TOKEN") } else if let token = token { print("FCM registration token: \(token)") checkViewAndEvaluate(event: "push-token", detail: "'\(token)'") } } }) } func checkViewAndEvaluate(event: String, detail: String) { if (!EPDriversApp2.WebView.isHidden && !EPDriversApp2.WebView.isLoading ) { DispatchQueue.main.async(execute: { EPDriversApp2.WebView.evaluateJavaScript("this.dispatchEvent(new CustomEvent('\(event)', { detail: \(detail) }))") }) } else { DispatchQueue.main.asyncAfter(deadline: .now() + 1.0) { checkViewAndEvaluate(event: event, detail: detail) } } } Again, I have not updated the native iOS app OR the WebApp's code. This just stopped functioning all of a sudden. One "weird" thing I noticed that there's no Provisiong Profile associated with the app. I'm not sure whether this was ever the case before, to be honest. Is this even mandatory? Can not having a Provisiong Profile associated with the app effect the ability of an already pusblished app for generating Push Notification tokens?
0
0
205
Oct ’24
WatchOS local notifications delayed
I'm scheduling local notifications on my WatchOS app, but they are always alerting exactly 13 seconds later than scheduled. I have read other users having the exact same issue but there is no solution anywhere. I'm not sure how one is supposed to write any sort of timer app when they are always coming in delayed. Any idea why this occurs and how to resolve it? For now I am subtracting 13 seconds from the end time, but that's not really a solution I'm happy with. Thanks
2
0
273
Oct ’24
Local notification shown in iphone not shown on apple watch
I created a local notification as follows: func scheduleNotification(title: String, subtitle: String = "", date: Date, id: String) { // Extract the components from the date let calendar = Calendar.current let hour = calendar.component(.hour, from: date) let minute = calendar.component(.minute, from: date) let second = calendar.component(.second, from: date) // Set the extracted components into DateComponents var dateComponents = DateComponents() dateComponents.hour = hour dateComponents.minute = minute dateComponents.second = second let content = UNMutableNotificationContent() content.title = title content.subtitle = subtitle content.sound = UNNotificationSound.default let action1 = UNNotificationAction(identifier: Constants.NOTIFICATION_ACTION_IDENTIFIER_1.id, title: Constants.NOTIFICATION_ACTION_IDENTIFIER_1.label, options: []) let action2 = UNNotificationAction(identifier: Constants.NOTIFICATION_ACTION_IDENTIFIER_2.id, title: Constants.NOTIFICATION_ACTION_IDENTIFIER_2.label, options: []) let category = UNNotificationCategory(identifier: "reminderCategory", actions: [action1, action2], intentIdentifiers: [], options: []) UNUserNotificationCenter.current().setNotificationCategories([category]) content.categoryIdentifier = "reminderCategory" let trigger = UNCalendarNotificationTrigger(dateMatching: dateComponents, repeats: false) let request = UNNotificationRequest(identifier: id, content: content, trigger: trigger) // add our notification request UNUserNotificationCenter.current().add(request) } and I also have func userNotificationCenter(_ center: UNUserNotificationCenter, willPresent notification: UNNotification, withCompletionHandler completionHandler: @escaping (UNNotificationPresentationOptions) -> Void) { // Handle foreground presentation options completionHandler([.sound, .badge]) } but for some reason the notification only shown on the phone. I've made sure that the phone is locked, apple watch is unlocked and also the notification setting in the watch app for this app is set to mirror.
0
0
196
Oct ’24
What is migration process or steps needs to be taken from App side while migrating the push notifications approach from certificate to keys(token)
We are recently started the migration from Certificate based approach push notification configuration to Token bases (APNS Keys) approach push notifications. From Server side, its pretty straight forward that we need to use APNS Keys. But We are facing one issue where we are not sure whether we can expire the existing push notification certificate that we are using so far or not. If I expire the existing certificate, then it will also be removed from App Id configuration capabilities as shown below and when I create the provisioning profile for this Bundle Id, it doesn't contain the push notification capability and also shows error in the Xcode while using the profile. can anyone help on this how to resolve this issue ? or any process or steps to follow for this migration ? Thanks in advance.
2
0
236
Oct ’24
Push notifications functions never triggered
I've spent over a day on this so I'm hoping someone on here has some idea as to what is going on for me. I've implemented push notifications in my app, but when I send a notification to a device, none of the receiving function are triggered. When the app is in the background, the notification arrives correctly, and when tapped it correctly launches the app - but the didReceiveRemoteNotification function is never triggered, so I'm unable to handle/react to the notification. When the app is in the foreground, neither the willLaunch or didReceive functions are triggered. I'm setting the UNUserNotificationCenterDelegate in the willFinishLaunchingWithOptions function, and when I monitor the app via the console, it shows no errors and shows willPresentNotification delivery succeeded I have updated the Background Modes to include background fetch, background processing, and remote notifications. I have also tested this on both the Xcode simulator and a physical device with the same results. I've also tested this with push notifications coming from my server, push notifications coming from the CloudKit console, and just dropping a JSON file onto the simulator. All resulted in the same behaviour. Does anyone have any idea why these functions might not be triggered??
3
0
218
Oct ’24
UNNotificationRequest Scheduling Limitation
I have read from previous posts in the forum and in StackOverflow that the limitation of 64 notification is still present with the current iOS18 version right? Inside testflight I was not able to reproduce this limit and was wondering if it only applies to the AppStore. Is it only a limit of scheduled notifications or is there also a limit of delivered notifications ? I find the Apple documentation lacking detail in this regard. If the latter is the case, I will not bother building a notification manager to deal with frequent notification scheduling. thank you in advance S.
2
0
173
Oct ’24
Iphone 12 Mini - Bluetooth Problem - IOS 18
I have been experiencing a consistent problem when connecting to a bluetooth device (Speaker, Vehicle, Etc.) where the music cuts-out every time I receive a notification or my Iphone screen turns on or off. This never happened before the update. I have tried restarting, downgrading to previous IOS versions and reupdating to the latest. No luck, unfortunately. I thought this might be due to the devices, but this happens when playing music through my device as well. I have checked the notification settings and haven't found anything that fixes this problem. Any assistance would be much appreciated.
1
0
173
Oct ’24
What restrictions does didReceiveRemoteNotification have when the app is started in background by the system?
I previously posted a topic about receiving application(_:didReceiveRemoteNotification:fetchCompletionHandler:) callback when my app is not running, and the system starts the app in the background to respond to a notification. While I receive the callback reliably, the work performed by the callback seems to have different restrictions whether the app is in the background or not running. When the app is running in the background, the work started in this callback completes reliably (in my case it takes no more than a few seconds), and I can post the result back to the system via the completion handler. When the app is not running and the system starts it in the background, the app starts the same work, but this work seems to be terminated quickly without being able to complete, and without me being able to call the completion handler passed to the callback. I’m not talking about 30 seconds - the termination seems to happen after less than a second, which is not enough for my app. The nature of the work shouldn’t matter, but just in case: I start a Task in the callback for some asynchronous work, which stores the completion handler, and calls back to it when the work is finished. This happens completely reliably when the app is running in the background, and not at all reliably when the app is not running and is started by the system. Why would application(_:didReceiveRemoteNotification:fetchCompletionHandler:) behave differently based on if it is ran when the app is already running, vs not running and started by the system? Is there anything I can do on my side to make it more reliable?
2
0
344
Oct ’24
Calling `requestAuthorization(options:completionHandler:)` in Swift 6 leads to `EXC_BAD_INSTRUCTION` crash.
I am in the process of evaluating Swift 6 and I noticed that when using the completion handler version of the requestAuthorization the application crashes with EXC_BAD_INSTRUCTION exception. Using this code: let center = UNUserNotificationCenter.current() center.requestAuthorization(options: [.alert, .sound, .badge]) { success, error in print(success) } Crashes when the project is build with Swift 6 and works normalising when build with Swift 5. The only solution that I have found so far is to switch to using the async version of that API: Task { let center = UNUserNotificationCenter.current() do { if try await center.requestAuthorization(options: [.alert, .sound, .badge]) == true { print("success") } else { print("fail") } } catch { print("Error") } } Is the a known issue? I have submitted feedback with ID "FB15294185".
2
0
312
Oct ’24
Regression: Heavy Delay of Push Notifications on iOS 18.1 beta (10s and more)
My app one sec uses push notifications to guide the user back to the app from a Screen Time Shield (screenshot attached). On iOS 18.1, notifications are delivered with a delay of 10+ seconds, even though they are classified as time sensitive: notificationContent.interruptionLevel = .timeSensitive notificationContent.relevanceScore = 1.0 The notification trigger is nil, which according to the documentation should show the notification banner immediately: var notificationTrigger: UNTimeIntervalNotificationTrigger? = nil "The condition that causes the system to deliver the notification. Specify nil to deliver the notification right away." In the sysdiagnose I have noticed that activity related to Apple Intelligence Priority classification delays the notification by 10 seconds ("UserNotificationsCore.IntelligenceActor"): [create, [id=43C0-B333, time=2024-09-27 06:03:26, bundle=***.riedel.one-sec], Time elapsed=10.373 sec]: Timeout of 10.0 reached. Cancelling work. [create, [id=43C0-B333, time=2024-09-27 06:03:26, bundle=***.riedel.one-sec], Time elapsed=10.377 sec]: Calling out to completion with failure(UserNotificationsCore.StepFailure.timedOut(exceeded: 10.0 seconds, summaryStatus: Optional(UserNotificationsServices.NotificationSummaryStatus.inferenceTimedOut), priorityStatus: Optional(UserNotificationsServices.NotificationPriorityStatus.inferenceTimedOut))) from 'scheduleTimeoutToPerform(after:for:)' [create, [id=43C0-B333, time=2024-09-27 06:03:26, bundle=***.riedel.one-sec], Time elapsed=10.378 sec]: Step: UserNotificationsCore.IntelligenceActor, index: 0 exceeded 10.0 seconds This seems like a bug to me, time sensitive notifications should be exempted from being analyzed for priority, especially if that comes at the cost of delaying notifications by 10 seconds. Tracked in Radar: FB15255061
13
5
1.9k
1w
How do I test if my app is restarted correctly when receiving push notifications?
To receive silent push notifications in the background, I need to include content-available payload into my APNS push notification, and have application(_:didReceiveRemoteNotification:fetchCompletionHandler:) implemented. When I send a push notification, my app receives and handles it with the above method. This works correctly and is straightforward to test when the app is running in foreground or background on my device. I would like to test if my app is woken up correctly from scratch and does the above work. But how do I do this? How do I get my app into the state where it is started when it receives a silent push notification? When the user force-kills the app, the notification is not delivered. This is also the case when I as a developer force-kill the app which I am testing. I assume it also applies when I force-stop the app running on my device from within Xcode. Is there any way for me as a developer to terminate the app, which does not count as “force killing”, and would reliably start the app when it receives the background notification?
3
0
356
Sep ’24
Request authorization for the notification center crash iOS app on Swift 6
Hey all! During the migration of a production app to swift 6, I've encountered a problem: when hitting the UNUserNotificationCenter.current().requestAuthorization the app crashes. If I switch back to Language Version 5 the app works as expected. The offending code is defined here class AppDelegate: NSObject, UIApplicationDelegate { func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool { FirebaseApp.configure() FirebaseConfiguration.shared.setLoggerLevel(.min) UNUserNotificationCenter.current().delegate = self let authOptions: UNAuthorizationOptions = [.alert, .badge, .sound] UNUserNotificationCenter.current().requestAuthorization(options: authOptions) { _, _ in } application.registerForRemoteNotifications() Messaging.messaging().delegate = self return true } } The error is depicted here: I have no idea how to fix this. Any help will be really appreciated thanks in advance
13
2
1.1k
1w
AW10 and iPhone 16 notifications not working while using CarPlay
I just switched back to Apple Watch from Garmin, and in the time away I got both work and personal vehicles with CarPlay. I've noticed that my AW10 does not get ANY notifications pushed to it while I am using CarPlay, which is annoying because only texts and calls get pushed to my CarPlay screen, so i miss everything else. Additionally, and this may be a bug issue with iOS18, but I also just noticed that my phone (16) does not light up/make sounds for notifications while using CarPlay - so it doesn't light up, nor do the vehicle speakers make sound with IG/snapchat/etc notifications, and even the screen "lock" sound doesn't audibly go off. I've only had CarPlay for a few months, but I typically keep my phone on Silent anyway, so maybe I'm just noticing this now and its not necessarily a new issue? it does make the sound when i get a text, so logically everything else should make a noise. I've made sure that my general focus and car focus modes are OFF. Sound is ON. Sound volume setting is all the way up. Have also restarted both phone and watch, and “forgot“ the phone from the vehicle and reconnected Am I doing something wrong here? is there a solution for either problem? From what I've seen, some people say that the AW not getting notifications at the same time as Carplay is a built-in safety feature, which most people do not want... maybe its the same with the phone not alerting to non-text/call notifications?
1
0
255
Sep ’24
Sending Push Notifications to api.sandbox.push.apple.com fails
I am developing a new App that uses Push Notifications. I completed the development of the App itself and I can send Push Notifications from the CloudKit and receive it on my phone. My problem is sending the Push Notifications from our service API to Apple. If I use the production address gateway.push.apple.com, I can send messages, but they don't work for my new App because it is in development and not yet released. If I use the sandbox address api.sandbox.push.apple.com, I get the following exception: System.Net.Sockets.SocketException (10061): No connection could be made because the target machine actively refused it. [::ffff:17.188.143.98]:2195 at System.Net.Sockets.Socket.DoConnect(EndPoint endPointSnapshot, SocketAddress socketAddress) at System.Net.Sockets.Socket.Connect(EndPoint remoteEP) at System.Net.Sockets.Socket.Connect(IPAddress[] addresses, Int32 port) --- End of stack trace from previous location --- at System.Net.Sockets.Socket.Connect(IPAddress[] addresses, Int32 port) at System.Net.Sockets.Socket.Connect(String host, Int32 port) at System.Net.Sockets.TcpClient.Connect(String hostname, Int32 port) at System.Net.Sockets.TcpClient..ctor(String hostname, Int32 port) The service API for sending Push Notifications was developed in C# .NET 8.0. Constants: private readonly string _hostname = "api.sandbox.push.apple.com"; private readonly int _port = 2195; The code for sending a message. public async Task Send(string? subtitle, string? title, string message, string deviceId) { var payload = "{ \"aps\": { " + "\"alert\": { " + "\"title\": \"" + title + "\", " + "\"subtitle\": \"" + subtitle + "\", " + "\"body\": \"" + message + "\"" + "} " + "} " + "}"; try { Debug.WriteLine($"apple api request: {payload}"); using var client = new TcpClient(_hostname, _port); var sslStream = new SslStream(client.GetStream(), false, new RemoteCertificateValidationCallback(ValidateServerCertificate)); var certificatesCollection = new X509Certificate2Collection(_certificate); await sslStream.AuthenticateAsClientAsync(_hostname, certificatesCollection, SslProtocols.Tls12 | SslProtocols.Tls13, true); var array = DataToBytes(deviceId, payload); sslStream.Write(array); sslStream.Flush(); client.Close(); } catch(Exception exception) { Debug.WriteLine(exception); } } The certificate that is used in this code was read beforehand: var clientCertificate = new X509Certificate2(iOSApp.Certificate, iOSApp.CertificatePassword); We are using a p12 certificate file with a private password. Again, it works great for an App in Production but not at all for an App in Development. I made use that I use a new p12 developer certificate for the new App when I tested. I also tested with a p12 production certificate. I get the same error. Any help is appreciated.
1
0
304
Sep ’24
Intermittent TopicDisallowed Error with APNs
Hello, I am encountering an intermittent TopicDisallowed error while using APNs and would like to ask for your assistance. Environment: Authentication: We are using certificate-based authentication with APNs, where the PEM file is stored on the server to authenticate our requests. API: We are using the HTTP/2 API and calling the /3/device/<device_token> endpoint while passing the apns-topic in the request header. Issue: After renewing our APNs certificate, the new certificate mistakenly included an incorrect app bundle ID, resulting in a TopicDisallowed error. We then issued a new certificate with the correct bundle ID and replaced it on our server before resuming remote push requests. However, even after replacing the certificate, we are still intermittently receiving the TopicDisallowed error, while other requests successfully return a 200 OK response and deliver notifications to devices. Over time, the frequency of TopicDisallowed responses has been decreasing, leading us to speculate that APNs might be caching responses and updating this cache over time. Questions: Could you provide details on the specific conditions or causes that lead to a TopicDisallowed error? After replacing the certificate, is there a reason why we might still be intermittently receiving this error? Are there additional certificate or configuration settings we should check? What might cause some requests to succeed with a 200 OK response, while others result in a TopicDisallowed error with the same setup? Is it possible that APNs could be caching outdated information from the previous certificate, which might explain the decreasing frequency of the errors? We have reviewed our certificate and configuration after the renewal, but the issue persists. Any guidance on how to further troubleshoot or resolve this would be greatly appreciated. Thank you.
1
0
259
Sep ’24
VOIP rejection
The app declares support for Voice-over IP (VoIP) in the UIBackgroundModes key in your Info.plist, but we are still unable to locate any VoIP services. Apps that declare support for VoIP in the UIBackgroundModes key in your Info.plist file must have features that require VoIP. My app rejected for VOIP and the app is totally supported video call or call when app is terminated or in background how can. i solve that rejection issue
0
0
270
Sep ’24