我的应用程序服务是使用phonegap的安卓应用程序,推送警报服务是应用程序服务之一。
目前我们的推送告警服务正在不断的在上方状态栏添加一条消息作为推送通知告警。
查看此>> http://www.givetime.co.kr/qna.png
但我想要替换消息最新的一个不添加,即我想在栏上只显示一条消息。
如何替换或仅显示一条消息?
这是我的推送报警服务代码。
以json消息的形式向"https://go.urbanairship.com/api/push/“发送告警代码:
{
"apids": [
"user APID",
],
"android": {
"alert": "You received a message."
}
}发布于 2013-05-14 13:02:30
默认情况下,城市飞艇在状态栏中显示接收到的所有消息,但您可以更改此行为,但请设置您自己的通知构建器,并将变量constantNotificationId设置为大于0的整数,以替换以前的通知。
以下是如何在安卓应用类中配置CustomPushNotificationBuilder的示例:
CustomPushNotificationBuilder nb = new CustomPushNotificationBuilder();
nb.layout = R.layout.notification_layout; // The layout resource to use
nb.layoutIconDrawableId = R.drawable.notification_icon; // The icon you want to display
nb.layoutIconId = R.id.icon; // The icon's layout 'id'
nb.layoutSubjectId = R.id.subject; // The id for the 'subject' field
nb.layoutMessageId = R.id.message; // The id for the 'message' field
//set this ID to a value > 0 if you want a new notification to replace the previous one
nb.constantNotificationId = 100;
//set this if you want a custom sound to play
nb.soundUri = Uri.parse("android.resource://"+this.getPackageName()+"/" +R.raw.notification_mp3);
// Set the builder
PushManager.shared().setNotificationBuilder(nb);您可以在Urban Airship documentation中查看更多信息
https://stackoverflow.com/questions/16535164
复制相似问题