What is registration ID in Android and how does it creates internally? - java

I'm new to Android and I don't understand some concepts.What is registration ID used in Google Cloud Messaging?How does it creates internally - it is unique device id as Apple device token or something else?How does it differs from application id? It is may be a stupid question but I really don't understand the concepts.

Is the temporally ID that allows to GCM services identify your device-application, so trough your server you can send messages to GCM and this will redirect it to your device. More info here
In advance i copy some text:
An ID issued by the GCM servers to the Android application that allows it to receive messages. Once the Android application has the registration ID, it sends it to the 3rd-party application server, which uses it to identify each device that has registered to receive messages for a given Android application. In other words, a registration ID is tied to a particular Android application running on a particular device.

It's documented quite fine there: http://developer.android.com/google/gcm/gs.html
For sender ID:
Open the Google APIs Console page. If you haven't created an API
project yet, this page will prompt you to do so:
Note: If you already have existing projects, the first page you see
will be the Dashboard page. From there you can create a new project by
opening the project drop-down menu (upper left corner) and choosing
Other projects > Create. Click Create project. Your browser URL will
change to something like:
https://code.google.com/apis/console/#project:4815162342
Take note of the value after #project: (4815162342 in this example). This is your project number, and it will be used later on as the GCM
sender ID.
As for ID returned after GCM registration - how it is created is not really important, but it's unique ID per your device + the Google account active on the device.

Related

How Can I use Google OR Microsoft Push Notification for 2 factor authentication in my JAVA based web app

I want to enable two factor authentication (with Push Notification) in my JAVA based web application.
I searched and found I can use Google & Microsoft authenticator app and can enable two factor authentication, I have successfully done POC for this and it works well with random code generated in Authenticator app and on my web app server and can verify the code. https://medium.com/#ihorsokolyk/two-factor-authentication-with-java-and-google-authenticator-9d7ea15ffee6
Now I want to enable Push notification in a same way, whenever user login to my webApp,after user name & password verification, I want to send push notification to user's registered mobile number OR in user's Google/Microsoft authenticator app, with YES, NO options. user will then select YES or NO and based on that response, user should be able to login in my web app.
I searched but not find any such API of Google or Microsoft which I can use in my web App to support push notification. Appreciate your help if any one can provide links to such API docs or have any other suggestion to achieve this requirement.
Thanks

Firebase: Setting up different environments for Auth and Notification

I have 2 mobile apps and one web app which use the same Firebase Auth and Notification services. I only use Auth and Notification services, nothing else.
I require to have a staging environment and production environment, and both need to run in parallel.
I do not see other option in Firebase rather than creating two different projects. But that's risky, because I have to replace the JSON files in mobile app, replace Admin SDK stuff in web app and so on.
So what's the best option for this? I use Firebase only for Auth and Notification. In notification I send messages to individual devices and user groups.
maybe asking the users to use different email accounts for testing and production is the way to go? (Because then the Auth data will not be messed up even though the same Auth space is used)
You could have only one single Firebase project and inside this project create several apps. For instance, you could create an app for production with the package name(android)/bundle id(iOS) "com.example.myapp" and another for staging "com.example.myapp.staging". That way, you can download a single json file with both configurations. In your android studio/xcode, you have to set up those package name/bundle id with the corresponding build configuration.

How to connect android users to my database / web application?

I have wrote a simple web application with few tables. It has it's administration area where you can manage it's table. Basic CRUD operations.
However, I need to develop an Android application which will retrieve information from this web application trough API. So I am going to write a simple API methods for fetching data. Also there will be sometimes when Android user will save some of its data to database.
Android application needs to be able to list items stored in database and bookmark some of those items over HTTP.
To me problem is how to implement SingIn / SignOut operations using Android's Google account. For example, application GMail is always signed in (at least on my device) and I want my application to be always signed in.
Then, how can I manage what items user bookmarked? Should I create a table android_bookmarked_items (android_user_id, item_id)? But then what should be android_user_id? Do I need to use OAuth?
I am doing this kind off sign in for the first time and I am really confused how to connect this web application with android user and manage bookmarked items per user...
You can make use of Android AccountManager. Check out How to get the Android device's primary e-mail address
I think i have found solution by using Google Sign-In for Android. I get idToken for currently login user before each POST request and verify it on server side. Also from the token I get property sub which is user id and store this in my database...
Auth with a backend server
However, I am pretty new to this stuff, tokens and authentication using google, I would like for someone more experinced to confirm that my solution is fine and secure...

How to add the data to Google Analytis by using java (programmatically)

At the current moment, I am trying to understand how to add any data to GA. I read the data from my GA account using Core Reporting API and Managment API without any problems. But now I want to add the data (the number of phone calls) to GA account programmatically. Somebody can explain me step by step - how can I do this?
The Measurement Protocol is how we send data to Google Analytics. The JavaScript snippet that we use in our websites also uses the Measurement protocol as do the SDK's for Android and IOS. Unfortunately there is no (official) SDKs for the other languages like Java for instance.
That being said you can technically code it yourself in any language that can handle a HTTP get or a HTTP post. I have personally done it for C#.
POST /collect HTTP/1.1
Host: www.google-analytics.com
payload_data
The following parameters are required for each payload:
v=1 // Version.
&tid=UA-XXXXX-Y // Tracking ID / Property ID.
&cid=555 // Anonymous Client ID.
&t= // Hit Type.
A few tips to get you started.
Check out validating hits this is very useful in the beginning for debugging your requests.
some of the parameters are only valid for certain hit types. Make sure you check the documentation.
Cid is just a string it can be anything most people send a Guid its basically used by the server to identify a unique session.
if you are doing this for an application google analytics account remember to send screenview not pageview the same goes for web application.
check the realtime report on google analytics to see if your hits are getting recorded.
Update for question in comment:
I recommend while you are getting the idea of this you start with just using HTTP GET in a web browser. Its easer to test your requests against debug that way. For example put this in a browser.
https://google-analytics.com/debug/collect?v=1&tid=UA-123456-1&cid=5555&t=pageview&dp=%2FpageA
DP is document path and I am not sure why it is requiring that you send that.
ScreenView hit type VS PageView hit type.
There are two types of Google Analytics accounts ones for applications like android applications or sometimes web applications, and web sites. Application Google analytics accounts are meant to be used with ScreenView hit (the user checks a screen in the application) type and web accounts use PageViews (the user views a webpage). If you send a Pageview to an application Google Analytics account it will accept the hit but there will be no way for you to see the data. If you send a ScreenView to a web Google Analytics account it will again accept the data but you wont see it.

Google Cloud Messaging single request

I've been searching over the web but I can't seem to find some straight answer.
I've got an application developed and now I need to add it notifications. My issue is that I need each device to be unique and send each one of them a different notification. (I don't mean ONE UNIQUE notification) but I mean to send some users a notification and others don't.
How can this be done?
As a part of the GCM infrastructure, you will need to have your own web application that will allow individual instances of your app to register. When this happens, your Android application will pass to the web application a registration ID along with any additional information that you can use to identify the device. Once you have this information stored, you can pick and choose which device should receive your notification.
See: Architectural Overview section in the http://developer.android.com/google/gcm/gcm.html

Categories

Resources