0

我創建了一個支持asp.net的web表單成功發送所有註冊設備的通知,但我厭倦了發送鏈接,例如我需要發送一個推送通知包括一個鏈接當用戶觸摸通知重定向到手機瀏覽器並打開鏈接。在Azure中使用推送通知發送鏈接for Andriod

private static async void SendNotificationAsync() 
     { 
      NotificationHubClient hub = NotificationHubClient 
       .CreateClientFromConnectionString("<Here is my endpoint >", "<hub name>"); 

      await hub.SendGcmNativeNotificationAsync("{ \"data\" : {\"message\":\"Hello Users \"}}"); 

     } 

回答

0

根據我的經驗,我們可以使用自定義的json格式,並在接收端將該字符串轉換爲url。例如,下面是完整的JSON有效載荷與定製的「web_link」包含URL關鍵的樣本:

{"data": "{\"message\":\"xxxx\",\"web_link\":\"https://www.example.com\"}"} 

然後我們可以覆蓋的onMessage函數來創建通知,我們也可以得到更詳細的信息Azure document

+0

尊敬的Tom Sun,當我從Azure Portal發送它時顯示錯誤通知 未能發送測試消息。錯誤:{「readyState」:4,「responseText」:「{\」error \「:{\」message \「:\」Bad Request \「,\」code \「:\」BadRequest \「}}」 「responseJSON」:{「error」:{「message」:「Bad Request」,「code」:「BadRequest」}},「status」:400,「statusText」:「Bad Request」}。 無法發送測試消息。錯誤:{「readyState」:4,「responseText」:「{\」error \「:{\」message \「:\」Bad Request \「,\」code \「:\」BadRequest \「}}」 「responseJSON」:{「error」:{「message」:「Bad Request」,「code」:「BadRequest」}},「status」:400,「statusText」:「Bad Request」}。 相關事件 –

+0

請嘗試在自定義格式的郵件中包含網址。例如:'{「data」:「{\」message \「:\」xxxx - url \「}」}'。我也upldate json文件 –

+0

我想發送一個鏈接,當用戶在移動設備的Web瀏覽器中打開鏈接時觸摸 –

相關問題