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

  • SEARCH
  • Home
  • 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 9007563
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 16, 20262026-06-16T01:43:26+00:00 2026-06-16T01:43:26+00:00

I am trying to Notify the Device by the Push Notification I Received this

  • 0

I am trying to Notify the Device by the Push Notification

I Received this Response From THE GCM Server

{"multicast_id":8594338261894783737,"success":1,"failure":0,"canonical_ids":0,"results":[{"message_id":"0:1355822022916886%8ae6056ef9fd7ecd"}]}

But Still Not get the Notification

With Knowledge That –> "success":1

But I Think there is something Wrong Here –> "canonical_ids":0


This Is My Code …

 private string SendGCMNotification(string apiKey, string postData, string postDataContentType = "application/json")
 {
     ServicePointManager.ServerCertificateValidationCallback += new RemoteCertificateValidationCallback(ValidateServerCertificate);

     //
     //  MESSAGE CONTENT
     byte[] byteArray = Encoding.UTF8.GetBytes(postData);

     //
     //  CREATE REQUEST
     HttpWebRequest Request = (HttpWebRequest)WebRequest.Create("https://android.googleapis.com/gcm/send");
     Request.Method = "POST";
     Request.KeepAlive = false;
     Request.ContentType = postDataContentType;
     Request.Headers.Add(HttpRequestHeader.Authorization, string.Format("key={0}",apiKey));
     Request.ContentLength = byteArray.Length;

     Stream dataStream = Request.GetRequestStream();
     dataStream.Write(byteArray, 0, byteArray.Length);
     dataStream.Close();

     try
     {
         WebResponse Response = Request.GetResponse();
         HttpStatusCode ResponseCode = ((HttpWebResponse)Response).StatusCode;
         if (ResponseCode.Equals(HttpStatusCode.Unauthorized) || ResponseCode.Equals(HttpStatusCode.Forbidden))
         {
          Label1.Text = "Unauthorized - need new token";

         }
         else if (!ResponseCode.Equals(HttpStatusCode.OK))
         {
             Label1.Text = "Response from web service isn't OK";
         }

         StreamReader Reader = new StreamReader(Response.GetResponseStream());
         string responseLine = Reader.ReadToEnd();
         Reader.Close();

         return responseLine;
     }
     catch (Exception e)
     {
         return "error";
     }
    // return "error";
 }

and i call this method using

     string deviceId = "APA91bHomX3zb6Y87fb4GAjyj8zIaI-tt1n6ZFmgtmu16nmLW7ntwnOyv4BXMH7RzQWk3JrKdLjttJMxKzvpFd3Kmrid_RzsC3zR46GLJGiZKERXOSIR8fYReBEfz1f0G_FIm5bPttWUBDwz9jPuF2lS8RQh-0DKbw";
     string message = "some test message";
     string tickerText = "example test GCM";
     string contentTitle = "content title GCM";
     string postData =
     "{ \"registration_ids\": [ \"" + deviceId + "\" ], " +
       "\"data\": {\"tickerText\":\"" + tickerText + "\", " +
                  "\"contentTitle\":\"" + contentTitle + "\", " +
                  "\"message\": \"" + message + "\"}}";

     Label1.Text = SendGCMNotification("AIzaSyBEvtrtbbfy2-p2zS8Zi8DweZiRy8M-nZc", postData);

Thanks In Advance

  • 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-06-16T01:43:28+00:00Added an answer on June 16, 2026 at 1:43 am

    Take a look at the Response format in the GCM documentation: http://developer.android.com/google/gcm/gcm.html#response

    success     Number of messages that were processed without an error.
    

    What I understand that to mean is that GCM was able to process that message, it does not mean that the message was successfully sent to the device. (E.g. The device might be offline and will receive it later, but the message was successfully processed).

    “canonical_ids”:0 Does not mean that there was an error, it means that there were no devices that needed their ID’s updated. You can read more about canonical ID’s here: http://developer.android.com/google/gcm/adv.html#canonical

    On the server side, as long as the application is behaving well,
    everything should work normally. However, if a bug in the application
    triggers multiple registrations for the same device, it can be hard to
    reconcile state and you might end up with duplicate messages.

    GCM provides a facility called “canonical registration IDs” to easily
    recover from these situations. A canonical registration ID is defined
    to be the ID of the last registration requested by your application.
    This is the ID that the server should use when sending messages to the
    device.

    If later on you try to send a message using a different registration
    ID, GCM will process the request as usual, but it will include the
    canonical registration ID in the registration_id field of the
    response. Make sure to replace the registration ID stored in your
    server with this canonical ID, as eventually the ID you’re using will
    stop working.

    I would suggest adding some logging code to your client, to make sure that you are not receiving the message. Specifically in your GCMIntentService classes onMessage() method.

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

Sidebar

Related Questions

I am Trying to fetch and push A notification (To inform the device to
I was trying to install this .htaccess to notify my users of site maintenance.
I am trying to pass a custom response header to notify my javascript the
I am trying to send information from notification to invoked activity, while from my
I am trying to use notify a main gtk thread ( from a separate
I'm trying to add push notification using Google Cloud Messaging to my Android application.
I am tinkering with the code for this new notification I'm trying to write.
I am trying to get my django app to send a push notification to
I am trying to send some text from the client's end to the server.
I'm trying write simple notify app in bash. I want to read output from

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.