FazBrowse GitHub Viewer
|
Trending
|
URL:
|
Home
Tools:
[Download Repo ZIP]
[View Raw Code]
[Original HTTPS Page]
webpush-csharp/Examples/WebPushMessage.cs at main · closureOSS/webpush-csharp · GitHub
Uh oh!
There was an error while loading.
Please reload this page
.
closureOSS
/
webpush-csharp
Public
forked from
web-push-libs/web-push-csharp
Notifications
You must be signed in to change notification settings
Fork
0
Star
2
Code
Issues
0
Pull requests
0
Actions
Security and quality
0
Insights
Additional navigation options
Code
Issues
Pull requests
Actions
Security and quality
Insights
Expand file tree
Breadcrumbs
webpush-csharp
/
Examples
/
WebPushMessage.cs
Copy path
More file actions
More file actions
Latest commit
History
History
History
30 lines (26 loc) · 1001 Bytes
Breadcrumbs
webpush-csharp
/
Examples
/
WebPushMessage.cs
Copy path
File metadata and controls
30 lines (26 loc) · 1001 Bytes
Raw
Copy raw file
Download raw file
Open symbols panel
Edit and raw actions
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
#!/usr/bin/env dotnet
#
:
package
ClosureOSS
.
WebPush@
2.5
.3
using
WebPush
;
var
vapidKeys
=
VapidHelper
.
GenerateVapidKeys
(
)
;
vapidKeys
.
Subject
=
@"mailto:user@example.net"
;
// example keys
var
p256dh
=
@"BIwCq8tz028CFq9YFQ56kipZ633EK628l4-u6FcPHTGkS_cqTsV-9MRRAGEu56UmfXQ-8lIg7QXgUTFmzedzMHM"
;
var
auth
=
@"eSZCfw7d6bXE0erlgnLe_Q"
;
var
webPushClient
=
new
WebPushClient
(
)
;
var
subscription
=
new
PushSubscription
(
"https://server.example.com/notify/Avv3mSO..."
,
p256dh
,
auth
)
;
var
options
=
new
WebPushOptions
{
VapidDetails
=
vapidKeys
,
Topic
=
"Example"
,
}
;
var
message
=
webPushClient
.
GenerateRequestDetails
(
subscription
,
"A payload"
,
options
)
;
Console
.
WriteLine
(
$
"
{
message
.
Method
}
{
message
.
RequestUri
}
"
)
;
Console
.
WriteLine
(
)
;
foreach
(
var
header
in
message
.
Headers
)
{
foreach
(
var
value
in
header
.
Value
)
{
Console
.
WriteLine
(
$
"
{
header
.
Key
}
:
{
value
}
"
)
;
}
}
Console
.
WriteLine
(
)
;
Console
.
WriteLine
(
$
"
{
Convert
.
ToBase64String
(
await
message
.
Content
!
.
ReadAsByteArrayAsync
(
)
)
}
"
)
;
Back
|
FazBrowse Home
|
New Git URL