1

我正在通过 GCM 发送消息,但我找不到通过 GCM 消息发送图像和网站链接的方法......到设备,因此如果我们点击通知,则应该打开 Web 链接或必须下载或显示图像.. ?

4

3 回答 3

4

我写了两篇博客文章,描述了两种方法:教程:使用 AirBop 在消息负载中发送图像和教程:使用 AirBop 推送图像以获取 BigPictureStyle 通知帖子使用AirBop作为其应用程序服务器,但您可以使用相同的与您与 GCM 一起使用的任何服务器的想法。

于 2013-01-19T20:26:54.800 回答
4

您可以在 GCM 消息中发送网络链接

在客户端 ( GCMIntentService ) -

@Override
protected void onMessage(Context context, Intent intent) {

String uriStr = intent.getStringExtra(FIELD_MESSAGE);
//FIELD_MESSAGE is the same key used while sending links from server
Intent notificationIntent = new Intent(Intent.ACTION_VIEW,  Uri.parse(uriStr));

  PendingIntent contentIntent = PendingIntent.getActivity(context, 0, notificationIntent, 0);
  notification.setLatestEventInfo(context, contentTitle, contentText, contentIntent);
  mNotificationManager.notify(970970, notification);
}
于 2013-01-18T10:15:36.183 回答
0

我会这样处理 1)将 GCM 通知与 URL 一起发送到客户端 2)根据收到的 URL,下载图像 3)下载后,保存图像并设置通知

于 2014-05-06T14:37:47.480 回答