Android (城市飞艇)如何删除(或更新)以前的推送消息警报?
我的应用程序服务是android应用程序,使用Android (城市飞艇)如何删除(或更新)以前的推送消息警报?,android,cordova,push,Android,Cordova,Push,我的应用程序服务是android应用程序,使用phonegap,推送报警服务是应用程序服务之一 当前,我们的推送报警服务不断在状态栏上添加一条消息作为推送通知报警 查看此>> 但是我想替换最新的消息,而不是添加,即我只想在工具栏上显示一条消息 如何替换或如何仅显示一条消息 这是我的推送报警服务代码 以json消息的形式向“”发送报警代码: { "apids": [ "user APID", ], "android": { "alert": "You received a message." }
phonegap
,推送报警服务是应用程序服务之一
当前,我们的推送报警服务不断在状态栏上添加一条消息作为推送通知报警
查看此>>
但是我想替换最新的消息,而不是添加,即我只想在工具栏上显示一条消息
如何替换或如何仅显示一条消息
这是我的推送报警服务代码
以json消息的形式向“”发送报警代码:
{
"apids": [
"user APID",
],
"android": {
"alert": "You received a message."
}
}
默认情况下,城市飞艇显示状态栏中接收的所有消息,但您可以更改此行为,但可以将自己的通知生成器设置为大于0的整数,以替换以前的通知 以下是如何在Android应用程序类中配置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);
您可以在中查看更多信息,我想知道的是。。如何在我的应用程序启动时删除接收到的警报?您可以在活动中使用和函数
cancelAll()
取消以前显示的所有通知。有没有办法在多次通知的情况下设置默认文本?您可以覆盖CustomPushNotificationBuilder
中的功能buildNotification
,并返回要在多次通知的情况下使用的字符串。您可以在BasicPushNotificationBuilder部分的中阅读更多内容。