Send Push Notification to User Devices - ASP.net C#

Source Code Option 1: System.Net

  
using System.Net;

    public static string SendPushToUserDevices(string message, string destinationurl, string userid)
    {
        string strResponse = "0";
        string apikey = "YOUR-API-KEY";


        string URI = "http://send.pushnotificationapi.com/v1/push/send_by_userid";

        string myParameters = "api_key=" + apikey + "&msg_title=" + message + "&user_id="+userid+"&destination_url=" + destinationurl;



        using (WebClient wc = new WebClient())
        {
            wc.Headers[HttpRequestHeader.ContentType] = "application/x-www-form-urlencoded";
            strResponse = wc.UploadString(URI, myParameters);


        }

        return strResponse;
    }
 

Source Code Option 2: RestSharp

  

var client = new RestClient("https://send.pushnotificationapi.com/v1/push/send_by_userid");
var request = new RestRequest(Method.POST);
request.AddHeader("cache-control", "no-cache");
request.AddHeader("content-type", "application/x-www-form-urlencoded");
request.AddParameter("application/x-www-form-urlencoded", "api_key=YOUR-API-KEY&user_id=YOUR-CUSTOM-USER-ID&msg_title=test%20message&destination_url=https%3A%2F%2Fpushnotificationapi.com", ParameterType.RequestBody);
IRestResponse response = client.Execute(request);