Register device for push notifications through GCM

Hi, I am trying to setup push notifications on my Android app. I have made a Google api project with enabled GCM. I have added the ANDROID api key into Corona Cloud app and set up almost everything in my app. Unfortunately this app is not a Corona app so I can’t use the corona cloud core library. I have also uploaded my application as a draft to Google play and linked it to a  “Sender ID” with the SERVER api key for my Google api  project as per Google’s instructions found here:

http://support.google.com/googleplay/android-developer/answer/2663268

Now, I try to send a notification through Corona Cloud dashboard but no devices are registered. Ok, obviously. Now I go to the docs, this page: 

https://docs.coronalabs.com/api_web/api/pushNotification/registerDevice.html

I am having trouble figuring out how to register a device. Do I do a simple http post with the same url as in the “example” section of the docs page? (Obviously modified for my project) I have very poor network skills so could someone also help me understand what is and how I can generate an “auth_token”?

Hi,

The auth_token is generated for every user/player that logs into the service.

  1. To get an auth_token you need to register (create) a new player account http://docs.coronalabs.com/api_web/api/users/registerUser.html:
  1. Now the player account is created, you need to log-in http://docs.coronalabs.com/api_web/api/authentication/user.html

When your player is logged in, Corona Cloud will return an auth_token, from this point onwards you don’t need to login the user again. All future calls will be done by passing the auth_token.

Can you share what are you using to develop on? Is it native? Are you using another SDK? I assume you are on Android?

Thanks

-Mohamed

Thanks for the clarification Mohamed. I fully understand the need to register a user account if I’m using leaderboards, but push notifications?Do I really have to make a user accoutn for every player if I wish to use push notifications only? I just want to enable push notifications for all my users regardless of whether they wish to store their scores in the cloud, is this possible?

Hi,

Technically at the moment you can’t, and we are looking into providing other ways of creating and logging in players.

In the mean time, what I would suggest is just create the account under the hood with no interaction with your player.

Thanks

-Mohamed

Thanks again Mohamed, I could integrate Facebook into my app and grab the users id, email, or whatever through facebook api and use that data for registration with corona cloud, but that would require that the user login to my app with facebook. Is it possible that I make 1 account for all my users to use just for push notifications? If not, can i just register randomly generated email addresses instead?

I think the best thing to do in your case is to create random accounts, or like I’ve suggested to others is to auto generate [AppName]+[UserName]@gmail.com, with you having access to appname@gmail.com.

Thanks

-Mohamed

Thanks again Mohamed. 

I am a bit confused on “[AppName]+[UserName]@gmail.com”. Are you saying I can use this to register a user even if that email doesn’t exist?

Actually what I should have mentioned is that you should create a catch all email on gmail, which is appname@gmail.com.

So when you append the +[UserName] to that email, gmail will receive it to the appname@gmail.com account.

-Mohamed

Thanks Mohamed, so I understand the need to make a new email account for my app. What do you mean “append a username” to that email? Can this be done only on gmail or can I do this with our own mail system?

As far as I know this is only supported on gmail.

What I mean is lets say your app is called ABC, you would create abc@gmail.com.

When you register a user, their email would be: abc+user1@gmail.com.

Thanks

-Mohamed

Hi,

The auth_token is generated for every user/player that logs into the service.

  1. To get an auth_token you need to register (create) a new player account http://docs.coronalabs.com/api_web/api/users/registerUser.html:
  1. Now the player account is created, you need to log-in http://docs.coronalabs.com/api_web/api/authentication/user.html

When your player is logged in, Corona Cloud will return an auth_token, from this point onwards you don’t need to login the user again. All future calls will be done by passing the auth_token.

Can you share what are you using to develop on? Is it native? Are you using another SDK? I assume you are on Android?

Thanks

-Mohamed

Thanks for the clarification Mohamed. I fully understand the need to register a user account if I’m using leaderboards, but push notifications?Do I really have to make a user accoutn for every player if I wish to use push notifications only? I just want to enable push notifications for all my users regardless of whether they wish to store their scores in the cloud, is this possible?

Hi,

Technically at the moment you can’t, and we are looking into providing other ways of creating and logging in players.

In the mean time, what I would suggest is just create the account under the hood with no interaction with your player.

Thanks

-Mohamed

Thanks again Mohamed, I could integrate Facebook into my app and grab the users id, email, or whatever through facebook api and use that data for registration with corona cloud, but that would require that the user login to my app with facebook. Is it possible that I make 1 account for all my users to use just for push notifications? If not, can i just register randomly generated email addresses instead?

I think the best thing to do in your case is to create random accounts, or like I’ve suggested to others is to auto generate [AppName]+[UserName]@gmail.com, with you having access to appname@gmail.com.

Thanks

-Mohamed

Thanks again Mohamed. 

I am a bit confused on “[AppName]+[UserName]@gmail.com”. Are you saying I can use this to register a user even if that email doesn’t exist?

Actually what I should have mentioned is that you should create a catch all email on gmail, which is appname@gmail.com.

So when you append the +[UserName] to that email, gmail will receive it to the appname@gmail.com account.

-Mohamed

Thanks Mohamed, so I understand the need to make a new email account for my app. What do you mean “append a username” to that email? Can this be done only on gmail or can I do this with our own mail system?

As far as I know this is only supported on gmail.

What I mean is lets say your app is called ABC, you would create abc@gmail.com.

When you register a user, their email would be: abc+user1@gmail.com.

Thanks

-Mohamed

hi Mohamed,

Is this discussion conclusive? Is there any changes that enables Push Notificcation on iOS device without e-mailI IDs?

Can you please share the latest info on getting Push Notification to work?

rgds

Clef