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 8071415
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 5, 20262026-06-05T13:41:22+00:00 2026-06-05T13:41:22+00:00

I followed this Push Notification tutorial . When I finish the tutorial, I found

  • 0

I followed this Push Notification tutorial.

When I finish the tutorial, I found out that two classes did not use which were AuthenticationUtil and MessageUtil.

Moreover, Google Login, this link seem unworkable. Second, This is the token id for the Android device or the account only? i thought push notification is push message to token id of Android device.

On the others hand, i found out that the bundle.putExtra(key, value), all the keys did not use it. For example put "app" but in C2DMRegistrationReceiver() did not get the key.

In this sendRegistrationIdToServer(), it seem like never being call out.

I am being confused by this tutorial about push notification.

Who can guide me or give me workable tutorial or example about push notification?

I would like pro to point out what’s my wrong.

This is my registration id

public static final String[] REGISTRATION_ID = {
        "APA91bFV6MwoAH0UNop69PZ2liKpSBUHSHenIuPzh44_6GdGKzVCLvoH_NM31eMZMVLZi-SAIFwP4iZaE72dSWkIh3GaD0RQYpPm9zO0ARWmnoxFyyyreL_KpQ9Qd_p0broclT12RhA4Ymk0cBT00CmpsbSHIwyxig",
        "APA91bEwmxgvs7zNbKC4p0n4DoTEM73DTihnQgBOP8Gxhf2sVW-fgltugDgS1Fh2S4KvN1wQHbMNJEIzieJ9F1nNPqs3NWeKGbB7IBYpKJq4xmN4Z7uzkjZQQUKGD8jW--AwfQY5McINBto9GAL_87_u5WkIq-kx3g",
        "APA91bH63Zgxn1X_MZ56UzrlRpffvmiLAIsqxvBUTMUHP2O_MT_VU9Ork_edXKHlml-PZSkjKEqdk8EKv5HvxbPdK1Vva3WtmqsPZfhXzEbtNIrwrqIvvRf7hL835rDc4t2E8EKUBj1dX2ta0OxY5pY3Xlhkyb1sBg",
        "APA91bGqT5Wo6eUaMdqT5r9TlGbKSX6GN2W6r-RjrRXz5T5v3j87flcQRyfSajmMNGXuPVe-fwZydRmvyYu63tWnYohDmpJyKkXOxs8Vx6P_FplFQ__ufR_hekwqGOspeUc6bfc8fhbMPGN3Ft9l-bfrghJwwk79jw"};

Messageutil

public static int sendMessage(String auth_token, String registrationId,
        String message, String title) throws IOException {

    StringBuilder postDataBuilder = new StringBuilder();
    postDataBuilder.append(PARAM_REGISTRATION_ID).append("=")
            .append(registrationId);
    postDataBuilder.append("&").append(PARAM_COLLAPSE_KEY).append("=")
            .append("0");
    postDataBuilder.append("&").append("data.payload").append("=")
            .append(URLEncoder.encode(message, UTF8));
    postDataBuilder.append("&").append("data.title").append("=")
            .append(URLEncoder.encode(title, UTF8));

    byte[] postData = postDataBuilder.toString().getBytes(UTF8);

    // Hit the dm URL.

    URL url = new URL("https://android.clients.google.com/c2dm/send");
    HttpsURLConnection
            .setDefaultHostnameVerifier(new CustomizedHostnameVerifier());
    HttpsURLConnection conn = (HttpsURLConnection) url.openConnection();
    conn.setDoOutput(true);
    conn.setUseCaches(false);
    conn.setRequestMethod("POST");
    conn.setRequestProperty("Content-Type",
            "application/x-www-form-urlencoded;charset=UTF-8");
    conn.setRequestProperty("Content-Length",
            Integer.toString(postData.length));
    conn.setRequestProperty("Authorization", "GoogleLogin auth="
            + auth_token);

    OutputStream out = conn.getOutputStream();
    out.write(postData);
    out.close();

    int responseCode = conn.getResponseCode();
    return responseCode;
}

private static class CustomizedHostnameVerifier implements HostnameVerifier {
    public boolean verify(String hostname, SSLSession session) {
        return true;
    }
}

Messagesender

public static void main(String[] args) throws IOException {
    String token = AuthenticationUtil.getToken(SecureStorage.USER,
            SecureStorage.PASSWORD);

    for (int i = 0; i < ServerConfiguration.REGISTRATION_ID.length; i++) {
        MessageUtil.sendMessage(token,
                ServerConfiguration.REGISTRATION_ID[i], "12358",
                "印尼羽賽:馬2單1雙止步入選賽");
        System.out.println(ServerConfiguration.REGISTRATION_ID[i]
                .toString());
    }
    System.out.println(token);

}
  • 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-05T13:41:23+00:00Added an answer on June 5, 2026 at 1:41 pm

    You should follow this tutorial for android c2dm implementation.

    For server, you could use anything, some code sample available on internet. For server I used .NET library called “C2DM Sharp“

    The process is very simple like…

    • First register your google email for c2dm on – https://developers.google.com/android/c2dm/signup
    • Run the android application on Android 2.2 or higher and send the registrationID which you can get in “C2DMReceiver” or get that ID by writting in LOG
    • Use the server code, for testing purpose paste your registrationID in Server code and you are ready to go.

    The basic flow of C2DM is …
    Register Phone for C2DM -> Get registrationID -> Send registrationID to server -> Server usees google id to get auth token -> server use registrationID and auth token to send message.

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

Sidebar

Related Questions

I have followed this tutorial: http://www.raywenderlich.com/3443/apple-push-notification-services-tutorial-part-12 fully, and after seing that I had issues
I followed this tutorial for push notification. http://mobiforge.com/developing/story/programming-apple-push-notification-services . In my didFinishLaunchingWithOptions i have
OKay..so I followed this tutorial on RayWenderlich.com about setting up push notifications in an
I have followed this tutorial which uses jQuery UI to generate Facebook tokens like:
I followed this tutorial to setup auto-completion functions for figlet / toilet . #
I followed this tutorial to connect a digit.tree to a store.JsonRest and everything works
I followed this tutorial from the Android Developers site. But, the auto complete doesnt
I followed this tutorial: https://github.com/EllisLab/CodeIgniter/wiki/PDF-generation-using-dompdf However, I can't seem to set the path right.
I followed this post to make my section header animate out of view when
I followed this link to make use of recent files list but statement below

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.