0

I want to send an app's registration number(which is received by the GCM),straight away to a database table called token_device,when this app is launched. The structure is

                      id|int(11)
                  reg_id|varchar(255)
              created_at|timestamp

I looked many tutorials that are doing this,but only after the user fills the form and send the data(name,email etc) to the server via a POST request. I don't want to do that. I want the reg_id to be send to the database without any user interaction.

Thanks

Theo
  • 3,099
  • 12
  • 53
  • 94

1 Answers1

0

For XMPP-based app server setups, you simply send an upstream message to the app server. The app server can get the registration ID from the from tag in the message.

For HTTP app server setups, you can send the output of register(<Sender ID>) immediately to your web server via HttpURLConnection (or something similar). Do not forget to store the registration ID locally in your Android app's SharedPreferences.

Refer to the accepted answer to this post for details on how to add the registration ID to your HttpURLConnection parameters.

Community
  • 1
  • 1
Koh
  • 1,570
  • 1
  • 8
  • 6