Has anyone succeeded in using pubnub examples for android? I am working a senior project that uses it for interacting with raspberry pi remotely. The demo project works find but replacing the pub/sub key with my own causes unknownhostExecption. I have created GCM account and using the api key as the sender ID. My manifest is registered the appropriate permission as well. I have been stuck with for a while. but still unable to figure out the cause.
What do i need to do?
I will start by linking to an Android PubNub project that was created to interact with a Raspberry Pi remotely. Take a look here https://github.com/GleasonK/PHue
I have created GCM account and using the api key as the sender ID.
Are you trying to use GCM? If all you need is Pub/Sub you simply need your developer Pub and Sub keys. Unknown host might be because you are using the wrong keys. Visit the admin console and log in (https://admin.pubnub.com/). You should then see Publish Key and Subscribe Key. Those are the two you need to use when instantiating a Pubnub object in Android.
If your project actually requires GCM, PubNub does support that as well. From the PN Blog. If this is what you need me to elaborate on let me know and I would be glad to!
Related
Hi android developers,
Today I have decided to use Push notification of GCM. But getting stuck with creating key.
Steps I followed below steps provided in docs
Created project.
under API & Auth Google Cloud Messaging for android turned ON
Here I stuck, which key to choose. In docs it clearly says to select server key but in api key help doc says:
A.Create and use a server key if your application runs on a server.
B. Create and use an Android key if your application runs on Android devices.
My Question is I have developed an offline app which runs on android phone. So which key should I prefer? Also if anyone has done this push notification stuff then please share whole procedure in simple words.It will be great help.
Please help!
Thanks in advance.
you just have to create the public server key and shared it with your api developer which will used it for send push notification with using the Google Cloud Messaging.
I have an android application where push notifications are implemented by GCM.
I need to change this. I need that with the new release (the app is already in the Store and people already use push with GCM) all the mechanism will be handle from Parse.
Can I simply delete everything concerning GCM and implement everything concerning PARSE and then upload the version of the application and be sure that everything will run the same?
Has anybody an idea if there will be conflicts with doing this? I'm thinking about devices that already have a GCM token for example.
You should try it and see. I think when implementing Parse, the registration ID (unique to every app <--> device) will be generated again. I've written a couple of articles on the topic which are not directly useful but can help in other ways.
Just make sure you follow this thoroughly.
how to create push notification in Android using GCM or either C2DM i have tried and check some sites and didn't get exact answer.i need to know how it works.Can any one provide me good tutorial on push notification
Could anybody help me. Thanks!!
Its Depend on your requirement what you have to do.
here is sample of C2DM: in this sample android device is registered wtih server after that server send massage to all device. so there is one way communication(server to Android device)
So all things are done at server side. just download this tutorial. Both Server side(PHP) and Android code are available.
Edited:
you got application key from Google services which you have to put at server side.
SENDER_ID – Google project id which you have to send when you want to register your device with server.
You can use GCM demo app supported by Google. One needs to install GCM libs using SDK manager and then create API keys in Google APIs console. Follow instructions from the link and you can create an app that receives push notifications from GCM server. I did try this and it worked even on my Android emulators. You need to use Emulator that targets Google APIs though.
I've been following this guide
and still dont get it (Im quite new to the whole android-stuff, Im sorry).
"1. Create a servlet (or other server-side mechanism) that can be used by the Android application to send the registration ID received by GCM . The application might also need to send other information—such as the user's email address or username—so that the server can associate the registration ID with the user owning the device.
2. Similarly, create a servlet used to unregister registration IDs."
I dont think this guide is very thorough overall but right here I ran into some trouble. Is there any kind code-cracker out there who can help me?
How do I make a "servlet" for GCM?
Thank you in advance!PS. Im using eclipse
You should probably take a look at the GCM Demo Application page, specifically the Setting Up the Server section which shows two methods for setting up a GCM server. I have seen a few other GCM developers using Google App Engine for their GCM servers as detailed in point two of the link.
There are also commercial solutions out there such as AirBop (which I happened to help create), Urban Airship, and a few others.
How can I send data from a server to an Android device without the device polling for data?
This is called a server side 'push' and is commonly referred to as 'pushing'. This is a well known feature of the iPhone, however, it does not currently exist on the Android. Android Cloud 2 Device messaging has not yet been released to the general development community. you may want to check out projects such as MQTT and Deacon.
You might consider using Googles cloud to device messaging for a solution.
You'll have to sign up for an account and are only able to use AppEngine servers at the moment.
Your application has to use API level 8 (2.2) in order to be able to receive the cloud's pushes.
GCM (Google Cloud Messaging) is the easiest way, and while GCM provides the basic service of sending messages, there are companies out there that do help you get up and running.
You could take a look at companies like urban airship, xtify and mBlox (developer.mblox.com) to get started with this and have a few additional tools that help you structure the push notifications in a more structured way.
Good Luck with your development!