1- using System . Text ;
2- using Newtonsoft . Json ;
1+ using Newtonsoft . Json ;
32using Newtonsoft . Json . Linq ;
43using Novu . Domain . Models . Subscribers ;
4+ using RabbitMQ . Client ;
55using Resgrid . Config ;
66using Resgrid . Framework ;
77using Resgrid . Model ;
88using Resgrid . Model . Providers ;
99using Resgrid . Providers . Bus . Models ;
10+ using System . Text ;
1011
1112
1213namespace Resgrid . Providers . Messaging
@@ -196,7 +197,7 @@ public async Task<bool> UpdateUserSubscriberFcm(string userId, string code, stri
196197
197198 public async Task < bool > UpdateUserSubscriberApns ( string userId , string code , string token )
198199 {
199- return await UpdateSubscriberApns ( $ "{ code } _User_{ userId } ", token , ChatConfig . NovuUnitApnsProviderId ) ;
200+ return await UpdateSubscriberApns ( $ "{ code } _User_{ userId } ", token , ChatConfig . NovuResponderApnsProviderId ) ;
200201 }
201202
202203 public async Task < bool > UpdateUnitSubscriberFcm ( int unitId , string code , string token )
@@ -221,7 +222,7 @@ private async Task<bool> SendNotification(string title, string body, string reci
221222 httpClient . DefaultRequestHeaders . Add ( "Authorization" , $ "ApiKey { ChatConfig . NovuSecretKey } ") ;
222223 httpClient . DefaultRequestHeaders . Add ( "idempotency-key" , Guid . NewGuid ( ) . ToString ( ) ) ;
223224
224- string androidChannelName = GetAndroidChannelName ( eventCode ) ;
225+ string channelName = GetAndroidChannelName ( eventCode ) ;
225226 // Build request payload
226227 var payload = new
227228 {
@@ -230,24 +231,21 @@ private async Task<bool> SendNotification(string title, string body, string reci
230231 {
231232 subject = title ,
232233 body = body ,
233- //inAppAvatar
234- //arrowImage
235-
236234 } ,
237235 overrides = new
238236 {
239237 fcm = new
240238 {
241239 android = new
242240 {
243- priority = androidChannelName == "calls" ? "high" : "normal" ,
241+ priority = channelName == "calls" ? "high" : "normal" ,
244242 notification = new
245243 {
246244 channelId = type ,
247245 defaultSound = true ,
248- sticky = androidChannelName == "calls" ? true : false ,
246+ sticky = channelName == "calls" ? true : false ,
249247 //priority = androidChannelName == "calls" ? 5 : 3,
250- priority = androidChannelName == "calls" ? "max " : "default " ,
248+ notification_priority = channelName == "calls" ? "PRIORITY_MAX " : "PRIORITY_DEFAULT " ,
251249 } ,
252250 data = new
253251 {
@@ -256,29 +254,35 @@ private async Task<bool> SendNotification(string title, string body, string reci
256254 eventCode = eventCode ,
257255 type = type
258256 }
259- } //,
260- //data = new
261- //{
262- // title = title,
263- // message = body,
264- // eventCode = eventCode,
265- // type = type
266- //}
267- }
257+ } ,
258+ } ,
259+ apns = new
260+ {
261+ badge = count ,
262+ sound = new
263+ {
264+ name = GetSoundFileNameFromType ( Platforms . iOS , type ) ,
265+ critical = channelName == "calls" ? 1 : 0 ,
266+ volume = 1.0f
267+ } ,
268+ type = type ,
269+ category = channelName ,
270+ eventCode = eventCode ,
271+ } ,
272+
268273 } ,
269274 to = new [ ] { new
270275 {
271276 subscriberId = recipientId
272277 } } ,
273278 } ;
274279
280+ var payloadString = JsonConvert . SerializeObject ( payload ) ;
275281 var content = new StringContent (
276- JsonConvert . SerializeObject ( payload , new JsonSerializerSettings { NullValueHandling = NullValueHandling . Ignore } ) ,
282+ payloadString ,
277283 Encoding . UTF8 ,
278284 "application/json" ) ;
279285
280-
281-
282286 var result = await httpClient . PostAsync ( "v1/events/trigger" , content ) ;
283287
284288 return result . IsSuccessStatusCode ;
@@ -317,53 +321,31 @@ private string GetSoundFileNameFromType(Platforms platform, string type)
317321 {
318322 if ( type == ( ( int ) PushSoundTypes . CallEmergency ) . ToString ( ) )
319323 {
320- if ( platform == Platforms . iOS )
321- return "callemergency.caf" ;
322-
323324 return "callemergency.wav" ;
324325 }
325326 else if ( type == ( ( int ) PushSoundTypes . CallHigh ) . ToString ( ) )
326-
327327 {
328- if ( platform == Platforms . iOS )
329- return "callhigh.caf" ;
330-
331- return "callhigh.mp3" ;
328+ return "callhigh.wav" ;
332329 }
333330 else if ( type == ( ( int ) PushSoundTypes . CallMedium ) . ToString ( ) )
334331 {
335- if ( platform == Platforms . iOS )
336- return "callmedium.caf" ;
337-
338- return "callmedium.mp3" ;
332+ return "callmedium.wav" ;
339333 }
340334 else if ( type == ( ( int ) PushSoundTypes . CallLow ) . ToString ( ) )
341335 {
342- if ( platform == Platforms . iOS )
343- return "calllow.caf" ;
344-
345- return "calllow.mp3" ;
336+ return "calllow.wav" ;
346337 }
347338 else if ( type == ( ( int ) PushSoundTypes . Notifiation ) . ToString ( ) )
348339 {
349- if ( platform == Platforms . iOS )
350- return "notification.caf" ;
351-
352- return "notification.mp3" ;
340+ return "notification.wav" ;
353341 }
354342 else if ( type == ( ( int ) PushSoundTypes . Message ) . ToString ( ) )
355343 {
356- if ( platform == Platforms . iOS )
357- return "message.caf" ;
358-
359- return "message.mp3" ;
344+ return "message.wav" ;
360345 }
361346 else
362347 {
363- if ( platform == Platforms . iOS )
364- return $ "{ type } .caf";
365-
366- return $ "{ type } .mp3";
348+ return $ "{ type } .wav";
367349 }
368350 }
369351
0 commit comments