From e87254a527d02ba9606328a93dfd7170ce5ffafa Mon Sep 17 00:00:00 2001 From: Shawn Jackson Date: Fri, 4 Oct 2024 22:31:38 -0700 Subject: [PATCH] CU-868a1kgf7 fixing iOS critical notification bug. --- Providers/Resgrid.Providers.Bus/Models/ApnsHeader.cs | 2 +- Providers/Resgrid.Providers.Bus/Models/ApnsSound.cs | 9 +++++++++ Providers/Resgrid.Providers.Bus/NotificationProvider.cs | 9 ++++++++- .../Resgrid.Providers.Bus/UnitNotificationProvider.cs | 9 ++++++++- 4 files changed, 26 insertions(+), 3 deletions(-) create mode 100644 Providers/Resgrid.Providers.Bus/Models/ApnsSound.cs diff --git a/Providers/Resgrid.Providers.Bus/Models/ApnsHeader.cs b/Providers/Resgrid.Providers.Bus/Models/ApnsHeader.cs index fb3d7fa1..92b1273f 100644 --- a/Providers/Resgrid.Providers.Bus/Models/ApnsHeader.cs +++ b/Providers/Resgrid.Providers.Bus/Models/ApnsHeader.cs @@ -8,6 +8,6 @@ public class ApnsHeader public ApnsAlert alert { get; set; } public string category { get; set; } public int badge { get; set; } - public string sound { get; set; } + public ApnsSound sound { get; set; } } } diff --git a/Providers/Resgrid.Providers.Bus/Models/ApnsSound.cs b/Providers/Resgrid.Providers.Bus/Models/ApnsSound.cs new file mode 100644 index 00000000..fe9ea12d --- /dev/null +++ b/Providers/Resgrid.Providers.Bus/Models/ApnsSound.cs @@ -0,0 +1,9 @@ +namespace Resgrid.Providers.Bus.Models +{ + public class ApnsSound + { + public float volume { get; set; } + public int critical { get; set; } + public string name { get; set; } + } +} diff --git a/Providers/Resgrid.Providers.Bus/NotificationProvider.cs b/Providers/Resgrid.Providers.Bus/NotificationProvider.cs index 70f75ea2..370a4a07 100644 --- a/Providers/Resgrid.Providers.Bus/NotificationProvider.cs +++ b/Providers/Resgrid.Providers.Bus/NotificationProvider.cs @@ -347,6 +347,8 @@ public async Task SendAppleNotification(string title, category = "chats"; else if (eventCode.ToLower().StartsWith("g")) // group chat category = "chats"; + else + category = "notifications"; var apnsPayload = new ApnsPayload { @@ -359,7 +361,12 @@ public async Task SendAppleNotification(string title, }, badge = count, category = category, - sound = GetSoundFileNameFromType(Platforms.iPhone, type) + sound = new ApnsSound + { + name = GetSoundFileNameFromType(Platforms.iPhone, type), + critical = category == "calls" ? 1 : 0, + volume = 1.0f + } }, eventCode = eventCode, type = type diff --git a/Providers/Resgrid.Providers.Bus/UnitNotificationProvider.cs b/Providers/Resgrid.Providers.Bus/UnitNotificationProvider.cs index dc2d21e6..3463fd6f 100644 --- a/Providers/Resgrid.Providers.Bus/UnitNotificationProvider.cs +++ b/Providers/Resgrid.Providers.Bus/UnitNotificationProvider.cs @@ -342,6 +342,8 @@ public async Task SendAppleNotification(string title, category = "chats"; else if (eventCode.ToLower().StartsWith("g")) // group chat category = "chats"; + else + category = "notifications"; var apnsPayload = new ApnsPayload { @@ -354,7 +356,12 @@ public async Task SendAppleNotification(string title, }, badge = count, category = category, - sound = GetSoundFileNameFromType(Platforms.iPhone, type, enableCustomSounds) + sound = new ApnsSound + { + name = GetSoundFileNameFromType(Platforms.iPhone, type, enableCustomSounds), + critical = category == "calls" ? 1 : 0, + volume = 1.0f + } }, eventCode = eventCode, type = type