duanjian4150 2014-07-27 12:40
浏览 58
已采纳

有关Google Cloud Messaging的特别消息(PUSH到Android)

I'm able to send strings to my Android phone via the PUSH system.

Atleast on my iPhone I have noticed people sending PUSH with images, PUSH with play / stop controls (IIRC), PUSH with custom sounds.

How can I send such data to the Android phone?

My current data:

$fields = array(
    'registration_ids' => $registration_ids,
    'data' => array( "message" => $message ),
);

$message being a string.

This is the plugin I am using on the phone:

https://github.com/phonegap-build


EDIT:

After spending some time on studying this I have come into a conclusion that you only able to send a string, or an array of data.

And to have an image on the PUSH notification, you would have to send a certain message, which you intercept with your application and then proceed to alter the PUSH notification view to show an image. So there is no build-in image support, or play / stop buttons for that matter? Am I on the right tracks?

  • 写回答

1条回答 默认 最新

  • duanfen2349 2014-07-28 01:38
    关注

    You are right. The payload you are sending from your server to your app via GCM server has no custom properties. It's just a list of key/value pairs contained within the data array, limited to 4K bytes. That's not enough for encoding an image.

    When you receive this payload in your app, it's up to you to decide what to do with it, and it's your responsibility to write the code that handles the message. The most common behavior is to display a notification, and open the app when the notification is tapped. The payload could contain a URL to an image that you can download and display.

    The notifications API in Android has many options, and keeps improving in new Android versions. I'm sure you can use it to achieve your desired behavior. It has nothing to do with GCM though.

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 求差集那个函数有问题,有无佬可以解决
  • ¥15 【提问】基于Invest的水源涵养
  • ¥20 微信网友居然可以通过vx号找到我绑的手机号
  • ¥15 寻一个支付宝扫码远程授权登录的软件助手app
  • ¥15 解riccati方程组
  • ¥15 display:none;样式在嵌套结构中的已设置了display样式的元素上不起作用?
  • ¥15 使用rabbitMQ 消息队列作为url源进行多线程爬取时,总有几个url没有处理的问题。
  • ¥15 Ubuntu在安装序列比对软件STAR时出现报错如何解决
  • ¥50 树莓派安卓APK系统签名
  • ¥65 汇编语言除法溢出问题