@@ -132,7 +132,7 @@ private async Task<bool> UpdateSubscriberFcm(string id, string token, string fcm
132132 }
133133 }
134134
135- private async Task < bool > UpdateSubscriberApns ( string id , string token , string apnsId )
135+ private async Task < bool > UpdateSubscriberApns ( string id , string token , string apnsId , string fcmId )
136136 {
137137 try
138138 {
@@ -144,16 +144,36 @@ private async Task<bool> UpdateSubscriberApns(string id, string token, string ap
144144 request . Headers . Add ( "idempotency-key" , Guid . NewGuid ( ) . ToString ( ) ) ;
145145 request . Headers . Add ( "Authorization" , $ "ApiKey { ChatConfig . NovuSecretKey } ") ;
146146
147- var payload = new
147+ string jsonContent = string . Empty ;
148+ if ( ! string . IsNullOrWhiteSpace ( apnsId ) )
148149 {
149- providerId = "apns" ,
150- credentials = new
150+ var payload = new
151151 {
152- deviceTokens = new string [ ] { token }
153- } ,
154- integrationIdentifier = apnsId
155- } ;
156- string jsonContent = JsonConvert . SerializeObject ( payload , new JsonSerializerSettings { NullValueHandling = NullValueHandling . Ignore } ) ;
152+ providerId = "apns" ,
153+ credentials = new
154+ {
155+ deviceTokens = new string [ ] { token }
156+ } ,
157+ integrationIdentifier = apnsId
158+ } ;
159+
160+ jsonContent = JsonConvert . SerializeObject ( payload , new JsonSerializerSettings { NullValueHandling = NullValueHandling . Ignore } ) ;
161+ }
162+ else if ( ! string . IsNullOrWhiteSpace ( fcmId ) )
163+ {
164+ var payload = new
165+ {
166+ providerId = "fcm" ,
167+ credentials = new
168+ {
169+ deviceTokens = new string [ ] { token }
170+ } ,
171+ integrationIdentifier = fcmId
172+ } ;
173+
174+ jsonContent = JsonConvert . SerializeObject ( payload , new JsonSerializerSettings { NullValueHandling = NullValueHandling . Ignore } ) ;
175+ }
176+
157177
158178 request . Content = new StringContent ( jsonContent , Encoding . UTF8 , "application/json" ) ;
159179 HttpResponseMessage response = await client . SendAsync ( request ) ;
@@ -197,7 +217,7 @@ public async Task<bool> UpdateUserSubscriberFcm(string userId, string code, stri
197217
198218 public async Task < bool > UpdateUserSubscriberApns ( string userId , string code , string token )
199219 {
200- return await UpdateSubscriberApns ( $ "{ code } _User_{ userId } ", token , ChatConfig . NovuResponderApnsProviderId ) ;
220+ return await UpdateSubscriberApns ( $ "{ code } _User_{ userId } ", token , ChatConfig . NovuResponderApnsProviderId , null ) ;
201221 }
202222
203223 public async Task < bool > UpdateUnitSubscriberFcm ( int unitId , string code , string token )
@@ -207,7 +227,8 @@ public async Task<bool> UpdateUnitSubscriberFcm(int unitId, string code, string
207227
208228 public async Task < bool > UpdateUnitSubscriberApns ( int unitId , string code , string token )
209229 {
210- return await UpdateSubscriberApns ( $ "{ code } _Unit_{ unitId } ", token , ChatConfig . NovuUnitApnsProviderId ) ;
230+ //return await UpdateSubscriberApns($"{code}_Unit_{unitId}", token, ChatConfig.NovuUnitApnsProviderId);
231+ return await UpdateSubscriberApns ( $ "{ code } _Unit_{ unitId } ", token , null , ChatConfig . NovuUnitFcmProviderId ) ;
211232 }
212233
213234 private async Task < bool > SendNotification ( string title , string body , string recipientId , string eventCode ,
@@ -259,6 +280,19 @@ private async Task<bool> SendNotification(string title, string body, string reci
259280 type = type ,
260281 }
261282 } ,
283+ apns = new
284+ {
285+ badge = count ,
286+ sound = new
287+ {
288+ name = sound ,
289+ critical = channelName == "calls" ? 1 : 0 ,
290+ volume = 1.0f
291+ } ,
292+ type = type ,
293+ category = channelName ,
294+ eventCode = eventCode ,
295+ } ,
262296 } ,
263297 apns = new Dictionary < string , object >
264298 {
0 commit comments