i have everything setup and able to send receive with gcm. but how to customized the notification received?
Code:
Message message = new Message.Builder()
.addData("message", "testing")
.build();
Notification received in emulator:-
GCM Notification
Received: Bundle[{message=testing}]
I would like to change the title GCM Notification and remove those received stuff. Been searching the web and unable to find. Thanks for your help.
看看Google提供的这份文档,它将向您说明如何将GCM消息转换为通知: http : //developer.android.com/google/gcm/client.html (“接收消息”部分)。
Thank you so much for the tips. Silly me, I thought whatever msg sent from gcm server(from the message builder) will be posted as it is in the app.
Didn't know i need to process the msg received from the client itself
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());
}
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.