0
0
iOS Swiftmobile~5 mins

Local notifications in iOS Swift - Cheat Sheet & Quick Revision

Choose your learning style9 modes available
Recall & Review
beginner
What is a local notification in iOS?
A local notification is a message that an app schedules and delivers on the same device to alert the user, even if the app is not running in the foreground.
Click to reveal answer
beginner
Which iOS framework is used to manage local notifications?
The UserNotifications framework is used to schedule and manage local notifications in iOS.
Click to reveal answer
beginner
What permission must an app request to show local notifications?
The app must request authorization from the user to display alerts, play sounds, or badge the app icon using UNUserNotificationCenter's requestAuthorization method.
Click to reveal answer
intermediate
How do you schedule a local notification to trigger after 5 seconds?
Create a UNTimeIntervalNotificationTrigger with a time interval of 5 seconds and set repeats to false, then add a UNNotificationRequest with this trigger to UNUserNotificationCenter.
Click to reveal answer
intermediate
What is the role of UNNotificationRequest in local notifications?
UNNotificationRequest represents the notification to be delivered. It includes an identifier, content (title, body, sound), and a trigger that defines when to deliver the notification.
Click to reveal answer
Which class do you use to request permission for local notifications in iOS?
AUNUserNotificationCenter
BUIApplication
CUNNotificationRequest
DUNNotificationContent
What does UNTimeIntervalNotificationTrigger do?
ACancels a notification
BTriggers a notification at a calendar date
CRequests notification permission
DTriggers a notification after a time interval
Which method schedules a local notification?
Aadd(_:withCompletionHandler:)
BrequestAuthorization(options:completionHandler:)
CremovePendingNotificationRequests(withIdentifiers:)
DgetNotificationSettings(completionHandler:)
What must you include in UNNotificationContent?
AOnly title
BTitle, body, sound
COnly sound
DOnly badge number
Can local notifications be delivered if the app is closed?
AOnly if the app is in background
BNo, app must be open
CYes, local notifications work even if the app is closed
DOnly if the app is running in foreground
Explain the steps to schedule a local notification in iOS.
Think about what you need before showing a notification and how to tell the system when to show it.
You got /5 concepts.
    Describe how you handle user permission for local notifications and why it is important.
    Consider privacy and user control over notifications.
    You got /4 concepts.