
- iOS Tutorial
- iOS - Home
- iOS - Getting Started
- iOS - Environment Setup
- iOS - Objective-C Basics
- iOS - First iPhone Application
- iOS - Actions and Outlets
- iOS - Delegates
- iOS - UI Elements
- iOS - Accelerometer
- iOS - Universal Applications
- iOS - Camera Management
- iOS - Location Handling
- iOS - SQLite Database
- iOS - Sending Email
- iOS - Audio & Video
- iOS - File Handling
- iOS - Accessing Maps
- iOS - In-App Purchase
- iOS - iAd Integration
- iOS - GameKit
- iOS - Storyboards
- iOS - Auto Layouts
- iOS - Twitter & Facebook
- iOS - Memory Management
- iOS - Application Debugging
- iOS Useful Resources
- iOS - Quick Guide
- iOS - Useful Resources
- iOS - Discussion
How to check notifications status for the iOS App
Notifications communicate important information to users of your app, regardless of whether your app is running on the user's device.
For example, a sports app can let the user know when their favourite team scores. Notifications can also tell your app to download information and update its interface. Notifications can display an alert, play a sound, or badge the app's icon.
You can read more about notification status here https://developer.apple.com/documentation/usernotifications
Apple recommend to user UserNotifications framework, So let’s get started. We will be seeing very simple and easy solution to get the notification status.
Step 1 − Firstly you need to import the UserNotifications framework
import UserNotifications
Step2 − Create an object of UNUserNotificationCenter.current()
let currentNotification = UNUserNotificationCenter.current()
Step 3 − Check status
currentNotification.getNotificationSettings(completionHandler: { (settings) in if settings.authorizationStatus == .notDetermined { // Notification permission is yet to be been asked go for it! } else if settings.authorizationStatus == .denied { // Notification permission was denied previously, go to settings & privacy to re-enable the permission } else if settings.authorizationStatus == .authorized { // Notification permission already granted. } })
Final Code
import UserNotifications let currentNotification = UNUserNotificationCenter.current() currentNotification.getNotificationSettings(completionHandler: { (settings) in if settings.authorizationStatus == .notDetermined { // Notification permission is yet to be been asked go for it! } else if settings.authorizationStatus == .denied { // Notification permission was denied previously, go to settings & privacy to re-enable the permission } else if settings.authorizationStatus == .authorized { // Notification permission already granted. } })
- Related Articles
- How to check which notifications are active in status bar in iOS?
- How to hide the status bar in a iOS App using Swift?
- How to check if Location Services are enabled in iOS App?
- How can I intercept the Status Bar Notifications in Android?
- How to check Location Manager is running or not in iOS App?
- How to get android notifications when the app was closed?
- What is the best iOS app for education?
- How to display count of notifications in Android App?
- How to manage your mobile notifications on YouTube App?
- How to integrate a facebook login in swift for iOS App?
- How to create scrollable TextView on iOS App?
- How to change status bar color to match app Android?
- How to display count of notifications in Android app launcher icon?
- How to create transparent Status Bar and Navigation Bar in iOS?
- How to display count of notifications in the Android App launcher using Kotlin?
