Java 如何自定义GCM消息生成器
我有一切设置,并能够发送与gcm接收。但如何定制收到的通知 代码: emulator中收到的通知:-Java 如何自定义GCM消息生成器,java,android,google-cloud-messaging,Java,Android,Google Cloud Messaging,我有一切设置,并能够发送与gcm接收。但如何定制收到的通知 代码: emulator中收到的通知:- GCM Notification Received: Bundle[{message=testing}] 我想更改标题GCM通知,并删除收到的内容。正在搜索web,但找不到。感谢您的帮助。看看谷歌提供的这份文档,它将解释如何将GCM消息转换为通知: (在“收到信息”部分)。非常感谢您提供的提示。我真傻,我以为无论从gcm服务器(从消息生成器)发送什么消息,都会像在应用程序中一样发布 我不知
GCM Notification
Received: Bundle[{message=testing}]
我想更改标题GCM通知,并删除收到的内容。正在搜索web,但找不到。感谢您的帮助。看看谷歌提供的这份文档,它将解释如何将GCM消息转换为通知:
(在“收到信息”部分)。非常感谢您提供的提示。我真傻,我以为无论从gcm服务器(从消息生成器)发送什么消息,都会像在应用程序中一样发布 我不知道我需要处理从客户端收到的消息
private void sendNotification(String msg) {
mNotificationManager = (NotificationManager)
this.getSystemService(Context.NOTIFICATION_SERVICE);
PendingIntent contentIntent = PendingIntent.getActivity(this, 0,
new Intent(this, DemoActivity.class), 0);
NotificationCompat.Builder mBuilder =
new NotificationCompat.Builder(this)
.setSmallIcon(R.drawable.ic_stat_gcm)
.setContentTitle("GCM Notification") //this is the place I am looking for
.setStyle(new NotificationCompat.BigTextStyle()
.bigText(msg))
.setContentText(msg);
mBuilder.setContentIntent(contentIntent);
mNotificationManager.notify(NOTIFICATION_ID, mBuilder.build());
}
你是说你想更改gcm日志标签/消息?是的。。目前标题为GCM Notification,没有缩略图图片。谁关心日志消息?您可以在应用程序的发布版本中删除它。但是为什么要更改日志消息呢?我是说不是日志。。当你在手机上收到通知时,你会收到“testing”消息以及标题“GCM Notification”。我想编辑该标题,并删除“Received:Bundle[{message=“将测试作为notification中的内容,这是不清楚的。当您谈论通知时,您是谈论从GCM接收的推送消息还是Android中常见的通知,意思是:通知栏中显示的内容。
private void sendNotification(String msg) {
mNotificationManager = (NotificationManager)
this.getSystemService(Context.NOTIFICATION_SERVICE);
PendingIntent contentIntent = PendingIntent.getActivity(this, 0,
new Intent(this, DemoActivity.class), 0);
NotificationCompat.Builder mBuilder =
new NotificationCompat.Builder(this)
.setSmallIcon(R.drawable.ic_stat_gcm)
.setContentTitle("GCM Notification") //this is the place I am looking for
.setStyle(new NotificationCompat.BigTextStyle()
.bigText(msg))
.setContentText(msg);
mBuilder.setContentIntent(contentIntent);
mNotificationManager.notify(NOTIFICATION_ID, mBuilder.build());
}