I have an android application that is designed to receive push notifications via GCM. When I initially designed the application, I used a "deprecated" tutorial (merely because it was one of the most in-depth I found) and my dev phone was running API 2.4, so I was able to get the service up and running without much issue.
Now, my development device is running Android version 4.4.2, so my goal is to "upgrade" my application to handle GCM properly for all devices (for now, lets ignore the fact that I'll have to differentiate how to handle Push Notifications depending on API level).
I attempted to follow the Android Developer tutorial for creating a demo client app for Google Cloud messaging, which can be found here. https://developer.android.com/google/gcm/client.html
While I hate to sound like I want to ignore to smart coding practices, this official walk through was a little big in terms of scope (My application supports Phonegap, and while I think implementing native GCM is much easier than using the PushPlugin for Phonegap, I don't want to handle more than is absolutely necessary in my Java code)
As a last ditch effort, I simply downloaded the demo gcm code from the source they provided here: https://code.google.com/p/gcm/source/browse/samples/?r=1ca8e646c517310e2d46a6a6eda74106b8084fc5
I attempted to import the gcm-demo-client application, and although I know my SENDER_ID, I don't understand anything about the SERVER_URL. The documentation provided by Android Developers talks very generally about HTTP vs. CCS, and I'm struggling to grasp where this server fits into the grand scheme of all that is Google Cloud Messaging.
Assuming I download the gcm-demo-server project directory they included (which seems to be some kind of Java Project), how do I host it? My previous deprecated GCM simply used a basic android application in which I would submit a form containing the device Registration Id, and a message with a title and context. Unfortunately, I can't figure out how to import their demo-server into Eclipse (since Eclipse doesn't think it contains ANY project files), AND I cannot seem to understand how this server connects with my application in any capacity.
TL/DR Summary of questions:
1.) How can I go about "hosting" the gcm-demo-server from URL #2 above?
2.) If I can just copy the Registration Id from my client app to the clipboard, can I just use my "android server" application to send my messages?
3.) Maybe it's just me, but I don't see anything resembling a Receiver class in the gcm-demo-client project directory, only a GcmIntentService. How can there be an intent when the application can't even properly handle messages?!
Thank you for your patience and help!
(P.S. - I cannot provide any code- however since the code in question is merely the provided Android Developer GCM demo code, this hopefully won't be a big issue)
1) There are many companies that offer server hosting services. You should choose one.
2) If you copy the registration Id manually, and hard code it in an application that serves as a "server", you don't need to host a real server, though that would only work in development. In production, assuming you'll have multiple users who install you app, you'll need a real server that receives and stores the registration IDs of all of them.
3) The demo client project you are referring to is old, and relies on a deprecated library (gcm.jar) which contains a default implementation of the BroadcastReceiver, which receives the messages from GCM server and starts the intent service. If you refer to the current demo app, you'll find a BroadcastReceiver class.
The demo app might not work because it is a gradle project and you should preferably open it in Android Studio. That might be why it could not see it as an Android project at all.
I have recently started implementing GCM myself and it is not difficult at all. I am using AppEngine for holding the backend part of my app. In Android studio, there is a very quick and easy way to generate both the android client and the backend part including the cloud endpoints and even a web interface for sending the messages (you don't need to use it though).
I followed this tutorial https://github.com/GoogleCloudPlatform/gradle-appengine-templates/tree/master/GcmEndpoints
Maybe this is not a fully satisfying answer for you, but I found the code very much readable and I understood how this stuff works.
Related
I'm building an open source application which is intended for users to self-host. Now, I would like to add push notifications on Android and iOS that would be sent from the self-hosted server application. Is there any alternative push notification service that does not require an API key (FCM, APNS) or per hosted instance registration (PushBullet) for this use case?
I've googled for this, but the only thing I've come across which even remotely resembles this is Pushjet.
Open source projects seem not to rely on Push Notifications, which is a shame considering how many great things can be done with them. I would really appreciate any and all suggestions.
To clarify, the project can't use Firebase, PushBullet, APNS or similar because all of these either require the developer to publish an API key in their app (Firebase) or require the user to register their clients and servers individually with a service like Pushbullet.
This question is specifically about avoiding this registration requirement and using some "public push" type service (if one exists).
Some examples of exactly what I'm trying to avoid:
https://julienrenaux.fr/2015/06/25/ios-android-push-notifications-100-free-and-self-hosted-for-wordpress-using-cordova-and-ionic/
https://home-assistant.io/components/notify.pushbullet/
https://github.com/mattermost/mattermost-push-proxy/blob/master/README.md
For anyone who's curious, the project is here: http://gitlab.mccollum.enterprises/icing/
I am to build an android app that needs a central cloud storage (along with some server coding). My app is somewhat in the footsteps of
https://play.google.com/store/apps/details?id=com.justyo
I mean i should be able to store a login and registration (possibly FB login in the future too). Then, i will also have to maintain and fetch users' 'friends' in the app along with a status (that can be changed any time by the friends).
I am not new with android dev. I also know ample amount of web development. However, i don't know the approach to this kind of an app that is to use some server side code and online db for android.
I have search a lot on the internet and have found a bunch of stuff, but i am just not getting the confidence as to which approach is what i need here.
Is there something pre-built and given by Google themselves?
Do i have to by a domain, deploy a hidden (UI-less) web service and access it through the android app?
is there a free option out there by google?
Is there a sample demonstration android app out there?
I don't need the code or anything. I am just confused; afraid of starting off in the wrong direction. Please answer so it is easy to understand.
Thank you in advance :)
There is the Google Cloud Platform, specifically App Engine. You can read the Docs here.
You dont't need to register a domain to use the platform. Yes, you will need to deploy a (not necessary UI-less) web service to the cloud, accessed from the Android client through endpoints. Additionally, the service is free up to certain limits.
Sample apps are available for deployment once you create a project from here.
I am developing an Android app that uses Google Cloud Endpoints on Google App Engine (in Python) for its backend. The Android app authorizes the user using Google Play Services on the Android device, and it all works fantastically.
However, now that I have actual users, I'd like to be able to test this all locally before deploying any app engine API changes to production, and I haven't figured out how to have the Android app talk to my local development server anywhere. The testing recommendations suggest that I just do some manual tinkering with API Explorer, but as I'm using the Endpoints Proto Datastore for my API, which makes the Android development easy, it also makes the API Explorer basically useless, since the calls I need to make are far more complicated than what I can generate by hand.
One answer to this question suggests that there is a way to point the Android client at the local server, but while I can use the --host argument to have the dev_appserver's default server listen on something other than localhost, I can't seem to find a way to do the same for the API server. And even if I could do that, it might only be the first step to a full end-to-end local testing setup for my Android app.
Can someone post more details on how I might do this, or short of that, please enlighten me on the best practices for testing Android apps that use Google Cloud Endpoints on App Engine? Thanks in advance for any answers.
Alright, finally got it working, thanks for the tips, Dan! Here are the remaining details that would have saved me a few hours - hopefully this is helpful to someone else.
1) As I expected and mentioned earlier, dev_appserver.py needs to be run with --host=0.0.0.0 so that it can listen on the local network.
2) In order to properly parse the ID token to make the user authentication work, you need to have the PyCrypto library installed - it is not installed by default, so just having it in your app.yaml isn't enough. I found the binaries for Windows here.
3) Then, in my generated Tictactoe.java-equivalent class, I had to change the DEFAULT_ROOT_URL to be http://<my-local-machine>:8080/_ah/api/ (which is where my local machine is running), so that requests went to the local network. Alternatively (and perhaps less invasively), you can use builder.setRootUrl to the same address from wherever you initialize your builder. This way you don't muck with your generated classes.
4) I also had to make the change Dan mentioned described here.
After doing those four things, everything seems to be working now and I can test my app locally - hooray!
In the local environment, the dev_appserver is the API server. If you've configured it so that it's accessible from machines other than localhost (i.e. another machine/device on the network) API requests should be accessible as well.
However, there's currently an issue with the local server and gzipped requests. Until that's fixed you'll need to disable gzipping within the client library in your Android app (see this post).
I need my android phone and my PC (win-xp-sp3) to be able to communicate with each other.
I am successfully running a xmpp code in my android phone through SL4a/python and it can send and receive communication.Now the communication my phone is sending i want to receive on my pc through a code.(which at present i am receiving thorough my gtalk client)
My questions are: how do i go about it?, is there any pre existing code,script,link that i can refer to? or can i hijack anyway the msgs received by gtalk in my pc?
I tried to use the same android code to listen for the chat from PC by removing the android part of the code, but I was getting error on xmpp module not existing. so i copied the xmpp.py file from google developers website to my lib folder. but now if i try to run it i am getting error "No module named google.appengine.api".
So i did some homework and downloaded gdata-2.0.17.zip from google developers website.
My questions are: am I on the right path? what should i do next? Is there any document/link regrading the same that you know?
I know the question was long but i tried to be specific to what I am looking for.
Please help me.
Google App Engine is Google's cloud computing service. If you're not creating a web application using that, you need to find an XMPP module for Python which doesn't depend on Google App Engine.
https://stackoverflow.com/questions/1081634/which-is-the-most-mature-python-xmpp-library-for-a-gchat-client seems like it's relevant to this question.
There are a wide variety of XMPP client libraries available that will work on Windows in pretty much any language you want to use. Pick one and simply write an app that connects to the gtalk server. You don't need anything google specific to do that.
I am creating a app wherein user shares some information. This data i am storing it in database through servlets i.e. i am calling my own servlets which will take data through url and store it in database. So i want other users of that same app to get notify that some information is available and in turn they will get the information that other user has updated.
For this to work we can use polling or pusher. But polling will take lots of battery power.
I have tried C2DM but its not working for me. So i am thinking for some other mechanism by which i can implement other than C2DM.
Please suggest some way to work it. and e.g. if u have came across.
C2DM is deprecated, the new version is called Google Cloud Messaging (GCM) and is exactly what you need for your use case. There is even a GCM Demo Application which uses a Java servlet. The source code can be found here, you browse it directly or if you prefer GitHub you can use this repository.
The servlet code can be found in the file
samples/gcm-demo-server/src/com/google/android/gcm/demo/server/HomeServlet.java
If you follow the instructions in the Getting Started guide you will soon have a working application. I would suggest you not trying to copy paste it together, you have to get a clear understanding of how the GCM architecture is working.