Support Topics Documentation Slack YouTube Blog

Obtaining custom notification header in Android

(Milen Marinov) #1


When sending a custom push notification (not from a template) through the SDK I set a custom header like so:

                publishOptions.putHeader("signalId", signalId);

How can I obtain that header when the notification is opened in Android?


(Anton Govorushkin) #2

Hi, please checkout the documentations for getting headers value -
It’s described at the very bottom


(Milen Marinov) #3

Hi Anton,

This is what the linked documentation says:
// if retrieving in a button handling activity:
Intent intent = this.getIntent();
String headerValue = intent.getStringExtra( “sample_header_name” );

However, I don’t have buttons on my notifications and use them to launch the app when the user taps the notification itself. The intent of the main activity that is launched has no extras. So I don’t know how to obtain the notification info in this use case.


(Oleg Vyalyh) #4

Hi, Milen.
For now we can only advise to construct a template (based on your message data) and retrieve headers from it.
You no need to use buttons in templates to get your headers. They will be available just in the intent, that comes into activity handler on a tap.

(Milen Marinov) #5

Hi Oleg,

I don’t use a template because I need to customize the notification from code and as far as I know you cannot customize templates.
The two specific things I need are:

  1. Deliver notification to particular devices that are determined dynamically in code
  2. Add custom header information that is also dynamic

(I know about Smart Text but it doesn’t achieve the job in this case as the info is not directly related to the user, receiving the notification)

Any suggestion on how I can retrieve custom header information in Android while achieving the above two requirements? I can successfully do this in iOS but not in Android.


(Anton Govorushkin) #6

Hi @milen-marinov

I believe for now getting header values is available only from Intent if notification was sent from a template. I’ve scheduled a task to add a feature for extracting header values in Android for the rest of the cases. We’ll notify you as soon the task is complete. I think it’s a matter of 1-2 weeks


(Milen Marinov) #7

Hi Anton,

Thanks a lot!

(Milen Marinov) #8

Hi Anton,

Can you update me on the progress of this task? I really need this functionality and missing it is blocking work on my app :frowning:


(Milen Marinov) #9

Hello? Can I get some attention on this topic?

(Sergey Kukurudzyak) #10

The fix in the repo now we will release android sdk on this week

(Milen Marinov) #11

Great! Thanks for the update! Looking forward to the new release!