-
Notifications
You must be signed in to change notification settings - Fork 106
/
Copy pathIWebPushClient.cs
117 lines (107 loc) · 6.41 KB
/
IWebPushClient.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
using System;
using System.Collections.Generic;
using System.Net.Http;
using System.Threading;
using System.Threading.Tasks;
namespace WebPush
{
public interface IWebPushClient : IDisposable
{
/// <summary>
/// When sending messages to a GCM endpoint you need to set the GCM API key
/// by either calling setGcmApiKey() or passing in the API key as an option
/// to sendNotification()
/// </summary>
/// <param name="gcmApiKey">The API key to send with the GCM request.</param>
void SetGcmApiKey(string gcmApiKey);
/// <summary>
/// When marking requests where you want to define VAPID details, call this method
/// before sendNotifications() or pass in the details and options to
/// sendNotification.
/// </summary>
/// <param name="vapidDetails"></param>
void SetVapidDetails(VapidDetails vapidDetails);
/// <summary>
/// When marking requests where you want to define VAPID details, call this method
/// before sendNotifications() or pass in the details and options to
/// sendNotification.
/// </summary>
/// <param name="subject">This must be either a URL or a 'mailto:' address</param>
/// <param name="publicKey">The public VAPID key as a base64 encoded string</param>
/// <param name="privateKey">The private VAPID key as a base64 encoded string</param>
void SetVapidDetails(string subject, string publicKey, string privateKey);
/// <summary>
/// To get a request without sending a push notification call this method.
/// This method will throw an ArgumentException if there is an issue with the input.
/// </summary>
/// <param name="subscription">The PushSubscription you wish to send the notification to.</param>
/// <param name="payload">The payload you wish to send to the user</param>
/// <param name="options">
/// Options for the GCM API key and vapid keys can be passed in if they are unique for each
/// notification.
/// </param>
/// <returns>A HttpRequestMessage object that can be sent.</returns>
HttpRequestMessage GenerateRequestDetails(PushSubscription subscription, string payload,
Dictionary<string, object> options = null);
/// <summary>
/// To send a push notification call this method with a subscription, optional payload and any options
/// Will exception if unsuccessful
/// </summary>
/// <param name="subscription">The PushSubscription you wish to send the notification to.</param>
/// <param name="payload">The payload you wish to send to the user</param>
/// <param name="options">
/// Options for the GCM API key and vapid keys can be passed in if they are unique for each
/// notification.
/// </param>
void SendNotification(PushSubscription subscription, string payload = null,
Dictionary<string, object> options = null);
/// <summary>
/// To send a push notification call this method with a subscription, optional payload and any options
/// Will exception if unsuccessful
/// </summary>
/// <param name="subscription">The PushSubscription you wish to send the notification to.</param>
/// <param name="payload">The payload you wish to send to the user</param>
/// <param name="vapidDetails">The vapid details for the notification.</param>
void SendNotification(PushSubscription subscription, string payload, VapidDetails vapidDetails);
/// <summary>
/// To send a push notification call this method with a subscription, optional payload and any options
/// Will exception if unsuccessful
/// </summary>
/// <param name="subscription">The PushSubscription you wish to send the notification to.</param>
/// <param name="payload">The payload you wish to send to the user</param>
/// <param name="gcmApiKey">The GCM API key</param>
void SendNotification(PushSubscription subscription, string payload, string gcmApiKey);
/// <summary>
/// To send a push notification asynchronous call this method with a subscription, optional payload and any options
/// Will exception if unsuccessful
/// </summary>
/// <param name="subscription">The PushSubscription you wish to send the notification to.</param>
/// <param name="payload">The payload you wish to send to the user</param>
/// <param name="options">
/// Options for the GCM API key and vapid keys can be passed in if they are unique for each
/// notification.
/// </param>
/// <param name="cancellationToken">The cancellation token to cancel operation.</param>
Task SendNotificationAsync(PushSubscription subscription, string payload = null,
Dictionary<string, object> options = null, CancellationToken cancellationToken=default);
/// <summary>
/// To send a push notification asynchronous call this method with a subscription, optional payload and any options
/// Will exception if unsuccessful
/// </summary>
/// <param name="subscription">The PushSubscription you wish to send the notification to.</param>
/// <param name="payload">The payload you wish to send to the user</param>
/// <param name="vapidDetails">The vapid details for the notification.</param>
/// <param name="cancellationToken"></param>
Task SendNotificationAsync(PushSubscription subscription, string payload,
VapidDetails vapidDetails, CancellationToken cancellationToken=default);
/// <summary>
/// To send a push notification asynchronous call this method with a subscription, optional payload and any options
/// Will exception if unsuccessful
/// </summary>
/// <param name="subscription">The PushSubscription you wish to send the notification to.</param>
/// <param name="payload">The payload you wish to send to the user</param>
/// <param name="gcmApiKey">The GCM API key</param>
/// <param name="cancellationToken"></param>
Task SendNotificationAsync(PushSubscription subscription, string payload, string gcmApiKey, CancellationToken cancellationToken=default);
}
}