---
title: "#260: New Notifications Capabilities 💭"
url: https://littlebitesofcocoa.com/260-new-notifications-capabilities
author: Jake Marsh
published: 2016-09-07
topics: ["Notifications"]
description: "Today we'll continue our look at Notifications in iOS 10 by checking out some new capabilities for interacting with the user's notification preferences, and..."
---

# #260: New Notifications Capabilities 💭

By Jake Marsh, September 7, 2016. HTML: https://littlebitesofcocoa.com/260-new-notifications-capabilities

Today we'll continue our look at [Notifications](https://www.littlebitesofcocoa.com/topics/29-notifications?v=l) in **iOS 10** by checking out some new capabilities for interacting with the user's **notification preferences**, and also the **notifications** we've requested and setup with the **notification center**. Let's begin.

First up, we <i>finally</i> have a way to "ask" the system for the user's current **notification preferences state**: 

``` swift
UNUserNotificationCenter.current()
  .getNotificationSettings { settings in 
    // settings is a beautifully descriptive
    // UNNotificationSettings object.
  }
```

Inside this fancy `UNNotificationSettings` object is a wealth of detail about exactly how the user has configured our **app's notifications** to work. Everything from `authorizationStatus` to `alertStyle`. Neat!

Next up, since we've been requesting all these **notifications** to be triggered, we can now ask the system to give us the list of _pending notifications_. (**Notifications** that are scheduled, but haven't been displayed yet).

``` swift
UNUserNotificationCenter.current()
  .getPendingNotificationRequests { requests in
    // requests is an array
    // of UNNotificationRequest objects.
  }
```

From here, we can take the `identifier` of any of these **requests**, and use it to (for example) "unschedule" it:

``` swift
UNUserNotificationCenter.current()
  .removePendingNotificationRequests(
    withIdentifiers: ["asteroid-id-123"]
  )
```

**Functions** also exist to remove all _pending notifications_ at once.

Last but certainly not least, we can actually do this exact same type of management on <i>notifications that have already been shown to the user</i>.

That's right we can retrieve the **notifications** that are currently in **Notification Center** like this:

``` swift
UNUserNotificationCenter.current()
  .getDeliveredNotifications { (notifications) in
    _ = notifications.map { print($0.request.identifier) }
  }
```

We can also remove any or all of these **notifications** by `identifier` as well. Super neat!
