Another topic about icons

Hi @Roberio_Lima

To set a custom icon for the push notification please follow the next steps:

  1. Locate your icon in the drawable or mipmap directory.
  2. Create the push template and set the value of “Small Icon” field to the name of your icon (but without file extension).
  3. Save the template and send the notification from Console or with API.

Here is the example:

You can also check the documentation for the Android Push Configuration.

Best Regards,
Maksym

Thank you for your answer @Maksym_Khobotin!

As I expected, this method worked to show the push notification with the app’s icon, but is there a way to send push notifications using templates with a custom text that is generated from user’s actions in the app?

Because in the docs the only option that I saw using templates, it was the one to send push notifications with custom informations coming from the Backendless database.

Regards,
Roberio

Yes, of course. You can use smart-text:
https://backendless.com/docs/android/push_notification_content.html#smart-text

and pass the values via
Backendless.Messaging.pushWithTemplate( String templateName, Map<String, String> templateValues) call.

For example:
Specify the message in the push template:
Here is my custom text: {custom_text}

and pass the custom_text value into templateValues:

templateValues.put("custom_text", "Some user-unique text");
Backendless.Messaging.pushWithTemplate("TestTemplate", templateValues, new AsyncCallback...);

You will receive the notification with following message:
Here is my custom text: Some user-unique text

Hi @Maksym_Khobotin,

I’m working in others two projects and I only could return to work in this app today. I had two issues.

Using the template with the icon setted I can send push notifications by the Backendless dashboard and it’s delivered with the icon like I wrote before.
But the same doesn’t happen when I use the command Backendless.Messaging.pushWithTemplate inside the app. Instead of the icon the notification shows the white square.

The second issue is I couldn’t send a custom text with the suggested method.
Maybe I did it wrong but I tried the following:

let templateValues = new Map();
templateValues.set(“msg”, “Sending a test message”);

Backendless.Messaging.pushWithTemplate(“Test”, templateValues);

And I only received an empty notification.

Regards,
Roberio

Hi @Roberio_Lima

About icon:
I sent the notification from the Console and with API. For both cases I received the notification with the custom icon. Please check if you use the same template for both cases.
It’s also can be the emulator problem. Please try to run your app on the real device and send the notification with command Backendless.Messaging.pushWithTemplate.

About custom text:
I checked the code sample you provided and it worked fine for me. Don’t you forget to add the custom text variable to your notification? For example:
image

You should receive the notification with message:
My message: Sending a test message

Best Regards,
Maksym

Hi @Maksym_Khobotin,

Yes, I used the same template. When I tried again today I decided to create a new template and tested the notifications in three devices. I rarely developing using emulators, I always prefer run the app in real devices.

The problem related with the icon only happened with one of the devices. In the others two the notification reached showing the custom icon. However the custom message didn’t arrive with the notifications.

The code I used it was the same described before only changing the template name to “TestWithIcon”.

Thanks
Roberio

Images:

dash

notificationsv1

notificationsv3

Hi @Roberio_Lima

Please specify your Application ID

Best Regards,
Maksym

Hello @Maksym_Khobotin,

App ID: D24CBE9E-09B0-1A8C-FF9A-293720B9DB00

Regards,
Roberio

Thanks, I will check this out!

Hi @Roberio_Lima

I’ve created the internal ticket BKNDLSS-20889. We will update you with a progress.

Best Regards,
Maksym

Hi @Roberio_Lima

I’ve reproduced the issue. We will add the smart-text support for React Native and publish the release soon.

Best Regards,
Maksym

Hi @Maksym_Khobotin,

It’s great news! Thank you!
This will be very helpful for others developers and projects that use the React-Native because I think the Backendless service is one of the best that I tested/used.

Best Regards,
Robério

We are very glad to hear it!

And thank you for pointing out the issue!

We’ve resolved the issue and published an update, @Roberio_Lima

Please run

npm i backendless -S

to update Backendless SDK and after that use

Backendless.Messaging.pushWithTemplate('TestWithIcon', { msg: 'My value' });

to send TestWithIcon template notification with msg value of My value.

Best Regards,
Maksym

Hi @Maksym_Khobotin,

I could only test it today and it worked as the expected.
Thanks for your attention and thanks for your attention too @vladimir-upirov!

Best Regards,
Roberio

Ok, one last thing because even with method pushTemplate working as expected, however mybe it can’t be useful to the situation that I really need.

I looked in the other topics and I found this one: Notification from a push template to individual device(s)

There he asked about using the pushTemplate to send messages to individual devices, the answer was this feature wasn’t implemented yet but it will be in the future.

I couldn’t find but is there an equivalent for the smart text of the custom message to specify the segment? For example, clause like deviceId = “yhjfhdj98”

Best Regards,
Roberio

Hello, @Roberio_Lima,
In Push Templates you can use segments to specify individual devices, e.g.

deviceId='16747669-...' OR deviceToken='67a100...'

Regards,
Olha

Hi @olhadanylova,

Thanks, but I think I didn’t ask the question appropiatedly, for example, like above where it’s possible to send a parameter to a custom message using the {msg}, I couldn’t identify something similar to specify the clause.
Using the example it would be something like deviceId = {id}

Regards,
Roberio

Ah, sorry for misunderstanding.
We don’t have this feature right now, but we have it on our roadmap. I assume it will be available later this year but I can’t say the exact time.

Regards,
Olha

The app was tested a while by a group and they solicited some changes and indicated one or other bug.

One of the things I returned it was this problem involving the icon in the push notifications. After some observations I perceived the code was taking the app’s icon instead of the indicated resource in the drawable or mipmap.

I will describe what I did because maybe it can help others that face this problem in the future.

The function that define the icon is the “setSmallIcon” and it’s in the file RNBackendlessPushNotificationHelper.java.
Initially I added in the AndroidManifest.xml inside the application tag the following piece:
android:logo="@mipmap/ic_stat_pushicon"

And inside the setSmallIcon function in this part of the code:

if (smallIcon == 0) {

        smallIcon = appContext.getApplicationInfo().icon;

        if (smallIcon == 0) {
            smallIcon = android.R.drawable.sym_def_app_icon;
        }

}

I changed the “appContext.getApplicationInfo().icon” to “appContext.getApplicationInfo().logo” and now it shows the aproppriated icon with the push notifications.