0

I have created a backed in asp.net web-forms successful send a notification for all registered devices but I tired to send a link for example I need to send one push notification include a link When user touch on the notification redirect to mobile browser and open the link.

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

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

        }
Cœur
  • 37,241
  • 25
  • 195
  • 267
Rebin Qadir
  • 291
  • 4
  • 12

1 Answers1

0

Based on my experience, we could use custom json format and at receiver end convert that string into url. For example,Here’s a sample of the complete JSON payload with a custom "web_link" key containing the URL:

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

Then we could override the OnMessage function to create Notification, we also could get more detail info from the Azure document.

Tom Sun - MSFT
  • 24,161
  • 3
  • 30
  • 47
  • Dear Tom Sun, when I send it from Azure Portal display Error notification Failed to send test message. Error: {"readyState":4,"responseText":"{\"error\":{\"message\":\"Bad Request\",\"code\":\"BadRequest\"}}","responseJSON":{"error":{"message":"Bad Request","code":"BadRequest"}},"status":400,"statusText":"Bad Request"}. Failed to send test message. Error: {"readyState":4,"responseText":"{\"error\":{\"message\":\"Bad Request\",\"code\":\"BadRequest\"}}","responseJSON":{"error":{"message":"Bad Request","code":"BadRequest"}},"status":400,"statusText":"Bad Request"}. Related events – Rebin Qadir Aug 16 '17 at 08:21
  • Please have a try to include the url in the message with customized format. example: `{"data": "{\"message\":\"xxxx--url\"}"}`. I also upldate the json file – Tom Sun - MSFT Aug 16 '17 at 08:29
  • I want to send a link when user touch on the link open in mobile device web browser – Rebin Qadir Aug 16 '17 at 08:37
  • Sorry, I am not an expert on mobile, but I found another [SO thread](https://stackoverflow.com/questions/36623497/how-to-pass-a-url-link-in-notification-and-on-click-it-should-get-open-in-webvi) refer to this. Hope it is useful. – Tom Sun - MSFT Aug 16 '17 at 08:41
  • me too no problem I appreciate you answer Tom Sun. – Rebin Qadir Aug 16 '17 at 08:44