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.

User Notifications Documentation

Posts under User Notifications tag

172 Posts
Sort by:
Post marked as solved
1 Replies
346 Views
How do you wake up an app without using push notification? I am developing a medical app which is isolated from the internet for cybersecurity/HIPAA reasons. When the iPhone is locked, I would like the app to launch, or return to the foreground, when the server notifies it that an event occurred. Is there a way implement this using Swift?
Posted
by NkMA.
Last updated
.
Post marked as solved
1 Replies
269 Views
I want to understand if my Remote notification will be throttled based on the payload that I am sending from my backend. The confusion is due to the introduction of apns-alert-type key with possible values of alert and background. I want to understand if I set the value of apns-alert-type to alert but include the content-available key in the aps dictionary, will such notifications be throttled if sent at a more than recommended frequency of two or three per hour? I have documented by understand here in this sheet: https://docs.google.com/spreadsheets/d/13RU0tS9w4OsPpFjqPeoM0DNm045_5CF9DDdhIM9jarQ/edit?usp=sharing Also adding the same here for easy reference: Case No. apns-push-type apns-priority aps.content-available aps.alert/badge/sound My understanding Observation Notification displayed? App woken up? 1 background 5 0 absent Misconfiguration: content-available should not be 0. ❌ ❌ 2 background 5 0 present Misconfiguration: content-available should not be 0. alert/badge/sound is not alllowed. ❌ ❌ 3 background 5 1 absent Correct Configuration: This is a background notification. ❌ ✅ 4 background 5 1 present Misconfiguration: alert/sound/badge is not allowed. ❌ ✅ 5 background 10 0 absent Misconfiguration:priority 10 is not allowed. content-available should not be 0. ❌ ❌ 6 background 10 0 present Misconfiguration:priority 10 is not allowed. content-available should not be 0. alert/sound/badge is not allowed. ❌ ❌ 7 background 10 1 absent Misconfiguration: priority 10 is not allowed. ❌ ✅ 8 background 10 1 present Misconfiguration:priority 10 is not allowed. alert/sound/badge is not allowed. ❌ ✅ 9 alert 5 0 absent Misconfiguration: alert/sound/badge should not be absent. ❌ ❌ 10 alert 5 0 present Correct configuration: Alert is shown w/o waking up the app. ✅ ❌ 11 alert 5 1 absent Misconfiguration: alert/sound/badge should not be absent. ❌ ❌ 12 alert 5 1 present Correct configuration: Alert is shown with waking up the app. ✅ ✅ 13 alert 10 0 absent Misconfiguration: alert/sound/badge should not be absent. ❌ ❌ 14 alert 10 0 present Correct configuration: Alert is shown w/o waking up the app. ✅ ❌ 15 alert 10 1 absent Misconfiguration: alert/sound/badge should not be absent. ❌ ❌ 16 alert 10 1 present Correct configuration: Alert is shown with waking up the app. ✅ ✅
Posted
by ptm_cc.
Last updated
.
Post marked as solved
2 Replies
277 Views
Even in the event of a disaster, push notifications are used to notify smartphone owners. However, we have received requests from customers for an app that assumes that the LTE network is disconnected due to base station inconveniences during disasters, and communication from the Apple cloud cannot be considered. In that case, you would like to send push notifications to the iOS app on-premises within the customer's server, but there is a way to do that.
Posted
by jona--.
Last updated
.
Post not yet marked as solved
1 Replies
351 Views
Hi all, More than a iOS dev i'm first of all a support tech. My company develops and makes available to our customers three iOS apps like one who received 3,4k reviews on the AppStore. Since many users of our apps upgrated to iOS 17 they started complaining their iPhones are not playing a sound anymore when a push notification is received. Thought at first glance that it was a simple issue like the new "rebound" ringing playing less lounder than the usual "tri-tones". But i ran my tests and it's a fact: our applications doesn't ring anymore when push notifications are received (while other apps like Protonmail rings well on the same set-up). Does any of you folks faced or are facing the same issue? Is this a setting to do on each phone? Or can it be solved by improved development (I wish it could)? Thank you very much for reading and feel free to ask any further infos. Kind regards, Pierre
Posted Last updated
.
Post not yet marked as solved
2 Replies
555 Views
Hello Friends, Could you please help me, whats wrong. We have requirement that, when I receive remote notifications on device, I need to save it in to db (without tapping or opening notification banner), regardless my app is in Foreground or in Background. I receive remote notifications on device & simulator both. And UNUserNotificationCenter delegates are being called if app is in foreground, but didReceiveRemoteNotification is not calling when app is background, not killed. func application(_ application: UIApplication, didReceiveRemoteNotification userInfo: [AnyHashable : Any], fetchCompletionHandler completionHandler: @escaping (UIBackgroundFetchResult) -> Void) { // Save to DB completionHandler(.newData) } I am having Xcode 15.2 & I tried on iOS versions 16.x & 17.x both on Simulator and on real devices. // Added this code in App delegate UNUserNotificationCenter.current().delegate = self UNUserNotificationCenter.current().requestAuthorization(options: [.alert, .sound, .badge]) { granted, error in if granted { // User granted permission DispatchQueue.main.async { UIApplication.shared.registerForRemoteNotifications() } } else { // User denied permission } }
Posted Last updated
.
Post marked as solved
1 Replies
366 Views
I'm getting really frustrated with emails from my App users who believe they've been charged for a free in-app purchase when they haven't. My App offers many in-app purchases of digital items and I give 4 of these away for free to let users get comfortable with how it works in-app. Over the last couple of years I've had a steady increase in angry emails from users who accuse me of fraud by charging them for a free item. I couldn't figure out for a while what this was as they would leave a 1 star rating, delete the app and ignore my emails for more information. Recently I had someone a bit more patient engage and explain it to me. The purchase for some reason popped up on my notifications right when I bought the [Free Item in my app]. It was from a movie I bought and the bill was delayed. The timing of that notification is what is misleading users about the free in-app purchase. Can someone take note of this please and perhaps delay any payment notifications so they aren't sent when the in-app purchase is for FREE? Thanks!
Posted
by Seoras68.
Last updated
.
Post not yet marked as solved
0 Replies
482 Views
Hello, I'm setting up a PWA with Next.js 13 and Firebase, and I need help with push notifications on iOS. Is there anyone experienced with this? I have notifications configured using the next-pwa service worker, and they work well on Android, but not on iOS. This is my worker/index.ts import { initializeApp } from 'firebase/app'; import { getMessaging, onMessage } from 'firebase/messaging'; import { onBackgroundMessage } from 'firebase/messaging/sw'; export const vapidKey = process.env.VAPID_API_KEY; export const FCM_TOKEN_COLLECTION = 'fcmTokens'; export const FCM_TOKEN_KEY = 'fcmToken' const firebaseConfig = { apiKey: process.env.NEXT_PUBLIC_FIREBASE_API_KEY, authDomain: process.env.NEXT_PUBLIC_FIREBASE_AUTH_DOMAIN, databaseURL: process.env.NEXT_PUBLIC_FIREBASE_DATA_BASE_URL, projectId: process.env.NEXT_PUBLIC_FIREBASE_PROJECT_ID, storageBucket: process.env.NEXT_PUBLIC_FIREBASE_STORAGE_BUCKET, messagingSenderId: process.env.NEXT_PUBLIC_FIREBASE_MESSAGING_SENDER_ID, appId: process.env.NEXT_PUBLIC_FIREBASE_APP_ID, vapidKey: process.env.VAPID_API_KEY, }; const app = initializeApp(firebaseConfig); const messaging = getMessaging(app); onBackgroundMessage(messaging, (payload) => { console.log('[firebase-messaging-sw.js] Received background message ', payload); // Customize notification here if (payload.notification?.title) { const notificationTitle = payload.notification.title; const notificationOptions = { body: payload.notification?.body, icon: '/images/logo-app-4.0.svg', }; self.registration.showNotification(notificationTitle, notificationOptions); } }); onMessage(messaging, (payload) => { console.log('Message received. ', payload); }); and the next.config.js const runtimeCaching = require('next-pwa/cache'); const withPWA = require('next-pwa')({ dest: 'public', register: true, skipWaiting: true, dynamicStartUrl: true, dynamicStartUrlRedirect: '/login', runtimeCaching, disable: prod ? false : true, }); module.exports = withPWA({ reactStrictMode: true, swcMinify: false, experimental: { appDir: true, }, }); and the public/firebase-messaging-sw.js importScripts('https://www.gstatic.com/firebasejs/10.6.0/firebase-messaging.js'); if ('serviceWorker' in navigator) { navigator.serviceWorker.register('../firebase-messaging-sw.js') .then(function (registration) { alert('Registration successful, scope is: registration.scope'); }).catch(function (err) { alert('Service worker registration failed, error:'); }); } firebase.initializeApp({ messagingSenderId: '*************' }) const initMessaging = firebase.messaging() initMessaging.onBackgroundMessage(messaging, (payload) => { console.log('[firebase-messaging-sw.js] Received background message ', payload); // Customize notification here if (payload.notification?.title) { const notificationTitle = payload.notification.title; const notificationOptions = { body: payload.notification?.body, icon: '/images/logo-app-4.0.svg', }; self.registration.showNotification(notificationTitle, notificationOptions); } });
Posted
by Ale000.
Last updated
.
Post not yet marked as solved
1 Replies
691 Views
i have an issue when handling silent push in my app when the user close the app, here is my native code which works like charm when the app in the foreground, background or terminated status from a short time from closing the app, and after long time from closing it (+30min) it will not work anymore, it make me confuse why it does not work and other messaging app like viber, whatsapp and messanger you can still receive messages and calls even you swipe the app and close it !! is there any thing must i add !! override func application(_ application: UIApplication, didReceiveRemoteNotification userInfo: [AnyHashable : Any], fetchCompletionHandler completionHandler: @escaping (UIBackgroundFetchResult) -> Void) { Messaging.messaging().appDidReceiveMessage(userInfo) if Auth.auth().canHandleNotification(userInfo) { completionHandler(.noData) return } // sample notification for testing let content = UNMutableNotificationContent() content.title = "Hi there" content.body = "Just test" content.sound = UNNotificationSound.default let request = UNNotificationRequest(identifier: "helloNotification", content: content, trigger: nil) UNUserNotificationCenter.current().add(request) { (error) in if let error = error { print("Error adding notification request: \(error.localizedDescription)") } } // resent to dart side let controller: FlutterViewController = window?.rootViewController as! FlutterViewController let notificationChannel = FlutterMethodChannel(name: "notificationHandler", binaryMessenger: controller.binaryMessenger) var dataToSend: [String: Any] = [:] if let text = userInfo["text"] as? String { dataToSend["text"] = text } // Convert the dictionary to NSDictionary let nsDataToSend = NSDictionary(dictionary: dataToSend) // Pass the NSDictionary to Dart notificationChannel.invokeMethod("handleRemoteMessage", arguments: nsDataToSend) } i checked : background capabilities : remote notifs, background fetching, voip, background processing
Posted
by devops07.
Last updated
.
Post not yet marked as solved
4 Replies
1.3k Views
We have an app where the notification service extension works well most of the time. However, sometimes we have noticed that the extension completely stops working even when the notification is sent successfully via the APNS server in production. We do not see even the log from the didReceive() function in that case. The only way we can get the extension working again is after restarting the iPhone. Trying to understand when this might happen? Is it something that is throttled by iOS? Would it happen when the device memory is low or the app is using too much memory? We have seen the extension crash sometimes due to hitting memory limits, however, the extension process is spawned again when a new notification comes in. Any kind of help or guidance would be greatly appreciated. Thanks We have setup acknowledgment API calls in the notification service extension processing to be notified when the notifications reach the device. So based on that we know how often the devices stop responding with the ACK to sent notifications. It happens seldom with some users and we have to ask them to restart their device to get the extension functional again.
Posted Last updated
.
Post not yet marked as solved
16 Replies
5.4k Views
Hello Everyone! After push notifications were enabled we got to work on this feature. for our PWA. The problem that we are having is that they work great for a little bit and then they suddenly stop working. We thought it was our problem but after doing some research I found that many other developers are having this same issue. Push notifications work perfectly on Android but don't reach ios users. Is anyone else having the same issue? Can something be done to fix this? Thanks!!
Posted
by Juanmdq.
Last updated
.
Post not yet marked as solved
0 Replies
394 Views
Hi, Please take a response to me about my Notification Service Entitlement Request. I have requested 5 times but i didn't get any repsonses. The application cannot be released because authorization is not granted. Please check my case and leave a response as soon as. Thanks,
Posted Last updated
.
Post not yet marked as solved
2 Replies
371 Views
As the title says. We have a pretty specific need for our app, and I have an idea of how to achieve it, but would like input on whether it's good practice or not. In communication apps such as Whatsapp or Discord, they need to send local notifications (and ideally update cached message data so it's fresh) anytime the user gets a new message. Conveniently for them, they control the backend, and so can just send out a silent push notification to the device(s) of user involved. In our case, we are creating a UI for someone else's backend, meaning we can't simply send a silent push on data change. What we were originally thinking was a sort of crowd-source involving a combination of silent push and background refresh, but refresh won't work if the user closes the app. I've read all the given reasons for this, and though I still disagree, there isn't anything we can do about it. So what I'm now thinking is that, at whatever interval (say 1-3hrs) some serverless function sends a silent push to every single client, which will wake them up to make a fetch and compare to the cached data and send a local notification if necessary. Downside here is it will likely incur some cost, and frankly it just feels kind of iffy as a solution, but I'm not sure what else we can do without controlling the backend API. Thoughts? Is there anything I'm missing? Any better ideas? Thanks in advance!
Posted
by mtroalson.
Last updated
.
Post not yet marked as solved
0 Replies
393 Views
Can I have a play/pause button in a Live Activities notification for the user to play an audio file if he/she chooses to? Kind of like a Spotify-style/Apple-Music-style play/pause/skip/rewind functionality but in the long-lasting Live Activities notification. Thank you.
Posted Last updated
.
Post not yet marked as solved
2 Replies
688 Views
Hi, How can I send push notification for point update and promos to my loyalty wallet users. Currently I get push notification Id when user install loyalty wallet and I use it for sending wallet updates. But when I tried to use this push notification id for custom APN messages it doesn't appear anywhere. Thank you.
Posted Last updated
.
Post not yet marked as solved
1 Replies
420 Views
Hello all. I noticed, that NSE living more than 30 seconds ( that described in doc ). When app receive notification, it created process NSE, and send notification to didReceive function, after this, app have 30 seconds to call contentHandler closure, after contentHandler is called, I expected that NSE process is killed, but it's not. If app using singletons in NSE, they won't dealloc after contentHandler is called, so, after new notification received, singletons still alive. Does it legal to not drop connection to websocket after contentHandler closure get called? For example, notification received, NSE process is loaded, websocket manager signleton is initialzied and started session, after few seconds contentHandler closure get called, so, system won't kill NSE because of 30 seconds timer, and my web socket connection will alive so long as possible, so, I not need to open it each 30 seconds, is that legal or not?)
Posted
by elaits.
Last updated
.
Post not yet marked as solved
0 Replies
408 Views
I'm using standard Safari Web Push, but my notifications aren't coming through. I'm trying to debug this. Is it possible to use the Apple Push Notifications Console to debug/analyze Safari Web Push deliverability? I can't figure out how to use it for web push. When I login and try to use the Push Notification Console, it asks me to choose an "app." But for standard Safari 16+ Web Push, there is no "app," no "Website Push ID", etc. that I register with Apple. So how can I use the Push Notification Console for this? Apple's documentation does strongly imply that it should work. Sending web push notifications in web apps and browsers: To resolve an error, address the issue and resend your push notification request. For more information about the factors that impact the delivery of a push notification, see Viewing the status of push notifications using Metrics and APNs. And that page is all about the Push Notification Console. So it must be possible somehow, right?
Posted
by dfabulich.
Last updated
.
Post not yet marked as solved
1 Replies
367 Views
My guess is no... but, I have to ask. I made a widget that checks our GitHub repository for new pull requests - in an attempt to make sure PRs are addressed quicker. It works great - using GitHub's API. It's on my iPhone's Lock Screen. It definitely keeps me more on top of our pull requests! Our product manager asked if we could also send a local notification when there's a new PR. I was thinking maybe from the widget - it's updating around every 15 minutes - and if there's a new PR - then maybe it could fire a local notification. However, there's the permissions. The user has to say "OK" to them. Widget can't do that. Can it inherit the notification permissions from the parent app? Anyway - I think it is way overkill - I mean we have a widget! Why a notification as well!?!?!? I thought I'd ask... Thanks, Scott iOS 17.
Posted
by Shorty16.
Last updated
.
Post not yet marked as solved
2 Replies
416 Views
We asked for and received confirmation that we have received the Critical alert entitlement. I have also tested it in development build with a development profile and it worked. However when we try to send an update to test flight to test in release mode on our device, we get the following error: The bundle contains a key that is not included in the provisioning profile: 'com.apple.developer.usernotifications.critical-alerts' NSLocalizedFailureReason = "Invalid Code Signing Entitlements. The entitlements in your app bundle signature do not match the ones that are contained in the provisioning profile. The bundle contains a key that is not included in the provisioning profile: 'com.apple.developer.usernotifications.critical-alerts' in our app. SUnderlyingError = "Error Domain=IrisAPI Code=-19241 "Asset validation failed" UserInfo={status=409, detail=Invalid Code Signing Entitlements. The entitlements in your app bundle signature do not match the ones that are contained in the provisioning profile. The bundle contains a key that is not included in the provisioning profile: 'com.apple.developer.usernotifications.critical-alerts in our app code=STATE_ERROR.VALIDATION_ERROR.90163, title=Asset validation failed we added the following entitlement to the entitlements.plist file: com.apple.developer.usernotifications.critical-alerts
Posted Last updated
.