Push notifications headers

Hi,

Trying to get back header and notification values in the overrideable onMessage method in class that extends BackendlessFCMService

I can retrieve the message with:
msgIntent.getStringExtra(“message”)

but am having trouble getting the title
I tried msgIntent.getStringExtra(“content-title”) but getting null

I am also using a custom header called message_id in the template and I cannot get this data back either
I tried msgIntent.getStringExtra(“message_id”) - again getting null

Mike

Hi, Mike!
Can you post your Backendless app ID?

Regards, Andriy

Hi Andriy

it is E9DF3457-FBDF-4D42-A6F3-FDFF2C260FF6

OK I am having lots of problems on the Android side of push.

All I want to do really is have a mechanism of telling the push notification on android to go to a different activity when the push notification is clicked upon.

So I tried a couple of things.

  1. overriding the onMessage method in a class which exends BackendlessFCMService and try and change the intent of the notification, but I can’t get this to work. It doesn’t seem to change the destination activity, it makes no difference

This is where I noticed that I can’t get the header values in this method. Update on this, I can get the header values if they are set with smartText in the template composer. This jogged my memory - It seems to be what we figured out a long time ago and maybe it isn’t fixed yet?! See:

  1. I can however pick up the header values as the main activity loads on a push notification click. Really weird thing is that sometimes it picks up old push notifications which have been sent. I just don’t get that, maybe that is just a weird developer phone bug. The messages I get in the onMessage method are always the correct ones.So I don’t think I want to rely on this method either!

Please please, all I really want to solve is how to change the activity which the push notification will go to when the notification is clicked. I can’t use the buttons option.

Any help appreciated as been stuck on this for ages now!

Mike

Hi Andriy

MY BAD!! You have fixed the getting header problem in onMessage method. I had not updated backendless to latest version. Apologies for that.

Any idea though how to help me go to a different activity on notification click?

Mike

Hi @mike-turner

I described how to get to a different activity on notification click here:

Thanks Maksym, I got the link.

Just a quick one here, how can I get these properties from the template notification in the extended BackendlessFCMService?

message: (working) msgIntent.getStringExtra(“message”)
header message: (working) msgIntent.getStringExtra(“header_name”)

but title and sub title?
not working: msgIntent.getStringExtra(“contentTitle”)
not working: msgIntent.getStringExtra(“summarySubText”)

Thanks for your help

sometimes it picks up old push notifications which have been sent

It means that notification’s extras are not updated when a new notification comes.
You should read more about building the notification. Take a look at PendingIntent options (notificationID and PedingIntent flags: PendingIntent  |  Android Developers)

Best Regards

how can I get title and sub title from the template notification

I will take a look and respond you as soon as possible.

Best Regards,

If you want to get template, that was previously created in web-console use such a code:

final String templateName = intent.getStringExtra( PublishOptions.TEMPLATE_NAME );
AndroidPushTemplate template = PushTemplateHelper.getPushNotificationTemplates().get( templateName );

got it - msgIntent.getStringExtra(“android-content-title”)

Please take into account that some constants from PublishOptions was used in the previous implementations of our messaging.
The new one is Push Templates.