push notifcation in android

165 views
Skip to first unread message

chitti ...........

unread,
May 26, 2012, 4:23:08 AM5/26/12
to android-c2dm
Hi ,
I am new to the android.i want to know the push notifcation using
c2dm .i was registering in c2dm account but there is no mail to
me.Please send me the registartion details and also how to send push
notification from server to device using c2dm.


Thank You,



Regards,
anusha

Eddie Hsieh

unread,
May 26, 2012, 4:58:26 AM5/26/12
to androi...@googlegroups.com
Hi,  anusha:


the sign up page:


You have to fill out the contact information at the bottom of this page then you'll receive the email form Google.

And this graph is the most important architecture of c2dm  




By the way, you could visit these site 



http://www.vogella.com/articles/AndroidCloudToDeviceMessaging/article.html 


I Hope these information could help you :)


Regards,
Eddie




2012/5/26 chitti ........... <anu.g....@gmail.com>

Anusha Gogineni

unread,
May 26, 2012, 5:58:23 AM5/26/12
to androi...@googlegroups.com
Thanks for ur lnfo..
   I have a small doubt about c2dm.My app is not publishing in app store it will get push notification or not?
--
                                                      Anusha

Eddie Hsieh

unread,
May 26, 2012, 7:49:28 AM5/26/12
to androi...@googlegroups.com
Don't worry about that. It always works no matter you publish it or not. Just try again, you'll got it.

Good luck :)

 Eddie




2012/5/26 Anusha Gogineni <anu.g....@gmail.com>

Anusha Gogineni

unread,
May 31, 2012, 11:09:57 AM5/31/12
to androi...@googlegroups.com
I am currently playing around with C2DM service .My application is running in 2.3.3 emulator. 
My current problem is that when my application sends registration intent to C2DM server, Logcat says:

Unable to start service Intent { act=com.google.android.c2dm.intent.REGISTER (has extras) }: not found.

I have to set up the google account in android emulator(settings->account&sync) but it shows "unable to open connection to server".
                           please give me any suggestion..
Thank you,
anusha
--
                                                      Anusha

selmi amel

unread,
May 31, 2012, 11:14:53 AM5/31/12
to androi...@googlegroups.com
salem
Your emulator must run with google APIs.
you must change the target of your emulateur.


2012/5/31 Anusha Gogineni <anu.g....@gmail.com>



--

Selmi Amel
Project Manager of Python @ 
Tunis-GTUG
Member of Tunandroid.com

Android and BlackBerry developer

E-mail: amel....@gmail.com ;amou...@apps-network.com

           



Anusha Gogineni

unread,
Jun 2, 2012, 5:28:15 AM6/2/12
to androi...@googlegroups.com
I got the register id.After getting the registration id it will send to the server.But the url  http://vogellac2dm.appspot.com/register is not working properly.The log cat shows android.os.NetworkOnMainThreadException.
--
                                                      Anusha

Anusha Gogineni

unread,
Jun 4, 2012, 2:33:31 AM6/4/12
to androi...@googlegroups.com
I successfully got the push message from c2dm server to my emulator but in that i synchronize with my gmail account with my c2dm account credentials.How can i get the mobile register id with out synchronize gmail account in particular mobile?
--
                                                      Anusha

Anusha Gogineni

unread,
Jun 27, 2012, 3:16:02 AM6/27/12
to androi...@googlegroups.com
I am using php code for c2dm server.In that i enter data.message => 'helloworld' .Run the server got the push message to my phone but it always shows 'Message Recieved' and the message conent is 'NO INFO' .I want to dispaly the message content is helloworld and then If i click on the push message how it will connect to my application?

Please any one suggest me i struggled from past 3 days....
Thanks in advance....


Arti

unread,
Jun 27, 2012, 5:15:53 AM6/27/12
to androi...@googlegroups.com
cud u plz mail me the source code
--
Warm Regards,
Arti


Anusha Gogineni

unread,
Jun 27, 2012, 6:57:52 AM6/27/12
to androi...@googlegroups.com


This is my php code for c2dm


<?php
define("C2DM_ACCOUNT_EMAIL","*****************");
define("C2DM_ACCOUNT_PASSWORD","************");
define("C2DM_CLIENT_LOGIN_URL","https://www.google.com/accounts/ClientLogin");
define("C2DM_MSG_SEND_URL","https://android.apis.google.com/c2dm/send");

function sendPushNotification($device_reg_id,$msg){

    $auth_id=get_auth_id(); // To get Auth ID

    $post_fields=array(
        'collapse_key=ck_1',
        'registration_id='. trim($device_reg_id),
        'data.payload='. trim($msg),
    );

    $data_str=implode('&', $post_fields);

    $headers = array(
    'Authorization: GoogleLogin auth='.trim($auth_id),
    'Content-Type: application/x-www-form-urlencoded',
    'Content-Length: '.trim(strlen($data_str)),
    'Connection: close'
    );

    $ch = curl_init();
    curl_setopt($ch, CURLOPT_URL,C2DM_MSG_SEND_URL);
    curl_setopt($ch,CURLOPT_HTTPHEADER,$headers);
    curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
    curl_setopt($ch, CURLOPT_POST, true);
    curl_setopt($ch, CURLOPT_POSTFIELDS, $data_str);
    curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
    $server_output = curl_exec ($ch);
    curl_close ($ch);
//  print_r($server_output);
}

function get_auth_id(){
    $ch = curl_init();
    curl_setopt($ch, CURLOPT_URL,C2DM_CLIENT_LOGIN_URL);
    curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
    curl_setopt($ch, CURLOPT_POST, 1);
    curl_setopt($ch, CURLOPT_POSTFIELDS, "Email=".C2DM_ACCOUNT_EMAIL."&Passwd=".C2DM_ACCOUNT_PASSWORD."&accountType=GOOGLE&source=Google-cURL-Example&service=ac2dm");
    curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
    $server_output = curl_exec ($ch);
    curl_close ($ch);
//  print_r($server_output);
    $parts=explode("Auth=",$server_output);
    $auth_id=$parts[1];
//  echo $auth_id;
    return $auth_id;
}

$reg_id = "*****************************************************************";
sendPushNotification($reg_id,"Hello World...!! Jay is testing C2DM..."); 

Xinyu Wang

unread,
Jun 27, 2012, 8:24:46 AM6/27/12
to androi...@googlegroups.com
Here is a open source node.js server for sending push notifications to Google's C2DM push notification server. Written by Instagram.

https://github.com/Instagram/node2dm

2012/6/27 Anusha Gogineni <anu.g....@gmail.com>
Reply all
Reply to author
Forward
0 new messages