@@ -265,32 +265,9 @@ public HttpRequestMessage GenerateRequestDetails(PushSubscription subscription,
265
265
public void SendNotification ( PushSubscription subscription , string payload = null ,
266
266
Dictionary < string , object > options = null )
267
267
{
268
- SendNotification ( subscription , payload , options , CancellationToken . None ) ;
269
- }
270
-
271
-
272
- /// <summary>
273
- /// To send a push notification call this method with a subscription, optional payload and any options
274
- /// Will exception if unsuccessful
275
- /// </summary>
276
- /// <param name="subscription">The PushSubscription you wish to send the notification to.</param>
277
- /// <param name="payload">The payload you wish to send to the user</param>
278
- /// <param name="options">
279
- /// Options for the GCM API key and vapid keys can be passed in if they are unique for each
280
- /// notification.
281
- /// </param>
282
- /// <param name="cancellationToken">The cancellation token to cancel operation.</param>
283
- public void SendNotification ( PushSubscription subscription , string payload ,
284
- Dictionary < string , object > options , CancellationToken cancellationToken )
285
- {
286
- var request = GenerateRequestDetails ( subscription , payload , options ) ;
287
- var sendAsyncTask = HttpClient . SendAsync ( request , cancellationToken ) ;
288
- sendAsyncTask . Wait ( ) ;
289
-
290
- var response = sendAsyncTask . Result ;
291
-
292
- HandleResponse ( response , subscription ) ;
268
+ SendNotification ( subscription , payload , options ) ;
293
269
}
270
+
294
271
295
272
/// <summary>
296
273
/// To send a push notification call this method with a subscription, optional payload and any options
@@ -317,23 +294,9 @@ public void SendNotification(PushSubscription subscription, string payload, stri
317
294
var options = new Dictionary < string , object > { [ "gcmAPIKey" ] = gcmApiKey } ;
318
295
SendNotification ( subscription , payload , options ) ;
319
296
}
297
+
320
298
321
299
/// <summary>
322
- /// To send a push notification asynchronous call this method with a subscription, optional payload and any options
323
- /// Will exception if unsuccessful
324
- /// </summary>
325
- /// <param name="subscription">The PushSubscription you wish to send the notification to.</param>
326
- /// <param name="payload">The payload you wish to send to the user</param>
327
- /// <param name="options">
328
- /// Options for the GCM API key and vapid keys can be passed in if they are unique for each
329
- /// notification.
330
- /// </param>
331
- public Task SendNotificationAsync ( PushSubscription subscription , string payload = null ,
332
- Dictionary < string , object > options = null )
333
- {
334
- return SendNotificationAsync ( subscription , payload , options , CancellationToken . None ) ;
335
- }
336
-
337
300
/// To send a push notification asynchronous call this method with a subscription, optional payload and any options
338
301
/// Will exception if unsuccessful
339
302
/// </summary>
@@ -344,8 +307,8 @@ public Task SendNotificationAsync(PushSubscription subscription, string payload
344
307
/// notification.
345
308
/// </param>
346
309
/// <param name="cancellationToken">The cancellation token to cancel operation.</param>
347
- public async Task SendNotificationAsync ( PushSubscription subscription , string payload ,
348
- Dictionary < string , object > options , CancellationToken cancellationToken )
310
+ public async Task SendNotificationAsync ( PushSubscription subscription , string payload = null ,
311
+ Dictionary < string , object > options = null , CancellationToken cancellationToken = default )
349
312
{
350
313
var request = GenerateRequestDetails ( subscription , payload , options ) ;
351
314
var response = await HttpClient . SendAsync ( request , cancellationToken ) ;
@@ -360,11 +323,12 @@ public async Task SendNotificationAsync(PushSubscription subscription, string pa
360
323
/// <param name="subscription">The PushSubscription you wish to send the notification to.</param>
361
324
/// <param name="payload">The payload you wish to send to the user</param>
362
325
/// <param name="vapidDetails">The vapid details for the notification.</param>
326
+ /// <param name="cancellationToken"></param>
363
327
public async Task SendNotificationAsync ( PushSubscription subscription , string payload ,
364
- VapidDetails vapidDetails )
328
+ VapidDetails vapidDetails , CancellationToken cancellationToken = default )
365
329
{
366
330
var options = new Dictionary < string , object > { [ "vapidDetails" ] = vapidDetails } ;
367
- await SendNotificationAsync ( subscription , payload , options ) ;
331
+ await SendNotificationAsync ( subscription , payload , options , cancellationToken ) ;
368
332
}
369
333
370
334
/// <summary>
@@ -374,10 +338,11 @@ public async Task SendNotificationAsync(PushSubscription subscription, string pa
374
338
/// <param name="subscription">The PushSubscription you wish to send the notification to.</param>
375
339
/// <param name="payload">The payload you wish to send to the user</param>
376
340
/// <param name="gcmApiKey">The GCM API key</param>
377
- public async Task SendNotificationAsync ( PushSubscription subscription , string payload , string gcmApiKey )
341
+ /// <param name="cancellationToken"></param>
342
+ public async Task SendNotificationAsync ( PushSubscription subscription , string payload , string gcmApiKey , CancellationToken cancellationToken = default )
378
343
{
379
344
var options = new Dictionary < string , object > { [ "gcmAPIKey" ] = gcmApiKey } ;
380
- await SendNotificationAsync ( subscription , payload , options ) ;
345
+ await SendNotificationAsync ( subscription , payload , options , cancellationToken ) ;
381
346
}
382
347
383
348
/// <summary>
0 commit comments