Any one knows how to send Images through android chat application using GCM. I have not found any proper answer for this question. Any help is appreciated.
Yes you can send Image in the payload of the GCM, but the size must be less then 4096 Byte. Here is a list of resource.
Suggestion: It is better to send a link of this image using GCM after that you can retrieve the image from this link in the client side. In this way you can improve the response time for Group/Room messaging.
The suggestion given by BeingMIAkashs is correct.
You can send, a URL from GCM server to the target device. The client app, can then perform a download of your image. Once the image is downloaded, then you can create a notification in your app and show it to the user.
Related
HOW I TRIED:
I have a scenario in which teacher would upload an assignment alert on the server with following thing:
Title
Description
Downloadable Links
created date
Deadline
and the student would get these detail on an Android. I have done this work (the communication between server and client side using WCF webservices). All the data is showing in the ListView on client Side which are uploaded on the server.
WHAT I WANT
A push notification of that alerts on a particular dates e.g (if the teacher uploads an alert on 14 April then the user on the client side would get a push notification on the same date).
DealLine push notification of that alert on a particular dates e.g (the user would get a dealline notification of that assignment on a particular deal line)
I have studied about the GCM. is the best way to send a push notification on an android device. But I don;t think that the GCM is the appropriate solution of my problem? or I just simply go for the Android Notifications?
Does anyone suggest me the how can I do this work? Any appropriate solution for this, or I would have to use any third party library for this work? any tutorial that similar with this problem? THanks in Advance.
I could use some help. I’m trying to create a phonegap app for iOS and Android. In this app you should be able to
type your user credentials (name, company, email and telephone number) and save it. This part in working for me.
Create a case where you type some text and take a number of pictures – hereafter you should press send and the text with the pictures will be sent to a predefined email address. – This part isn’t working for me
Is it possible to do that with Phonegap? And if yes then how do I do that? If no, will it then be possible to zip the text and the pictures and then sent it to a server of some kind (ftp, dropbox ect?)
Best regards
Jacob
Yes, It is possible. You can send image's data (binary data) and text to server. At server end you can create images by using the image data and send the email as per your requirement.
You can also compress images by reducing image quality with the help of phonegap api as well and it will be helpful to minimize your request in size.
If you are using Ajax to send request to server then you should use cross domain option true.
I was going through whatsapp application and I noticed that, for the first time it fetches thumbnails from the server, keeps them in cache memory, and thereafter it fetches these from the cache memory instead of server. (Like bitmap lazyloading).
Till now I have completed implementing the bitmap lazyloading part.
However I have a question as follows:
When any contact changes its profile picture how does the user's whatsapp application detects that particular change and how does it update that particular thumbnail only, cause the application is supposed to fetch the thumbnails from cache memory.
I am clueless about this. Any help is appreciated.
EDIT:
Does it use push notification to notify the client applications to update the corresponding profile thumbnail?
Source:
WhatsApp is build upon C2DM and XMMP for message delivery. MQTT is another protocol which is used to minimise the battery usage.
When any contact changes its profile picture how does the user's
whatsapp application detects that particular change and how does it
update that particular thumbnail only, cause the application is
supposed to fetch the thumbnails from cache memory
Answering your question: So WhatsApp may be using XMMP push or a GCM push notification(C2DM is deprecated ;] ) to inform all the client that some event has occurred and all it's client needs to take care of the same. In your case event is to update your profile pic in devices of your friends in WhatsApp contacts
In your case, you can use GCM to update clients regarding such events.
I don't have much idea about XMPP but You can also have a look at Smack API(An Open Source XMPP (Jabber) client library for instant messaging and presence) and this interesting post
I hope I answered your question. Good Luck :)
Edit:
GCM is a service from Google that uses a persistent XMPP connection to communicate with Android devices. You can use any of the following techniques of GCM to achieve this.
Send "send-to-sync" messages
Send messages with payload
An easy way to handle this situation will be to keep an modified datetime in the table where you store the path of the image and thumbnail. You have to keep the url of the image along with the modified date as the parameter.
Eg:
http://yourdomain.com/images/user_id.png?q=modifieddatetime
Whenever the app will try to open this link, it will first check whether it is available in cache or not. If not the new image will be fetched from the server.
I have not tried this on Android, but it should work. I usually do this in my web applications.
I'm an Android newbie, and I'm using Google GCM to send a plain text message. Is it possible to send an image file as stream or by some other method?
Java - Server
Android - Client.
Message message = new Message.Builder()
.collapseKey("1")
.timeToLive(3)
.delayWhileIdle(true)
.addData("TEST",
"Hello Android")
.build();
Here the plain message is .addData("TEST","Hello Android").
You can only send key/value pairs with total size up to 4096 bytes.
Even if you manage to encode an image within a string parameter, it would be a tiny image.
An alternative is to send a string that refers to the image location, either a local file name on your device or a URL that you can access to download the image when you handle the notification.
I wrote two blogs posts on how to do this:
Tutorial: Using AirBop to Send Images in the Message Payload which shows you how to do it by base64 encoding the image.
Tutorial: Using AirBop to Push Images for BigPictureStyle Notifications which shows you how to push image urls and then download the image.
Both tutorials use AirBop as the Application server, but the client code is separate from that and can be used generically.
You could only send a very small image, as the data payload is limited to 4kB. You would also need to encode it somehow.
Okay let's think about the bigger picture here. As everyone has said it is very hard or impossible to send an image using gcm unless you have a tiny image. Another technique is to send it in parts but hey that's annoying no one wants to code that all out. My suggestion is to code the server to store passkeys and image credentials which can be sent to the device. The device then queries the server with the credentials to get an image download. This technique is similar to the theory of using push to notify the device that new data is available on the server. It was originally used to make a server that uses as little push as possible but it is adpted in this case to be a placeholder for sending big data.
I'm currently thinking of setting up a picture message import project. Something like this:
Client Mobile Device [picture message] -> our Server Device
Server Device [picture && number -> Server Computer
However I don't know if there's a possible way to do this. I could set up a google voice account and use something like this in order to retrieve messages, however this doesn't allow picture messages...
So I was thinking of perhaps making an android or iPhone application to redirect picture messages. Though I don't know if this is possible. If it is, how would I go about gathering the messages? The networking is simple enough, however I'm not familiar with the android system, nor the message system of the iPhone.
On the other hand, I could make a simple email server to receive messages from the cell phone provider's email system.
Is any of the above viable? The image as well as the origin number are both needed.
This sounds like a typical client/server application actually, except the commands sent to the server contain binary data.
There are many ways to do this, and many protocols you can use. Email (gmail) is just one example.
What I would do is use HTTP to post binary messages to your web server. This is cool because it manages authentication, data transfer, etc, are all available.
Here's a short example: Secure HTTP Post in Android
Just add authentication on top of that and you're in business!
You would have to do some web server development too.
I hope this helps.
Emmanuel
Ok I think this is possible. I'm not sure how it works but I'll do my best.
First you have to be notified when an SMS is received by listening to SMS_RECEIVED events. BroadcastReceiver + SMS_RECEIVED
Second, you have to read the SMS attachment as explained here: Get attachment from unread MMS messages
Does this help?