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

160 Posts
Sort by:

Post

Replies

Boosts

Views

Activity

UNNotificationContentExtension Rich Notification Play/Pause Button Not Changing State
In an iOS UNNotificationContentExtension with a media player, I have an AVPlayer which can either play a WAV or an MP4 remotely depending on the push payload userInfo dictionary. I have implemented mediaPlayPauseButtonFrame, mediaPlayPauseButtonTintColor, and mediaPlayPauseButtonType, have overridden canBecomeFirstResponder to force true, and set the view to becomeFirstResponder when the AVPlayer is added. I have implemented the UNNotificationContentExtension protocol's mediaPlay and mediaPause methods. I also have subscribed to the .AVPlayerItemDidPlayToEndTime (NS)Notification and I call a method on the VC when it returns, which calls mediaPause. When the AVPlayer reaches the end, the .AVPlayerItemDidPlayToEndTime Notification is properly emitted, my method is called, and mediaPause is called. However, the media play/pause button provided by UNNotificationContentExtension remains visibly in the "playing" state instead of changing to the "pause" state. The button correctly changes its display state when the user presses the play/pause button manually, so it works. And so, collective Obis Wan Kenobi, what am I doing wrong? I have tried resigning first responder, have no access to the button itself -- as far as I know -- and am wondering where to go next. (This is the only thing not working by the way.) Sanitized example: import UIKit import UserNotifications import UserNotificationsUI class NotificationViewController: UIViewController, UNNotificationContentExtension { // Constants private let viewModel = ... private var mediaPlayer: AVPlayer? private var mediaPlayerLayer: AVPlayerLayer? private var mediaPlayerItem: AVPlayerItem? { mediaPlayer?.currentItem } override var canBecomeFirstResponder: Bool { true } // MARK: - UNNotificationContentExtension var overrides var mediaPlayPauseButtonType: UNNotificationContentExtensionMediaPlayPauseButtonType { return .default } var mediaPlayPauseButtonFrame: CGRect { return CGRect(x: 0.0, y: 0.0, width: 50.0, height: 50.0) } var mediaPlayPauseButtonTintColor: UIColor { return .blue } ... func didReceive(_ notification: UNNotification) { ... // Process userInfo for url } ... @MainActor func playAudio(from: URL) async { let mediaPlayer = AVPlayer(url: url) let mediaPlayerLayer = AVPlayerLayer(player: audioPlayer) ... // view setup mediaPlayerLayer.frame = ... self.mediaPlayer = mediaPlayer self.mediaPlayerLayer = mediaPlayerLayer self.view.layer.addSublayer(mediaPlayerLayer) becomeFirstResponder() } // MARK: - UNNotificationContentExtension func mediaPlay() { mediaPlayer?.play() } func mediaPause() { mediaPlayer?.pause() } // MARK: - Utilities private func subscribe(to item: AVPlayerItem) { NotificationCenter.default.addObserver(self, selector: #selector(playedToEnd), name: .AVPlayerItemDidPlayToEndTime, object: item) } @objc func playedToEnd(notification: NSNotification) { mediaPause() } }
2
0
436
Feb ’24
Cloud Kit Push Notifications User Opened Notification Metric
I am checking the Push Notification Console of Cloudkit to understand my apps push delivery metrics. There are nice metrics in there to see push sends and discards. But I couldn't see any metric to understand "How many of the users opened the notiifications I send". Is there any way me to understand this statistic? Also can we export this metrics without logging in to CloudKit like an API request?
0
0
318
Feb ’24
Experiencing Duplicate Notifications Issue Recently
For a period of time, we have frequently received reports of users receiving duplicate message notifications. We can ensure that the message is only sent once and there is only one ApnsId, but when it reaches the device, there are multiple duplicate notifications (2-3) I suspect this may be related to iOS 17, as there seems to be some overlap in time. Have others encountered similar problems? We sincerely hope to receive help from society. Thank you for your help~
1
1
868
Feb ’24
IOS warning: instance method 'userNotificationCenter(_:willPresent:withCompletionHandler:)' nearly matches optional requirement
In an iOS project, I have implemented the following delegate method to handle Notifications when app is in foregorund: func userNotificationCenter (_ pNotificationCenter : UNUserNotificationCenter, willPresent pNotification : UNNotification, withCompletionHandler pCompletionHandler : @escaping (UNNotificationPresentationOptions) -> Void) -> Void { // When app is in foreground, notification is directly sent to // the app by invoking this delegate method. } When building, I'm getting the warning. But my implementation is correct according to documentation. Why is this method not recognized as the implementation of the UNUserNotificationCenterDelegate protocol? This is the warning in text format: Showing All Issues <file path & line number>: Instance method 'userNotificationCenter(_:willPresent:withCompletionHandler:)' nearly matches optional requirement 'userNotificationCenter(_:willPresent:withCompletionHandler:)' of protocol 'UNUserNotificationCenterDelegate' This is the image of the warning: Am I missing some flag in a compiler setting? My env: Xcode 15.2, Swift 5.0, Deployment target - iOS 14.0+.
1
0
418
Feb ’24
Unable to remove notification number in badge when enter app
Hi! I have recently added the functionality of notifications in my app. I can send notifications and I see them in my phone well. The problem is that even if I have no notifications, the badge shows I have 3 and I can not remove this notification when I read the notifications. What it is strange is that even if I send new notifications, the number 3 is still there...
1
0
322
Feb ’24
How to send Push without sound and indication on iOS
Hi, I need a feature in the iOS app that requires updating the user screen via FCM. In other words, I have to update it with no sound and screen display, but this doesn't work. When I remove the notification field, the notification will not be displayed to the user, but the sound will be played. If I remove the sound field, I can make no sound, but the user will be notified. If I remove both, I'm not getting this from the iOS app. How can I solve this?? Which option should I send Push from the server?? I'm also using Notification Service Extension.
1
0
436
Feb ’24
Help migrating from .p12 to .p8
Prior to .p8 tokens, we were using .p12 cert for communication with APNS. We have since migrated to use .p8 token within our 3rd party push notification provider however, we still have the .p12 cert associated with our AppStore provisioning profile. Do we still need to maintain the .p12 cert to ensure the validity of the AppStore provisioning profile? Will revoking the .p12 cert result in inability for Apple to recognize that the app has push notifications enabled?
0
0
660
Feb ’24
Is a Privacy Manifest Required When Using Notification Service Extension?
Apple requires declaring the use of UserDefaults in both the App and third-party libraries in the PrivacyInfo. However, I also utilize UserDefaults in the Notification Service Extension. Should I treat the Extension as part of the App and only declare it within the App project? Or do I need to separately declare it for the Extension as well?
0
2
685
Feb ’24
Force Update required after App Transfer for Push Notifications?
This question is a follow-on and clarification from this earlier post. I'd just like to confirm that after an App Transfer has been completed, whether there is any need for a new release to be cut? Judging from the prior post, my understanding is that a new release would not be necessary, and that all the existing versions of the app will continue to connect successfully with the APN servers. The only necessary update would be the server connection between the APN servers and the server used to generate notifications, with a new token or certificate. Is my understanding correct?
2
0
376
Feb ’24
The failed reason `Unregistered` for APNS notification is no longer exists since February 1st, 2024
Refer to the document: https://developer.apple.com/documentation/usernotifications/setting_up_a_remote_notification_server/handling_notification_responses_from_apns#3394529 Error code 410, 'Unregistered' means: The device token is inactive for the specified topic. But since February 1st, 2024, we did not got 'Unregistered' response any more. Do you know why ?
3
3
740
Feb ’24
FCM Push notifications stop working on PWA
I have implemented Web push notifications for a website built on NextJs 13 using Firebase and they are working perfectly on desktop Chrome, Safari, and Android Chrome. But on IOS after adding the website to the home screen, the user initially starts receiving notifications after 3-4 notifications even if the user does nothing and just leaves the PWA open, the user stops receiving notifications foreground and background. On further debugging, I found out that the FCM device token gets changed. I have no idea why it is changing automatically without doing anything It happens only for IOS. IOS version 17.3 and 16.7, Firebase version 10.7.1 Is this a bug? or if someone can guide me on this?
1
0
571
Feb ’24
push notifications on-premises
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.
2
0
328
Jan ’24
Push notifications doesn't make a sound while received on iOS 17
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
1
0
413
Jan ’24
Need clarity about background notifications
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. ✅ ✅
1
0
313
Jan ’24
[APNS][RemoteNotifications] didReceiveRemoteNotification UIBackgroundFetchResult method doesn't being called, when App is in background state, iOS swift push notification.
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 } }
2
0
717
Jan ’24
iOS misleading users with payment notification timing
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!
1
0
432
Jan ’24