Reputation: 3
My app service is android app using phonegap
and push alarm service is one of the app services.
Current our push alarm service is continuously adding a message on upside-status-bar as push notification alarm.
See this >> http://www.givetime.co.kr/qna.png
But i want to replace the message newest one not add, i.e. i want to display only one message on the bar.
How can i replace or How can i display only one message?
this is my push alarm service code.
send alarm code to "https://go.urbanairship.com/api/push/ " as post a json message :
{
"apids": [
"user APID",
],
"android": {
"alert": "You received a message."
}
}
Upvotes: 0
Views: 1415
Reputation: 365
By default, urban airship display all the messages that receives in the status bar, but you can change this behavior but setting your own notification builder and setting the variable constantNotificationId to a integer bigger than 0 in order to replace previous notifications.
Here is an example of how to configure a CustomPushNotificationBuilder in the Android application class:
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);
You can check more information in the Urban Airship documentation
Upvotes: 1