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
124
votes
11 answers

Registering for Push Notifications in Xcode 8/Swift 3.0?

I'm trying to get my app working in Xcode 8.0, and am running into an error. I know this code worked fine in previous versions of swift, but I'm assuming the code for this is changed in the new version. Here's the code I'm trying to run: let…
86
votes
8 answers

UIApplication.registerForRemoteNotifications() must be called from main thread only

Xcode 9 (iOS 11) showing me an error/warning while registering for Push (remote) notification. Here is error message And here is code, I've tried: let center = UNUserNotificationCenter.current() center.delegate =…
Krunal
  • 77,632
  • 48
  • 245
  • 261
51
votes
5 answers

Getting local notifications to show while app is in foreground Swift 3

Apparently this is now possible with ios10 : optional func userNotificationCenter(_ center: UNUserNotificationCenter, willPresent notification: UNNotification, withCompletionHandler completionHandler:…
user6820041
  • 1,213
  • 2
  • 13
  • 29
30
votes
5 answers

Add Local Notification in iOS 10 - Swift 3

So I been trying to add a notification to the new UNUserNotificationCenter, but I don't seem to get it. My view controller has an action: @IBAction func sendPressed(_ sender: AnyObject) { let content = UNMutableNotificationContent() …
Bjarte
  • 2,167
  • 5
  • 27
  • 37
29
votes
5 answers

Enable or Disable Iphone Push Notifications inside the app

I have a iphone app which is enable to receive push notifications. Currently i can disable push notifications for my app by going to the iphone settings/Notifications. But i want to add a switch or button inside my app to enable or disable push…
27
votes
2 answers

How to enable/disable push notification from the app?

In my app I want to enable/disable push notification from the settings page of my app itself.Can any one suggest me a solution to turn on/off the status of app in notification center from the app ?
22
votes
4 answers

iOS 10 How to view a list of pending notifications using UNUserNotificationCenter?

Solution Code: let center = UNUserNotificationCenter.current() print(center.getPendingNotificationRequests(completionHandler: { error in // error handling here })) My original post: I am trying to get a list of pending notifications…
Ian Kohlert
  • 484
  • 1
  • 4
  • 15
20
votes
2 answers

How can I know when UNUserNotificationCenter's removeAllPendingNotificationRequests() has completed?

The iOS docs say that UNUserNotificationCenter's removeAllPendingNotificationRequests() is asynchronous. What I want to do is this: Call removeAllPendingNotificationRequests() to get rid of all my scheduled notifications Schedule a bunch of new…
Erik Westwig
  • 713
  • 4
  • 16
18
votes
3 answers

UNUserNotificationCenter link error

I have an Xcode project, Xcode 8.1 (8B62) with two targets, one for the paid version of the application and the other for the free version. They both manage remotes push notifications. Since I made the changes for iOS 10 with the new framework…
Patrick Bodet
  • 641
  • 2
  • 8
  • 17
16
votes
2 answers

How can I remove previously delivered notifications when a new notification arrives with UNUserNotificationCenterDelegate in iOS 10?

This question is about the new UserNotifications framework in iOS 10. I have an app that schedules a local notification every half hour after the user did a certain action in the app, starting at 1 hour. To avoid cluttering a user's lock screen or…
gohnjanotis
  • 6,513
  • 6
  • 37
  • 57
14
votes
4 answers

iOS 11 crashing with bundleProxy != nil error on using UNUserNotificationCenter

The following line of code is where our app has suddenly started to crash on iOS 11 / 11.0.1 / 11.0.2 / 11.1.1 / 11.2.2 for some users: UNUserNotificationCenter *center = [UNUserNotificationCenter currentNotificationCenter]; We've got this in…
strangetimes
  • 4,953
  • 1
  • 34
  • 62
13
votes
1 answer

Use of undeclared type 'UNUserNotificationCenter'

i want to show banner of push notification when app is in foreground. And i implementing this method to show notification: func userNotificationCenter(_ center: UNUserNotificationCenter, willPresent notification: UNNotification,…
Shahbaz Akram
  • 1,598
  • 3
  • 28
  • 45
12
votes
3 answers

Action Button Not Appearing in Notification iOS 10

I am using local push notifications in my app. when added action button for the notification in iOS 10, it doesn't appear below the notification. the notification is appearing, but the action button is missing at the bottom of the notification. The…
Ganesh Kumar
  • 1,631
  • 2
  • 21
  • 35
11
votes
6 answers

iOS 10 UserNotifications custom sound in background mode

Since UILocalNotification is deprecated in iOS 10 so I have updated my local notification flow using the UNUserNotification framework. The app plays custom sound using AVPlayer when the app is in the foreground and it works fine. But in background…
11
votes
1 answer

Accessing the scheduled date of a UNNotificationRequest object

I'm try to find the scheduled fire date of a UNNotificationRequest object. I'm fetching the pending notifications requests like this: UNUserNotificationCenter.current().getPendingNotificationRequests { (notifications) in let…
glv19
  • 474
  • 6
  • 16
1
2 3
24 25