Also please note that you should return false
in the onMessage
method. Otherwise there will be shown two notifications: yours and from SDK.
I canât see anything there about passing paramaters to template via api?
You should take a look at Smart Text
section:
https://backendless.com/docs/android/push_notification_content.html#smart-text
Also this topic may be helpful for you:
and
Thanks Maksym, going to try that this afternoon. let you know how I get on.
Ah, ok yes, of course, you could use the smart text as like a substitute for passing in a paramater. I think I get that now.
Perfect, that works how I was hoping it would. Many thanks for your code input.
You are welcome, Mike!
Hi Maksym,
Just another quick question on this code you providedâŚ
void showNotification() {
final NotificationCompat.Builder notificationBuilder;
Context context = getApplicationContext();
String channelName = "channelName";
For channelName, can I somehow get this from this in the msgIntent which is passed into the override onMessage. So if a channel is set in the message template I would like to pick it up here and I canât find a way of doing that?
Hi @mike-turner
The channel name is the same as template name.
To get the template name use the following code:
final String templateName = intent.getStringExtra( PublishOptions.TEMPLATE_NAME );
And to get the template object with all the information about push notification, use:
AndroidPushTemplate template = PushTemplateHelper.getPushNotificationTemplates().get( templateName );
Best Regards,
Maksym
Hi thanks for that, it makes sense.
Strange thing is template name is returning as âImmediateMessageâ
In the backendless console I have setup a template called âandroid_developer_phone_testâ , created and added a channel called testChannel to this template.
So you would expect it to return âandroid_developer_phone_testâ correct ? I donât have any channels or templates called âImmediatMessageâ so confused as where that is coming from.
Mike
You receive the âImmediateMessageâ name if you send the notification from Console.
When you send the notification using API
Backendless.Messaging.sendWithTemplate()
you will receive the real template name.
Best Regards
Ah ok, no probs, I can just send it through the header in the console as a work around.