My question is how does the Google Cloud Messaging know where to send the message to? does it work by IP Address? Is there an interval that runs a function on the phone to send the current location or IP Address of the phone to the Google server? Does anyone know?
Google doesn't need to know the IP address of your device. Instead, your device connects to Google, identifies itself using whatever protocol Google uses for authentication, and Google then uses that established connection to send notifications to your device.
When your phone changes from one IP address to another, it simply makes a new connection to Google, and Google then uses that new connection for your notifications. Google wouldn't even need to keep track of your IP address after you disconnect, since as soon as you disconnect (like on a public wifi system), somebody else might start using that same address.
Here is the link which explains the working of GCM http://developer.android.com/guide/google/gcm/gcm.html
Every GCM client creates a unique device token that you need to send to GCM server for sending the push notifications to client.
Here you can find link explaining the GCM.
GCM Works by Running a Service of its Own to handle Push Notifications.
This service requests the Google Cloud Server (GCM) with your app token ID created by GCM for any pending notifications created by your app and sends the response back with all the notifications from your token id to your app, and this happens for the all the apps using GCM.
So, basically if you have 5 apps which have implemented GCM then their token IDs will be send together by this service and GCM will check if any notification is available for the sent token id's and send them as a response.
Read this thread, this guy has explained it, and GCM is reliable for new app builds !!
http://eladnava.com/google-cloud-messaging-extremely-unreliable/
Related
I'm trying to build an android app that would have the basic functionality of sending a short text Message via USSD to a specific mobile number.
is that possible in any way without establishing a web server and only by creating a peer to peer session between two mobile devices?
You can't.
USSD is not IP, web, or whatever technology around internet. USSD works on mobile networks and messages are transported on the signaling network. In other words, whenever you type #xyz# on your mobile phone, as a call or in an app you've developped, the message is sent to your mobile telco operator on a USSD Gateway, a platform hosted by the telco. That gateway may use HTTP(S) to have the request processed and retrieve the menus to be sent back to the user, that HTTP server may be located on the internet, but this is absolutely not mandatory and most of the time it's not the case.
If you want to write a messaging app using USSD, you have to have an agreement with a mobile telco and your app as likely to only work on his network
I am using aws sns for sending push notifications to devices(mobile devices mostly android). I am able to send notifications to individual devices but i want to publish a common message that has to be sent to all the active devices. I have created platform application and created the end points using all the device registration ids and also created the topic and subscribed to it but when i publish the message, the publish is success and i get the message id but i am not getting the notifications. I have implemented most of the methods which are in AmazonSNSClient class. If someone can guide me it would be very helpful.
Check the aws console in the website using your credentials there you will find details of the notifications sent. If you find that the notification is sent then probably the notification has failed. AWS does not guarantee the delivery of notifications.
I'm trying to make it such that a click on my web client from a computer can "trigger" the android app to run its set function.
I've searched extensively but it seems like all methods need the mobile device to initiate a connection before the web server can even do anything.
Is there a way for the web client to be the one initiating? Also, is there any way to do this without notifying the user of the device, i.e. in the background? I'm using cakephp for the web client but any kind of answer will be appreciated. Thanks!
Use push notification system to trigger any action on your device. Push notification system such as Parse, PushApps, pubnup etc are available for free and some are paid too. Try them. Send a push notification and listen to that push message and on receiving trigger your action.
Use Google Cloud Messaging .
"Google Cloud Messaging for Android (GCM) is a service that allows you to send data from your server to your users' Android-powered device, and also to receive messages from devices on the same connection. The GCM service handles all aspects of queueing of messages and delivery to the target Android application running on the target device. GCM is completely free no matter how big your messaging needs are, and there are no quotas."[Google]
Here you'll find how to implement the GCM with PHP.
I'm aware of GCM services for push notifications, but I have this issue.
I have a android app which will send a data to a local web server (php) that will response to another android device with the data sent, a normal push notification with GCM, I think.
But I need this to work even without internet, because it is a local web app that will work only that.
Is that even possible? Android device X send json data to web server that will send the data to other android device Y.
How can I verify that exists new data in the device Y ?
Thanks. I know its a little wierd.
Yes, it is possible. But it is not easy to develop. This is why:
Push notifications work attached to an account service. So you would have to implement an Authenticator service and then the whole push platform yourself.
I would not use GCM for what you are doing though. If it is working on a local network, you can use "polling" (request the server every now and then for updates)
I am currently working on a project which requires a server to request data from the devices which are currently connected to the server. Meaning, first the server finds out which devices are connected to the server and then sends an application specific message to the client device which should wake certain functionality present on the client.
I was looking into XMPP service which looked promising since it works as a PUSH notification. The in XMPP can be used to check if the device is currently connected and has subscribed to the server. Since every android user has a gmail account, I was thinking of using the gmail xmpp service to connect /subscribe to the server. Then send specific message to the client, i.e x...#gmail.com.
However if a message is sent this way the client app gets the message as well as the native gtalk client. So how do I go about intercepting this so that it doesn't show up on the gtalk client but my app still gets it ?
Use the full JID when sending the message. The send to multiple clients should only occur when the bare JID is used.
Full JID -> xyz#gmail.com/device
Bare JID -> xyz#gmail.com