Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 669387
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 14, 20262026-05-14T00:08:45+00:00 2026-05-14T00:08:45+00:00

im want to send notification from my server side (c#) via urbanairship api is

  • 0

i”m want to send notification from my server side (c#) via urbanairship api

is there any example in c# how to do it?

thanks

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-14T00:08:45+00:00Added an answer on May 14, 2026 at 12:08 am

    Basically…

    using System;
    using System.IO;
    using System.Net;
    using System.Text;
    
    namespace Examples.System.Net
    {
        public class WebRequestPostExample
        {
            public static void Main ()
            {
                // Create a request using a URL that can receive a post. 
                WebRequest request = WebRequest.Create ("https://go.urbanairship.com/api/push/");
                // Set the Method property of the request to POST.
                request.Method = "POST";
    
                // Create POST data and convert it to a byte array. 
    

    broken out to multiple lines so you can read it

                string postData = "{
        "device_tokens": [
            "some device token",
            "another device token"
        ],
        "aliases": [
            "user1",
            "user2"
        ],
        "tags": [
            "tag1",
            "tag2"
        ],
        "schedule_for": [
            "2010-07-27 22:48:00",
            "2010-07-28 22:48:00"
        ],
        "exclude_tokens": [
            "device token you want to skip",
            "another device token you want to skip"
        ],
        "aps": {
             "badge": 10,
             "alert": "Hello from Urban Airship!",
             "sound": "cat.caf"
        }
    }";
    

    and then

                byte[] byteArray = Encoding.UTF8.GetBytes (postData);
                // Set the ContentType property of the WebRequest.
                request.ContentType = "application/json";
                // Set the ContentLength property of the WebRequest.
                request.ContentLength = byteArray.Length;
    
                //Do a http basic authentication somehow
                string username = "<application key from urban airship>";
                string password = "<master secret from urban airship>"; 
                string usernamePassword = username + ":" + password;
                CredentialCache mycache = new CredentialCache();
                mycache.Add( new Uri( "https://go.urbanairship.com/api/push/" ), "Basic", new NetworkCredential( username, password ) );
                request.Credentials = mycache;
                request.Headers.Add( "Authorization", "Basic " + Convert.ToBase64String( new ASCIIEncoding().GetBytes( usernamePassword ) ) );
    
                // Get the request stream.
                Stream dataStream = request.GetRequestStream ();
                // Write the data to the request stream.
                dataStream.Write (byteArray, 0, byteArray.Length);
                // Close the Stream object.
                dataStream.Close ();
                // Get the response.
                WebResponse response = request.GetResponse ();
                // Display the status.
                Console.WriteLine (((HttpWebResponse)response).StatusDescription);
                // Get the stream containing content returned by the server.
                dataStream = response.GetResponseStream ();
                // Open the stream using a StreamReader for easy access.
                StreamReader reader = new StreamReader (dataStream);
                // Read the content.
                string responseFromServer = reader.ReadToEnd ();
                // Display the content.
                Console.WriteLine (responseFromServer);
                // Clean up the streams.
                reader.Close ();
                dataStream.Close ();
                response.Close ();
            }
        }
    }
    

    See api docs, msdn and here for more on https

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I want to send email from a Ruby application. Is there a call in
If I want to send mail not via SMTP, but rather via sendmail, is
I just want to send SMS from my web application in PHP. Can anyone
i want to know that when we want to use push notification service.From where
I would like to send a push notification to the user but I want
For testing purposes I want send mail to my localhost user account rather than
I want so send every week an update by email. But Im afraid that
I want to send an array constructed in javascript with the selected values of
I want to send a message to a thread and handle it in the
I want to send some strings in a list in a POST call. eg:

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.