首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >(城市飞艇)如何删除(或更新)以前的推送消息警报?

(城市飞艇)如何删除(或更新)以前的推送消息警报?
EN

Stack Overflow用户
提问于 2013-05-14 12:31:55
回答 1查看 1.2K关注 0票数 0

我的应用程序服务是使用phonegap的安卓应用程序,推送警报服务是应用程序服务之一。

目前我们的推送告警服务正在不断的在上方状态栏添加一条消息作为推送通知告警。

查看此>> http://www.givetime.co.kr/qna.png

但我想要替换消息最新的一个不添加,即我想在栏上只显示一条消息。

如何替换或仅显示一条消息?

这是我的推送报警服务代码。

以json消息的形式向"https://go.urbanairship.com/api/push/“发送告警代码:

代码语言:javascript
复制
{
"apids": [
"user APID",
],
"android": {
"alert": "You received a message."
}
}
EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2013-05-14 13:02:30

默认情况下,城市飞艇在状态栏中显示接收到的所有消息,但您可以更改此行为,但请设置您自己的通知构建器,并将变量constantNotificationId设置为大于0的整数,以替换以前的通知。

以下是如何在安卓应用类中配置CustomPushNotificationBuilder的示例:

代码语言:javascript
复制
 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中查看更多信息

票数 1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/16535164

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档