搜尋 Mozilla 技術支援網站

防止技術支援詐騙。我們絕對不會要求您撥打電話或發送簡訊,或是提供個人資訊。請用「回報濫用」功能回報可疑的行為。

Learn More

Web Push C# server example

  • 1 回覆
  • 1 有這個問題
  • 21 次檢視
  • 最近回覆由 Paul

more options

With Firefox 44+ now supporting the Push API (and that Edge developers have also committed to supporting it) does someone have some example C# code that would be able to encrypt then push a payload-bearing message to my Firefox Web App?

If you are unfamiliar with what is required then basically, once your Javascript client has registered its Service Worker it can then register with the PushManager flagging its willingness to accept Notifications. You then (Firefox only at the moment Chrome is fixing a bug) call getKey() on your subscription object and send the result along with your subscription .endpoint to your server so that your server logic knows that you have subscribed. (E.g. https://github.com/chrisdavidmills/push-api-demo/blob/gh-pages/main.js#L19 )

Ok, that's all on the browser and not particularly relevant to the C# code. What I'mm looking for is C# that will take the public key DH 'p256dh' and use it to encrypt the response message (avec payload) that will be POSTed back to the browser.

The only server example I have is Javascript NODE.js etc stuff: - https://github.com/marco-c/web-push/blob/master/index.js if you look at the encrypt() function or, for a complete picture the sendNotification() function, you will see the encryption and the pushRequest I'm looking for.

Is there a class(es) that handles this for us in .NET C#

With Firefox 44+ now supporting the Push API (and that Edge developers have also committed to supporting it) does someone have some example C# code that would be able to encrypt then push a payload-bearing message to my Firefox Web App? If you are unfamiliar with what is required then basically, once your Javascript client has registered its Service Worker it can then register with the PushManager flagging its willingness to accept Notifications. You then (Firefox only at the moment Chrome is fixing a bug) call getKey() on your subscription object and send the result along with your subscription .endpoint to your server so that your server logic knows that you have subscribed. (E.g. https://github.com/chrisdavidmills/push-api-demo/blob/gh-pages/main.js#L19 ) Ok, that's all on the browser and not particularly relevant to the C# code. What I'mm looking for is C# that will take the public key DH 'p256dh' and use it to encrypt the response message (avec payload) that will be POSTed back to the browser. The only server example I have is Javascript NODE.js etc stuff: - https://github.com/marco-c/web-push/blob/master/index.js if you look at the encrypt() function or, for a complete picture the sendNotification() function, you will see the encryption and the pushRequest I'm looking for. Is there a class(es) that handles this for us in .NET C#

所有回覆 (1)

more options

Hi

Thank you for your question, but this forum is more for the answering of front end user issues rather than programming support.

I recommend that you ask your question in the Stack Overflow community.