[Bug]: Crash tapping local notification on iOS earlier than 16 when accessing FilterCriteria
johngraumann opened this issue · comments
Component/Nuget
Notifications (Shiny.Notifications)
What operating system(s) are effected?
- iOS (13+ supported)
- Mac Catalyst
- Android (8+ supported)
- Windows (.NET 7 Target - only Core is currently supported, BLE is coming)
Version(s) of Operation Systems
iOS 15.8
Hosting Model
- MAUI
- Native/Classic Xamarin
- Manual
Steps To Reproduce
- Create a basic MAUI application for iOS and register a local notification delegate builder.Services.AddNotifications()
- Display a local notification INotificationManager.Send("Hello", "World").
- With the app in the foreground, pull down the system tray and tap the notification and choose "Open".
Expected Behavior
INotificationDelegate.OnEntry will be called in my local notification delegate.
Actual Behavior
The application crashes with an 'ObjCRuntime.ObjCException: Objective-C exception thrown. Name: NSInvalidArgumentException Reason: -[UNNotificationContent filterCriteria]: unrecognized selector sent to instance 0x2823d3200' error.
It looks like https://developer.apple.com/documentation/usernotifications/unmutablenotificationcontent/3930024-filtercriteria is not available until iOS 16 but is currently inside a check for iOS 14 or greater.
Exception or Log output
(ObjCRuntime.ObjCException)
at UserNotifications.UNNotificationContent.get_FilterCriteria() in /Users/builder/azdo/_work/1/s/xamarin-macios/src/build/dotnet/ios/generated-sources/UserNotifications/UNNotificationContent.g.cs:line 236
at Shiny.Notifications.ApplePlatformExtensions.FromNative(UNNotificationRequest native)
at Shiny.Notifications.ApplePlatformExtensions.FromNative(UNNotificationResponse native)
at Shiny.Notifications.NotificationManager.OnDidReceiveNotificationResponse(UNNotificationResponse response, Action completionHandler)
Code Sample
https://github.com/johngraumann/ShinyLocalNotification
Code of Conduct
- I have supplied a reproducible sample that is NOT FROM THE SHINY SAMPLES!
- I am a Sponsor OR I am using the LATEST stable/beta version from nuget (v3.0 stable - ALPHAS are not taking issues - Sponsors can still send v2 issues)
- I am Sponsor OR My GitHub account is 30+ days old
- I understand that if I am checking these boxes and I am not actually following what they are saying, I will be removed from this repository!
FilterCriteria is also accessed inside of an iOS 14 check here: https://github.com/shinyorg/shiny/blob/dev/src/Shiny.Notifications/Platforms/Apple/NotificationManager.cs#L175
Thank for the detailed report. This will be fixed as part of 3.2.2 in the next couple of days.