默认情况下,城市飞艇在状态栏中显示接收到的所有消息,但您可以更改此行为,但设置您自己的通知生成器并将变量constantNotificationId设置为大于 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);
您可以在Urban Airship 文档中查看更多信息