0

I would like to map the gcm reg id to individual users on my site.

What is the best way to accomplish this?

I have a webview in android that loads my site where users are required to login, until login users are anonymous so i can only map the users after login.

some thoughts are,

Set the user agent string to the reg id if its not been registered, when logged in , if no id is mapped to the user then grab it from the user agent string.

^^ that seems the easiest way for me as i'm a beginner but i can think of some flaws straight away.

Monitor the page url, if this can be done. when the webview detects the url is "index.php"(user is logged in) then executes the function within the application to send the reg id to the server.

inject the code into a hidden field in the page before login and submit it with that?

I'm not sure if any of these methods are viable, any help would be much appreciated. I'm still pretty much beginner so laymans terms would be also appreciated.

Eran
  • 387,369
  • 54
  • 702
  • 768
Guernica
  • 246
  • 5
  • 21

2 Answers2

0

You can pass data from the java code that receives the Registration ID (from Google) to your Web View by using javascript, as explained in the answer to this question.

Or you can load the Web View only after getting the Registration ID from Google. This way you can pass it as a parameter to the URL you are loading.

Community
  • 1
  • 1
Eran
  • 387,369
  • 54
  • 702
  • 768
0

Ok by far the best way for me was to expose the javascript interface in the webview, i placed a check in my sessions.php after authentication, if the registration key wasn't in the database then it would call a java function in the application that is essentially an ajax call to another script on the website in which the reg key is passed to and saved in the database along with the user id.

Guernica
  • 246
  • 5
  • 21