Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

2 users using same device and same app but different login id -do they have different gcm registration id?

I have created table with user_id(unique sno based on email-id) and GCM_id of each user .There are 2 questions I have namely,

  1. Can 2 users with different email_id login from the same device and receive gcm w.r.t that user?

  2. How do I create and maintain columns in my database.Basically what are the columns I need for getting gcm working if user has installed app on different devices(Mobile,tab-Android) but same email_id ?

I was referring to Android Hive link but someone said that its gcm(2012) and is deprecated. http://www.androidhive.info/2012/10/android-push-notifications-using-google-cloud-messaging-gcm-php-and-mysql/

Summary: What are the steps I need to take to make latest GCM work properly on multiple devices? Thanks. I really appreciate any help .Thanks in Advance.

like image 635
jason Avatar asked May 07 '14 09:05

jason


1 Answers

Your app on a given device will have one registration ID. You want to associate that registration ID with the user ID of the current logged in user. So, when a user logs in, you should send to your server the user ID + registration ID and store them in your table. When a user logs out, you should send the user ID to your server and clear the registration ID for that user in your DB.

Now, if you want to support multiple devices for the same user, you'll need to tables. One table for user IDs (in which user ID is unique, and is probably the primary key), and another table for the association of user IDs to registration IDs (in which each user may be associated to multiple registration IDs). Again, you create the user ID - registration ID association during login and delete the association during logout.

like image 53
Eran Avatar answered Sep 24 '22 23:09

Eran