I'm try to send data throught pub/sub library to my topic in GoogleCloud
projects/navigator-cloud/topics/navigator-location
Here is a project of a google map with a overlay image of a building, which I should use. I want to publish a JSON with some info like this: {"Username": "oscarhmg", "Location": "labproto", "Timestamp": "2016-12-04T15:29:05Z" }.
When the topic receive this info, in the building map appears a marker(This map shows in my application in a web view). This functionality is already implemented, what I still do not understand at all is how to pass the message to publish on this topic through my android application. Any help would appreciate it
Check out this Android Things tutorial that has the device directly publishing messages to Google Cloud Pub/Sub without going through a web server. The way to do the authentication is by building the .json credential into the Android app.
https://github.com/androidthings/weatherstation
As #gunit points out there is a way to connect an android app demonstrated by androidthings. I have not used this method myself.
You will have to manually create a google cloud api token from the console and pass it in while using the API.
When connecting a mobile client directly to PubSub but you may need to setup the topic permissions to enable access.
Alternatively, you can make a web service that your android app connects to (via HTTP POST) to publish a message. That web service will then put the message it receives into the PubSub topic.
If you use use appengine to build the webservice solution then it will automatically be authenticated to work with pubsub (I can confirm the python api does this at least).
Related
I have a project, angularjs webapp (backend java and spring boot) and uses google map too, there is an android app that sends alerts to this webapp and those show location on the webapp’s map. However when I implement spring security it would secure the webapp and REST api, but will prevent the alerts from android showing on the map (can not find resource)….
I want an easy simple way to secure the app without stopping the REST API services, yes I want to secure my API but still want to be able to show the alerts sent from android device, also still accepts new registration from android users....(android users cant access webapp they only register to use android app and will be added to database..they will need to be able to post their info...)
I tried oauth2 using google sing in, but I must be missing something as it wont load,..If you think this is the right approach please confirm...I will further look into it...Or direct me to tutorial or give me any suggestions...
P.S I am using bluemix platform as a service at the moment and CLearDB database service from bluemix
I am a student and all this is new to me...Thanks
Is it possible for a device to send message to other devices using Google cloud messaging without an app server at all?
I have a centralized database using Google Cloud Datastore. The app will get required registration ids from the centralized database and the database is updated by all the devices. So, getting registration ids is not a problem.
Can this be done using upstream messaging? I am not sure because i have searched a lot but never saw an example where app server is not used for this purpose.
This question is not duplicate of another question, because here i have central database to store registration ids which is mentioned as a problem in another question.
In the most basic sense no, not at this time. You cannot send an upstream message from one device to another without an app server. You can create an app server on your device application but that is not recommended. The current recommendation would be to use an app server to facilitate your device to device messages.
To answer is it possible? Yes it is.
Sometime back I have created a POC to send GCM message to self, so I know its very much possible. I configured my GCM to work with any ip in developer console i.e. 0.0.0.0.
just use HTTP post to send your message from android as you would have done from Server.
Like (most) everything else, there is an API for that.
Google hosts its GCM service on GCM Connection Servers. The official document requires you to create an App Server to issue the API requests to the Connection Servers.
Alternatively you could setup the Connection Server to accept requests from any IP around the world, and then issue the requests via your client app. The API is here and it's quite simple.
Seurity issues
Bundling your API key with your app, and setting the Connection Server to unrestricted connections is an obvious major security issue.
Why bother?
Why bother doing all of this? Instead I would use a free service like Parse.com, which takes care of the users database and offers up to 1000000 messages a month free.
Has anyone actually done this. I would like to see example android project.
I am working on Android gcm project. The docs recommend to save the project ID and api key in a server for security purposes. But all of the GCM examples in the web don't do that. How efficient would that be to save them in a server and grab them when needed in the app? Has anyone done that in any project? Can someone give me a snippet of efficient code?
Thank you
GCM implementations require you to have server side part that will be sending data to your devices. This acts as middleware between devices and GCM servers. Server side can be PHP/Python etc scripts, whatever. And to these scripts need these data to be able to send anything to your devices via Google servers. So your app is NOT fetching anything. Like this:
.
What I'm trying to do is have an Android app that connects to a Google App Engine backend in order to get data from a database stored in the cloud. I've looked up some documentation and figured that Google Cloud Messaging is the best way for this. I'm stuck on trying to integrate Google App Engine with the Android app.
GCM is great for sending small messages from GAE to the app, and particularly for waking the app and getting a message to it even if it isn't running.
Sending a request from Android to GAE via GCM is new and is not the normal way of making requests. In my personal experience with new Google stuff, I would suggest you stay far away and stick to the normal way which is to do an HTTP/REST/JSON request from an Android to a servlet on GAE.
There many Android libraries for doing this including Volley from Google (this was in use long before it was release so is not as scary as the GCM thing I was mentioning). On the server you could do it with Google Endpoints for easier authentication and cross-platform support, but it too is quite wonky (it is not fully released), so if you don't need those two features I would avoid it.
I am writing an android app which provides scores to users based on Questions and answers. I am planning to bundle the app with the questions. I want to store the user's score on some web server. For this I need to implement some kind of an authentication mechanism as well as I need some web based datastorage. Realized that Google App engine can be used for this purpose.
However, I found only one framework for this Google Cloud Messaging (GCM). Looks like this framework has far more use cases than what i originally require. i.e, it also allows to send messaging from cloud to the device. However i am not sure if we can use this to send data from Android to Google Cloud and store it in Google App Engine.
Just wanted to check if there is any framework which only exactly what i wanted, ie., to store and retrieve the data rather than acting as a messaging service.
Google Cloud Messaging (GCM) is use to send message to all of your app user. Google Cloud Messaging (GCM) is for push notification service.
To store your game scores, better use web service, Like php or ,net or other web service.
Thanks.
You can run a simple Java Servlet on the Google App Engine and send HTTP requests from the Android device with the score data.
On the Android device, you will need to aonfigure Internet access rights and a HTTP client library.
Looks like I can use Google Cloud Storage which serves my purpose. Haven't explored it yet, but will definitely try it.