How to change the notification message in Android to localised it? I just want to change the message what I get from Urban AirShip before it will be display on notification bar?
-
do you want to modify the message coming from server ??? – Dinesh Sharma Feb 20 '12 at 11:13
-
Yes, I just need to change the message before notification method will display it. – goodm Feb 20 '12 at 11:23
5 Answers
You can using this method: PushManager.shared().setNotificationBuilder(null);
and send your own notification with android notification from the SDK

- 31,209
- 11
- 51
- 83

- 71
- 1
- 4
-
Thanks, I was looking for a way to disable the default notification – Climbatize Apr 10 '12 at 12:13
I read the answers and came up with a combined solution.
You want to disable UrbanAirship's default notification handler. If you do that, it won't generate and show you the notifications at all.
PushManager.shared().setNotificationBuilder(null);
(Using David T's suggestion)You want to build your own notification. This can be done inside your
IntentReceiver
. This link will do the trick.
Hope this helps others.

- 1
- 1

- 1,057
- 2
- 11
- 26
Please using that code to disable Urban Airship's notifications, override BasicPushNotificationBuilder:
BasicPushNotificationBuilder nb = new BasicPushNotificationBuilder() {
@Override
public Notification buildNotification(String alert,
Map<String, String> extras) {
return null;
}
};
// Disable notifications
PushManager.shared().setNotificationBuilder(nb);

- 199
- 1
- 1
- 10
Yes you can modify the message once you receive the message from Urban AirShip for your internal use in the app but can't show the modified message in the notification bar.
You can check the message in your IntentReceiver
public class IntentReceiver extends BroadcastReceiver {
private static final String logTag = "Hey";
@Override
public void onReceive(Context context, Intent intent) {
Log.i(logTag, "Received intent: " + intent.toString());
String action = intent.getAction();
if (action.equals(PushManager.ACTION_PUSH_RECEIVED)) {
int id = intent.getIntExtra(PushManager.EXTRA_NOTIFICATION_ID, 0);
Log.v(logTag, "Received push notification. Alert: " + intent.getStringExtra(PushManager.EXTRA_ALERT)
+ ". Payload: " + intent.getStringExtra(PushManager.EXTRA_STRING_EXTRA) + ". NotificationID="+id);
//can get your message here
} else if (action.equals(PushManager.ACTION_NOTIFICATION_OPENED)) {
Log.v(logTag, "User clicked notification. Message: " + intent.getStringExtra(PushManager.EXTRA_ALERT)+ ".Payload:" + intent.getStringExtra("PushManager.EXTRA_STRING_EXTRA"));
Intent launch = new Intent(Intent.ACTION_MAIN);
UAirship.shared().getApplicationContext().startActivity(launch);
} else if (action.equals(PushManager.ACTION_REGISTRATION_FINISHED)) {
Log.i(logTag, "Registration complete. APID:" + intent.getStringExtra(PushManager.EXTRA_APID)
+ ". Valid: " + intent.getBooleanExtra(PushManager.EXTRA_REGISTRATION_VALID, false));
}
}
}

- 11,533
- 7
- 42
- 60
-
ok, so if I want to handle notification in other way? Just react on it by my way, dont use the default system from Urban AirShip? – goodm Feb 20 '12 at 11:41
-
see you can create your own custom layout with icon images to show on the notifcation bar , please download sdk sample code from Urban airship resource , you can see there a file named notification.xml that can be used as showing in notification bar....any other thing do you want...??? – Dinesh Sharma Feb 20 '12 at 11:46
-
I need to localised the message, so before it appear on notification bar I need to change it. Urban AirShip I want to use only to trigger the event. – goodm Feb 20 '12 at 11:53
-
as I told you already that you can't show the modified message on notification it will be handled automatically. – Dinesh Sharma Feb 20 '12 at 12:09
-
I found the solution, its kind a dirty one, but right know I need to use this. Just after get notification from Urban AirShip I cancel all and send my own with changed message.

- 7,275
- 6
- 31
- 55