Questions tagged [unusernotificationcenter]

Manages the notification-related activities for your app or app extension. Local notifications and push notifications are both ways for an iOS application that isn’t running in the foreground to let its users know it has something for them. Use this tag for the queries related to the new Rich Notifications introduced in Swift 3.

Use the shared UNUserNotificationCenter object to schedule notifications and manage notification-related behaviors in your app or app extension. The shared user notification center object supports both local or remote notifications in varying capacities. Use this object to perform the following types of tasks:

  • Request authorization for displaying alerts, playing sounds, or badging the app’s icon in response to local or remote notifications. (Authorization is required for all user interactions.)

  • Declare the notification types that your app supports and the custom actions (if any) that the user may perform when those notifications
    are delivered.

  • Schedule the delivery of notifications from your app.

  • Manage app-specific notifications displayed in Notification Center.

  • Get the notification-related settings for your app.

The notifications that you schedule directly from your app are known as local notifications because your app creates them locally on the user’s device. By contrast, remote notifications are created by your own server and delivered to the user’s device via the Apple Push Notification Service (APNS).

370 questions
3
votes
1 answer

UNUserNotificationCenter Swift - local notification not firing in specific cases

I'm facing issue while using Local Notifications in application. I'm scheduling local notification with custom content & custom action category. It's scheduling & firing in iOS 11, but not in iOS 10. As per documentation, it should be working in iOS…
3
votes
0 answers

UNUserNotificationCenter removeDeliveredNotificationRequests not removing notifications when created with UNCalendarNotificationTrigger

I am using the newer notification APIs introduced in iOS 10 and working in Swift. When I create a local notification, it shows up properly, but I am trying to remove it in my app when a relevant action occurs (so that the user doesn't have to clear…
3
votes
2 answers

Localise notifications sent from Firebase

Is there a way to translate / localise notifications sent from Firebase? I have my app setup to receive notifications successfully: extension AppDelegate: UNUserNotificationCenterDelegate { func setupNotifications() { …
José
  • 3,112
  • 1
  • 29
  • 42
3
votes
1 answer

Can UNUserNotificationCenter.current().requestAuthorization() be called more than once?

Can UNUserNotificationCenter.current().requestAuthorization() be called more than once? Can I invoke upon every application launch? Can I invoke it again after the user has granted notification permissions? If not, why not?
3
votes
0 answers

use systemSound from SystemSoundID for UNNotificationSound

I am trying to add a sound to my UNNotification. Instead of my own custom sound or the default sound, I would like to use one of the iOS SystemSounds in AVFoundation. I can get the sound by: import AVFoundation ... let systemSoundID: SystemSoundID…
alionthego
  • 8,508
  • 9
  • 52
  • 125
3
votes
2 answers

NotificationCenter obersever not called in swift 4

i am trying to post notification NotificationCenter from appdelegate and receive notification in another view but notification not received. Post notification :- func xmppStream(_ sender: XMPPStream, didReceive message: XMPPMessage) { print("did…
3
votes
0 answers

Local Notification not firing in IOS 11 swift4

My app works perfectly on ios 10 but on ios 11 it does not push local Notification. Is there any error in my code?. I have searced a lot but couldn't find appropriate solution is this a bug in ios 11 ? class AddReminderViewController:…
3
votes
1 answer

Cannot get Actionable Notifications callback on Apple Watch

I have an iOS App that's pushing notifications (for example when the user is entering a geographic region). I have also a Watch App that gets these notifications when the iPhone is locked. I have 2 Actions in these notifications ("Call", "Go to"),…
sebastien
  • 2,489
  • 5
  • 26
  • 47
3
votes
1 answer

UNUserNotificationCenter Thread-Safety

Deleting and adding a notification with a matching identifier one after another seems to work fine for me if they are on the same thread, as required by the docs. If they are on different threads, the newly added notification is deleted by the…
Roselle Tanner
  • 357
  • 3
  • 11
3
votes
2 answers

How to turn on and off notifications in iOS?

I am trying to implement a settings screen in an iOS 11 app, where I need a UISwitch that would be used to control user notifications. When set on off, I want to give up the permissions to notifications, when set to on, I want to request for…
Milan Nosáľ
  • 19,169
  • 4
  • 55
  • 90
3
votes
1 answer

Modify the Push notification content from Userinfo in ios

When receiving a notification, I want to change the user info content before showing in mobile notification in iOS. "aps": { "alert": { "body": "hello", "sound": "Default" "badge": "1" } } Example I want to show…
3
votes
0 answers

No done handler with removePendingNotificationRequests?

There is no done handler in removePendingNotificationRequests huh? How are you supposed to know when a request has been removed? Suppose you have a table view or something showing these requests. And you remove one - you need to remove that cell row…
Jonny
  • 15,955
  • 18
  • 111
  • 232
3
votes
1 answer

Multiple notifications in Xcode, Swift 3

first I'd like to say that I've been searching for the answer to my question quite a bit but the only things I've found so far are answers for older versions of Swift or answers that don't specifically answer my question. Background info: I'm…
G Buis
  • 303
  • 4
  • 17
3
votes
1 answer

Apple watch local notification not working when the watch isn't worn

We are using the UNUserNotification framework provided by WatchOS 3.0 to create local notification to notify user at a predefined moment. However, the notification is not shown when the watch is not being worn on the wrist. It does work well when…
Jibeex
  • 5,509
  • 3
  • 27
  • 37
3
votes
0 answers

Do something when local notification is presented when app is terminated or in the background

I know there's the will present method that will be called only when the app is in foreground state. Now I want the app to do something if the user ignored the notification. In this case I want present another view controller during the next launch…