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
5
votes
1 answer

Why are notifications not removed with removeDeliveredNotifications?

Up until recently (I believe prior to iOS 12 release), removing remote push notifications from the Notification Center worked as expected using removeDeliveredNotifications. Suddenly, without any code change in the Notification Service Extension,…
5
votes
1 answer

UNUserNotificationCenter.current().getDeliveredNotifications only returns empty array

I am trying to retrieve all delivered notifications still showing in the notification center but UNUserNotificationCenter getDeliveredNotifications(completionHandler:) just doesn't work. I can get all the pending notifications with…
5
votes
0 answers

Random Repeating Local Notifications in Swift

TL;DR: Is it possible to have repeating, random local notifications without using APNS (or an alternative push notification service)? I am building a Core Data app that includes a bunch of objects. (We'll call them widgets.) Every day at a certain…
5
votes
2 answers

Swift - Local notification icon badge number update on deliver App is in background

I am trying to figure how I can update dynamically the icon badge number when a local notification is delivered. Registering the badge number upon scheduling is not an option since if I register two or more notification before any are delivered the…
Marco
  • 1,051
  • 1
  • 17
  • 40
5
votes
2 answers

Wait till local notifications from UNUserNotificationCenter gets deleted using removePendingNotificationRequests ios 10 swift 3

Using new local notifications from UNUserNotificationCenter. I try to delete notification with some identifiers: UNUserNotificationCenter.current().removePendingNotificationRequests(withIdentifiers: identifiers) and from documention: This method…
Igor Lantushenko
  • 1,771
  • 10
  • 19
5
votes
0 answers

willpresentnotification method not called

At first glance, this may look similar to many other questions on stack overflow, but I didn't find the solution for the issue I am facing. I am using xcode 8.3.2 and ios 10.3.2 and configured FCM to send push notifications. I am receiving push…
5
votes
1 answer

Cannot open URL from notification action handler

I am trying to handle local notifications by opening a URL on iOS 10 / Swift 3. I have one URL assigned to the notification's default action and another assigned to a custom action button. When the default action is triggered (tapping on the…
5
votes
5 answers

iOS Swift Receive Push Notification When App in Foreground

Here is the code that I have used to receive push Notification when app in foreground @available(iOS 10.0, *) func userNotificationCenter(center: UNUserNotificationCenter, willPresentNotification notification: UNNotification, withCompletionHandler…
5
votes
1 answer

Local Notificaton not working in simulator iOS10.0

override func viewDidLoad() { super.viewDidLoad() // Do any additional setup after loading the view, typically from a nib. askForPermission() } @IBAction func addLocalNotification(_ sender: AnyObject) { addLocalNotification() …
akshay
  • 765
  • 6
  • 20
5
votes
1 answer

`willPresent notification` isn't called & local notifications aren't not showing up when the app is in the foreground in iOS 10

When I first run my app the simulator is able to display notifications whilst the app is in the foreground. When I relaunch the app didReceive notification: (i.e. notification method from iOS 9) is called instead of willPresent notification (i.e.…
4
votes
1 answer

Using the New UNUserNotification API in a Standalone Objective-C Program

I'm trying to throw notifications from a standalone Objective-C file. The NSUserNotification API will be deprecated after OSX 11, so I'm looking to switch to the newer UNUserNotification interface. Unfortunately, I'm not able to find much on the…
4
votes
1 answer

Schedule local notification every n days (timezone safe)

I believe this has been asked several times, but there is no clear answer. There are two ways to schedule temporal notifications: UNCalendarNotification and UNTimeIntervalNotificationTrigger. Scheduling a notification for a specific time and day of…
4
votes
2 answers

How do I provide custom accessibility text for ios local notification content - UNNotificationContent

I'm trying to provide custom text for voiceover user instead of reading the body text. E.g., the current body text is say "Apple stock $203.03 ↑" it reads as "Apple stock two hundred three dollars and three cents up arrow" but I wanted to read as…
palaniraja
  • 10,432
  • 5
  • 43
  • 76
4
votes
0 answers

Notification Service Extension Creating Local Notifications

We want to add a feature to our app so that users are able to opt-in to being reminded to read important notifications which they might have missed. Here's how we would like it to work: When a push notification comes in, a Notification Service…
4
votes
1 answer

Is there any way to remove delivered notifications upon arrival of a new one?

Roughly during the third quarter of last year, I was able to use UNNotificationServiceExtension to not only decrypt incoming push notification contents (a common use case) but also remove previously delivered notifications every time a new one…
1 2
3
24 25