简体   繁体   English

使用设备上的JavaScript向Azure Notification Hub注册

[英]Register with Azure Notification Hub using JavaScript on device

I am creating a PWA that I want to use Azure Notification Hub for Push Notifications 我正在创建要使用Azure Notification Hub进行推送通知的PWA

Reading the flow of registration for ANS, this document tells me that I must first obtain a PNS handle from the native service. 阅读ANS的注册流程,该文档告诉我,我必须首先从本机服务获取PNS句柄。 https://docs.microsoft.com/en-us/azure/notification-hubs/notification-hubs-push-notification-registration-management https://docs.microsoft.com/en-us/azure/notification-hubs/notification-hubs-push-notification-registration-management

The device first retrieves the PNS handle from the PNS, then registers with the notification hub directly 设备首先从PNS检索PNS句柄,然后直接在通知中心注册

Using JavaScript, I am able to retrieve the handle which looks like this... 使用JavaScript,我可以检索如下所示的句柄...

{"endpoint":" https://fcm.googleapis.com/fcm/send/ewOnb-xuHQM:APA91bH7FWNQ9h9RKnOGHvxfPaF3OSr6FbnofFnLcE-bf6LtSYeNcDrCPN7DmwpcrKolUYQCw5qYI2UGZfaUkrGr555hfMkoCMFEchq6_yIUoPyyCxtQsT5Y6Cgc_c2jYD-HoQnvnWJV ","expirationTime":null,"keys":{"p256dh":"BPYcgtxUvSYDNYn6EVuu1BmIAz2vTU-TLdYb6pTAMOHTyJE1t8JLdBw1LLTljp5JMbnZF_Lk1ZoCV6nAJTUbDac","auth":"7cZDn_upNP_9HKO2NYhMbA"}} { “端点”: “ https://fcm.googleapis.com/fcm/send/ewOnb-xuHQM:APA91bH7FWNQ9h9RKnOGHvxfPaF3OSr6FbnofFnLcE-bf6LtSYeNcDrCPN7DmwpcrKolUYQCw5qYI2UGZfaUkrGr555hfMkoCMFEchq6_yIUoPyyCxtQsT5Y6Cgc_c2jYD-HoQnvnWJV ”, “expirationTime”:空, “钥匙”:{ “p256dh”:“BPYcgtxUvSYDNYn6EVuu1BmIAz2vTU-TLdYb6pTAMOHTyJE1t8JLdBw1LLTljp5JMbnZF_Lk1ZoCV6nAJTUbDac ”, “身份验证”: “7cZDn_upNP_9HKO2NYhMbA”}}

Using the REST API for ANS, how do I pass this value (and which part) to register my device with the hub? 使用REST API for ANS,如何传递该值(以及哪一部分)以在集线器上注册我的设备? And am I able to do this through JavaScript (not node.js) rather than backend? 我可以通过JavaScript(而不是node.js)而不是后端来做到这一点吗?

Push notification service is meant to receive notifications on mobile devices. 推送通知服务旨在在移动设备上接收通知。 PNS handle simply means the Mobile Device Token that you receieve from APNS in case of Apple devices, GCM for android devices. PNS句柄简单地表示您从APNS接收的移动设备令牌(对于Apple设备),对于Android设备为GCM。 You use this Mobile device token as "Handle" in case of Azure Notification hubs. 如果是Azure通知中心,则可以将此移动设备令牌用作“句柄”。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM