From 0f139bf20a8f2bc46a02e11f9ef1d8f51105a0f1 Mon Sep 17 00:00:00 2001 From: TJ Lambert Date: Mon, 18 Jul 2022 13:35:17 -0500 Subject: [PATCH 1/2] Reorder the enum to the correct order --- src/usernotifications.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/usernotifications.cs b/src/usernotifications.cs index 0f572db0849d..9fa53c7f9b7c 100644 --- a/src/usernotifications.cs +++ b/src/usernotifications.cs @@ -171,10 +171,10 @@ public enum UNShowPreviewsSetting : long [Native] public enum UNNotificationInterruptionLevel : long { - Active, - Critical, Passive, + Active, TimeSensitive, + Critical, } [iOS (10, 0)] From 484eed0bec100433b32e85a80232b43f6d5ebb4d Mon Sep 17 00:00:00 2001 From: TJ Lambert Date: Fri, 22 Jul 2022 17:04:54 -0500 Subject: [PATCH 2/2] Change order for xamcore 5 and add test --- src/usernotifications.cs | 19 +++++++++++ .../NotificationInterruptionLevel.cs | 32 +++++++++++++++++++ 2 files changed, 51 insertions(+) create mode 100644 tests/monotouch-test/UserNotifications/NotificationInterruptionLevel.cs diff --git a/src/usernotifications.cs b/src/usernotifications.cs index 9fa53c7f9b7c..116023f9bc61 100644 --- a/src/usernotifications.cs +++ b/src/usernotifications.cs @@ -171,10 +171,29 @@ public enum UNShowPreviewsSetting : long [Native] public enum UNNotificationInterruptionLevel : long { +#if XAMCORE_5_0 Passive, Active, TimeSensitive, Critical, +#else + [Obsolete ("Use 'Active2'.")] + Active, + [Obsolete ("Use 'Critical2'.")] + Critical, + [Obsolete ("Use 'Passive2'.")] + Passive, + [Obsolete ("Use 'TimeSensitive2'.")] + TimeSensitive, +#endif // XAMCORE_5_0 + + // Additional enum values to fix reordering - to be at the end of the enum +#if !XAMCORE_5_0 + Active2 = Critical, + Critical2 = TimeSensitive, + Passive2 = Active, + TimeSensitive2 = Passive, +#endif // !XAMCORE_5_0 } [iOS (10, 0)] diff --git a/tests/monotouch-test/UserNotifications/NotificationInterruptionLevel.cs b/tests/monotouch-test/UserNotifications/NotificationInterruptionLevel.cs new file mode 100644 index 000000000000..e81de7474e13 --- /dev/null +++ b/tests/monotouch-test/UserNotifications/NotificationInterruptionLevel.cs @@ -0,0 +1,32 @@ +using System; +using NUnit.Framework; + +using Foundation; +using UserNotifications; + +namespace MonoTouchFixtures.UserNotifications { + + [TestFixture] + [Preserve (AllMembers = true)] + public class UNNotificationInterruptionLevelTest { + + [Test] + public void EnumTest () + { +#if !XAMCORE_5_0 + /* Apple Docs order these enum values as: + typedef NS_ENUM (NSUInteger, UNNotificationInterruptionLevel) + { + UNNotificationInterruptionLevelPassive, + UNNotificationInterruptionLevelActive, + UNNotificationInterruptionLevelTimeSensitive, + UNNotificationInterruptionLevelCritical, + } */ + Assert.AreEqual ( (int)UNNotificationInterruptionLevel.Passive2, 0); + Assert.AreEqual ( (int)UNNotificationInterruptionLevel.Active2, 1); + Assert.AreEqual ( (int)UNNotificationInterruptionLevel.TimeSensitive2, 2); + Assert.AreEqual ( (int)UNNotificationInterruptionLevel.Critical2, 3); +#endif + } + } +}