{%hackmd @Airethz/Theme_GrayAndBlue_01 %} ## 參考文件 * [GitHub - .NET Client for Azure Notification Hubs](https://github.com/Azure/azure-notificationhubs-dotnet) ## 流程 > [color=#AF7AC5]Blazor Server Sample ### 1. 安裝套件 Microsoft.Azure.NotificationHubs ![](https://hackmd.io/_uploads/B1ygJAIFj.png) ### 2. 設定參數 1. NotificationHubName:Azure Notification Hubs名稱。 2. manageConnectionString:權限為「Manage」的連線字串。 ![](https://hackmd.io/_uploads/rJAdeCUFs.png) ### 3. C#建立訊息並傳送 ```csharp= async Task SendAsync() { string manageConnectionString = "連線字串"; string notificationHubName = "Hub名稱"; NotificationHubClient hub = NotificationHubClient.CreateClientFromConnectionString(manageConnectionString, notificationHubName); var jsonBody = "{\"notification\":{\"title\":\"Web通知\",\"body\":\"透過Web新增推播\"},\"data\":{}}"; var notification = new AppleNotification(jsonBody); NotificationOutcome outcome = await hub.SendFcmNativeNotificationAsync(jsonBody); } ```