As iOS 14 is released, ‘alert’ in UNNotificationPresentationOptions has been deprecated. But New 2 UNNotificationPresentationOptions added
Apple Official Overview don’t exist yet, so I tested it myself
Below is the source that gets Push Notification from AppDelegate.
- didFinishLaunchingWithOptions - call requestAuthorization Request permission to the user.
- call registerForRemoteNotifications to register APNS Push Token
- in UNUserNotificationCenterDelegate, didRegisterForRemoteNotificationsWithDeviceToken function. get Push Token
- This function determines whether or not the app is push notification exposed when in the foreground.
Set handler values (list, banner) in userNotificationCenter willPresent.
Check!
As of Xcode 11.4, you can also perform push notification tests on the simulator. The simulator has been tested for push notifications.
When handler is set to ‘banner’,
It works like the ‘alert’ that was used previously.
When handler is set to ‘list’,
It doesn’t work when the app is in the Foreground, but only when it is in the Background.
Conclusion
The existing ‘alert’ option was divided into two functions.
If you don’t want to expose push notifications when your app is in Foregorund, you can branched directly into the code.
But, Starting with iOS14 or later, the ‘list’ option takes care of it.