File tree Expand file tree Collapse file tree 2 files changed +16
-3
lines changed Expand file tree Collapse file tree 2 files changed +16
-3
lines changed Original file line number Diff line number Diff line change @@ -122,7 +122,15 @@ - (void)userNotificationCenter:(UNUserNotificationCenter *)center
122122 NSLog (@" %@ " , userInfo);
123123
124124 // Change this to your preferred presentation option
125- completionHandler (UNNotificationPresentationOptionBadge | UNNotificationPresentationOptionAlert );
125+ // Note: UNNotificationPresentationOptionAlert has been deprecated.
126+ if (@available (iOS 14.0 , *)) {
127+ completionHandler (UNNotificationPresentationOptionList |
128+ UNNotificationPresentationOptionBanner |
129+ UNNotificationPresentationOptionSound );
130+ } else {
131+ completionHandler (UNNotificationPresentationOptionAlert |
132+ UNNotificationPresentationOptionSound );
133+ }
126134}
127135
128136// Handle notification messages after display notification is tapped by the user.
Original file line number Diff line number Diff line change @@ -119,8 +119,13 @@ extension AppDelegate: UNUserNotificationCenterDelegate {
119119 print ( userInfo)
120120
121121 // Change this to your preferred presentation option
122- return [ [ . alert, . sound] ]
123- }
122+ // Note: UNNotificationPresentationOptions.alert has been deprecated.
123+ if #available( iOS 14 . 0 , * ) {
124+ return [ . list, . banner, . sound]
125+ } else {
126+ return [ . alert, . sound]
127+ }
128+ }
124129
125130 func userNotificationCenter( _ center: UNUserNotificationCenter ,
126131 didReceive response: UNNotificationResponse ) async {
You can’t perform that action at this time.
0 commit comments