[英]How to customize GCM Message Builder
我已完成所有设置,并能够通过gcm发送接收消息。 但是如何定制收到的通知?
码:
Message message = new Message.Builder()
.addData("message", "testing")
.build();
在模拟器中收到通知:
GCM Notification
Received: Bundle[{message=testing}]
我想更改标题GCM通知并删除那些收到的内容。 正在搜索网络,无法找到。 谢谢你的帮助。
看看Google提供的这份文档,它将向您说明如何将GCM消息转换为通知: http : //developer.android.com/google/gcm/client.html (“接收消息”部分)。
非常感谢您的提示。 愚蠢的我,我想从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());
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.