There is a .alert
in the push notification display options (ʻUNNotificationPresentationOptions), but it has been deprecated until iOS 14. Instead, it is divided into
.banner and
.list`, and I will introduce them because I investigated their behavior.
It is as shown in the table below.
In .alert
, notifications are sent to both the banner and notification center, but from iOS 14, you can use .banner
and .list
to make notifications come to only one of them.
UNNotificationPresentationOptions | banner | Notification Center |
---|---|---|
.alert |
||
.banner |
||
.list |
If iOS 13 or earlier is still supported, it is better to branch by OS version.
AppDelegate.swift
extension AppDelegate: UNUserNotificationCenterDelegate {
func userNotificationCenter(
_ center: UNUserNotificationCenter,
willPresent notification: UNNotification,
withCompletionHandler completionHandler: @escaping (UNNotificationPresentationOptions) -> Void) {
if #available(iOS 14.0, *) {
completionHandler([[.banner, .list, .sound]])
} else {
completionHandler([[.alert, .sound]])
}
}
}
The following articles helped me send push notifications to the iOS simulator. https://qiita.com/koogawa/items/85c0dd0abd2f1970c5fc
Thanks to this article, I was able to easily send push notifications and try them out.
From iOS 14, we found that we had more control over the display of notifications.
By specifying only .list
, you can use it like Android silent notification, and it seems convenient to master it.
If you find it useful, please let us know in the comments: relaxed:
.banner
and .list
are not "No overview available.", I didn't have to write this article.