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.
Related
I am creating a b2b e-commerce mobile application. I am using flutter as frontend and django for backend. I am stuck while sending a post request to django server with flutter. The case is I have two types of user. They are seller and buyer. The seller has to post product in the app. Model field for product are title, description, price and image. I created post method in django rest framework and it worked while checking through postman. But I am having hard time sending image through flutter. I used image picker to get the image. I searched for many things but could not figure out what to do. I found articles and videos posting only image at a time but i want to send image along with other text field. How can i do so??
Help me find a solution.
It is better that you upload your selected image with multipart and separate api, but if you want send image with other info , you must, first decrease quality of image until request time was decreased(don't receive timeout api), and also use base64 for this.
Key word for searching for more info, upload image with base64
With the given code samples we have tried to text chatting and it is working. We want to use documents sharing in the same chat window and I don't see any code samples for the same. Not sure whether this feature is available in Agora.io. Did anyone tried using Agora.io chat feature with documents sharing such as pdf, images etc. I want similar functionality of whatsapp. Any references would be of great help.
Agora RTM Docs: https://docs.agora.io/en/Real-time-Messaging/product_rtm?platform=All%20Platforms
Agora RTM's maximum message size is 32 KB and it can be a text message or a text description of the raw message or JSON.
Agora itself does not provide any APIs to share files.
What you can actually do is, let's say if you UserA wants to share an image to UserB. UserA first uploads the image to your own server or an S3 bucket once done get the uploaded link and share the link with the description and type as an image in JSON format to UserB through Agora RTM p2p message and when UserB receives the message render it directly as image.
sendMessageToPeer: https://docs.agora.io/en/Real-time-Messaging/API%20Reference/RTM_java/classio_1_1agora_1_1rtm_1_1_rtm_client.html#a729079805644b3307297fb2e902ab4c9
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.
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'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?