GCM 发送图像而不是消息 [英] GCM send image instead of message

查看:32
本文介绍了GCM 发送图像而不是消息的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我是 Android 新手,我正在使用 Google GCM 发送纯文本消息.是否可以将 图像 文件作为流或其他方法发送?

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 - 服务器

Android - 客户端.

Android - Client.

    Message message = new Message.Builder()
                .collapseKey("1")
                .timeToLive(3)
                .delayWhileIdle(true)
                .addData("TEST",
                        "Hello Android")
                .build();

这里的普通消息是.addData("TEST","Hello Android").

推荐答案

我写了两篇关于如何做到这一点的博文:

I wrote two blogs posts on how to do this:

教程:使用 AirBop在消息有效负载中发送图像,它向您展示了如何通过对图像进行 base64 编码.

Tutorial: Using AirBop to Send Images in the Message Payload which shows you how to do it by base64 encoding the image.

教程:使用AirBop 为 BigPictureStyle 通知推送图像,它向您展示了如何推送图像 URL,然后下载图像.

Tutorial: Using AirBop to Push Images for BigPictureStyle Notifications which shows you how to push image urls and then download the image.

两个教程都使用 AirBop 作为应用程序服务器,但客户端代码与此分开,可以通用.

Both tutorials use AirBop as the Application server, but the client code is separate from that and can be used generically.

这篇关于GCM 发送图像而不是消息的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆