# iOS 10 Screencast: User Notification Management

**URL:** <https://forums.kodeco.com/t/ios-10-screencast-user-notification-management/16823>\
**Category:** 🎓 Courses & Articles\
**Created:** [July 1, 2016, 8:18pm UTC](https://forums.kodeco.com/t/ios-10-screencast-user-notification-management/16823 "2016-07-01T20:18:51Z")\
**Posts on this page:** 12\
**Page:** 1

<div class="post-metadata">

**Author:** ![samdavies](https://assets.chunter.kodeco.com/user_avatar/forums.kodeco.com/samdavies/32/108448_2.png) [@samdavies](https://forums.kodeco.com/u/samdavies)\
**Post date:** [July 1, 2016, 8:18pm UTC](https://forums.kodeco.com/t/ios-10-screencast-user-notification-management/16823/1 "2016-07-01T20:18:51Z")

</div>

Learn what notification permissions the user has set & how to interact w/ pending & delivered notifications in the new UserNotifications framework in iOS 10.

 
* * *
 This is a companion discussion topic for the original entry at [https://www.raywenderlich.com/4968-ios-10-user-notification-management](https://www.raywenderlich.com/4968-ios-10-user-notification-management)

---

<div class="post-metadata">

**Author:** ![swiftnib](https://assets.chunter.kodeco.com/user_avatar/forums.kodeco.com/swiftnib/32/81494_2.png) [@swiftnib](https://forums.kodeco.com/u/swiftnib)\
**Post date:** [July 4, 2016, 8:30am UTC](https://forums.kodeco.com/t/ios-10-screencast-user-notification-management/16823/2 "2016-07-04T08:30:15Z")

</div>

lol i just noticed the images you put in the app, really cuddly… cacti…

---

<div class="post-metadata">

**Author:** ![silvinaroldan](https://assets.chunter.kodeco.com/user_avatar/forums.kodeco.com/silvinaroldan/32/108674_2.png) [@silvinaroldan](https://forums.kodeco.com/u/silvinaroldan)\
**Post date:** [March 11, 2017, 10:47pm UTC](https://forums.kodeco.com/t/ios-10-screencast-user-notification-management/16823/3 "2017-03-11T22:47:30Z")

</div>

Hi, I have a question, UNUserNotificationCenter.current().getPendingNotificationRequests works only for notifications you schedule locally on the user’s device, right? because with push I don’t have a request

---

<div class="post-metadata">

**Author:** ![samdavies](https://assets.chunter.kodeco.com/user_avatar/forums.kodeco.com/samdavies/32/108448_2.png) [@samdavies](https://forums.kodeco.com/u/samdavies)\
**Post date:** [March 13, 2017, 3:36am UTC](https://forums.kodeco.com/t/ios-10-screencast-user-notification-management/16823/4 "2017-03-13T03:36:48Z")

</div>

Hi @silvinaroldan,

Yes, you’re correct: that method will only return local notifications. Remote notifications are delivered immediately as they’re sent, so there would never be any pending remote notifications.

However, a `UNNotification` object for a remote notification does have a `UNNotificationRequest` object on its `request` property, but this is synthesised from the information received from the APNS server.

Hope that helps

sam

---

<div class="post-metadata">

**Author:** ![silvinaroldan](https://assets.chunter.kodeco.com/user_avatar/forums.kodeco.com/silvinaroldan/32/108674_2.png) [@silvinaroldan](https://forums.kodeco.com/u/silvinaroldan)\
**Post date:** [March 14, 2017, 4:12pm UTC](https://forums.kodeco.com/t/ios-10-screencast-user-notification-management/16823/5 "2017-03-14T16:12:20Z")

</div>

Thanks, the information was really helpful 😉

---

<div class="post-metadata">

**Author:** ![mariam](https://assets.chunter.kodeco.com/user_avatar/forums.kodeco.com/mariam/32/76572_2.png) [@mariam](https://forums.kodeco.com/u/mariam)\
**Post date:** [July 25, 2017, 3:00pm UTC](https://forums.kodeco.com/t/ios-10-screencast-user-notification-management/16823/6 "2017-07-25T15:00:05Z")

</div>

Hi Sam,

Thanks for your tutorial. I have a question: what is Swift 3 version for this snippet of code ??

```
let imageURL = Bundle.main.urlForResource(randomImageName, withExtension: "jpg")!
    
let attachment = try! UNNotificationAttachment(identifier: randomImageName, url: imageURL, options: .none)

```

---

<div class="post-metadata">

**Author:** ![samdavies](https://assets.chunter.kodeco.com/user_avatar/forums.kodeco.com/samdavies/32/108448_2.png) [@samdavies](https://forums.kodeco.com/u/samdavies)\
**Post date:** [July 26, 2017, 5:57am UTC](https://forums.kodeco.com/t/ios-10-screencast-user-notification-management/16823/7 "2017-07-26T05:57:28Z")

</div>

Hi @mariam

I’m pretty sure that that snippet of code is already in Swift 3. What problem are you having?

sam

---

<div class="post-metadata">

**Author:** ![mariam](https://assets.chunter.kodeco.com/user_avatar/forums.kodeco.com/mariam/32/76572_2.png) [@mariam](https://forums.kodeco.com/u/mariam)\
**Post date:** [July 26, 2017, 8:12am UTC](https://forums.kodeco.com/t/ios-10-screencast-user-notification-management/16823/8 "2017-07-26T08:12:51Z")

</div>

Hi sam,

Thanks for your reply. I got the following error:  
`Value of type 'Bundle' has no member 'urlForResource'`

Also, I tried the below code it worked but when I put image in xcassets it doesn’t work! ☹ Any help?

`if let path = Bundle.main.path(forResource: "SoartAlMulk", ofType: "png")`

Thanks.

---

<div class="post-metadata">

**Author:** ![samdavies](https://assets.chunter.kodeco.com/user_avatar/forums.kodeco.com/samdavies/32/108448_2.png) [@samdavies](https://forums.kodeco.com/u/samdavies)\
**Post date:** [July 26, 2017, 10:03am UTC](https://forums.kodeco.com/t/ios-10-screencast-user-notification-management/16823/9 "2017-07-26T10:03:35Z")

</div>

@mariam

Apologies, that method has been renamed:

```swift
let imageURL = Bundle.main.url(forResource: randomImageName, withExtension: "jpg")

```

should do the trick.

The reason you can’t get hold of the path for that image in the asset library is because it’s compiled into the asset catalog itself, and thus isn’t accessible in the app bundle directly.

If you just need the image then you can use the following constructor:

```swift
if let image = UIImage(named: "SoartAlMulk") { ... }

```

Alternatively, you can actually use image literals inside Xcode—which allows you to choose an image inline. Behind the scenes this uses the `UIImage(imageLiteralResourceName:)` initialiser.

Hope that helps.

sam

---

<div class="post-metadata">

**Author:** ![mariam](https://assets.chunter.kodeco.com/user_avatar/forums.kodeco.com/mariam/32/76572_2.png) [@mariam](https://forums.kodeco.com/u/mariam)\
**Post date:** [July 26, 2017, 10:20am UTC](https://forums.kodeco.com/t/ios-10-screencast-user-notification-management/16823/10 "2017-07-26T10:20:12Z")

</div>

Thanks Sam 🙂

I would like to use the image in UNNotificationAttachment, is there a way to do it when the image in asset catalog ?

Best regards,  
Mariam

---

<div class="post-metadata">

**Author:** ![samdavies](https://assets.chunter.kodeco.com/user_avatar/forums.kodeco.com/samdavies/32/108448_2.png) [@samdavies](https://forums.kodeco.com/u/samdavies)\
**Post date:** [July 26, 2017, 10:41am UTC](https://forums.kodeco.com/t/ios-10-screencast-user-notification-management/16823/11 "2017-07-26T10:41:34Z")

</div>

Hi @mariam

Although it it is _possible_ to get hold of the URL of an item in the asset catalog, I don’t think it is supported behaviour. I would therefore suggest that you put images that you want to use for user notifications directly into the bundle instead.

I’m not 100% sure on this though, so it might be worth doing some more searching around. However, I don’t see that there are any significant problems in using the bundle directly for this purpose.

sam

---

<div class="post-metadata">

**Author:** ![mariam](https://assets.chunter.kodeco.com/user_avatar/forums.kodeco.com/mariam/32/76572_2.png) [@mariam](https://forums.kodeco.com/u/mariam)\
**Post date:** [July 26, 2017, 2:53pm UTC](https://forums.kodeco.com/t/ios-10-screencast-user-notification-management/16823/12 "2017-07-26T14:53:21Z")

</div>

Well I put it directly into the bundle. And I searched a lot all what I found they do it like this. But I afraid it’s not a good approach that why I asked.

Thank you Sam so much 🙂
