Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

On Android setSmallIcon when used with an XML resource adds unneeded padding, makes notification icon look incorrect. #21

Open
shamilovtim opened this issue Jul 21, 2021 · 6 comments

Comments

@shamilovtim
Copy link
Contributor

shamilovtim commented Jul 21, 2021

Our notification icon is an XML resource. As you can see the icon is not scaled correctly and seems to have padding. When used with pure FCM push (no Responsys) the icon appears correctly and at the right size. Also it would be nice if you provided a setIconColor function (for default_notification_color) in order to style the icon for when the icon is provided in XML format. When a PNG resource is used, the icon appears correctly in Responsys. So this is an incompatibility with XML icons.

Is there a reason you can't use the default icon settings that are already passed to FCM in AndroidManifest?

The native code is as follows:

      // if it's a responsys push, set the icon and handle it with Responsys
        if (pushIOManager.isResponsysPush(remoteMessage)) {
            String appName = reactContext.getPackageName();
            int notificationIconID = reactContext.getResources().getIdentifier("ic_launcher_foreground", "drawable", appName);
            pushIOManager.setDefaultSmallIcon(notificationIconID);
            pushIOManager.setDefaultLargeIcon(notificationIconID);
            pushIOManager.handleMessage(remoteMessage);
        } else {
            // Otherwise not a Responsys push notification, handle it through FCM only
            FCMModule.onMessageReceived(reactContext, dataMap);
        }

Responsys:
Screen Shot 2021-07-21 at 3 19 10 PM
Screen Shot 2021-07-21 at 3 19 18 PM

FCM:
Screen Shot 2021-07-21 at 3 21 53 PM
Screen Shot 2021-07-21 at 3 21 45 PM

@shamilovtim shamilovtim changed the title On Android setSmallIcon adds unneeded padding, makes notification icon look incorrect. On Android setSmallIcon when used with an XML resource adds unneeded padding, makes notification icon look incorrect. Jul 21, 2021
@neerhaj
Copy link
Member

neerhaj commented Jul 21, 2021

Please share the XML file that has this issue.

@shamilovtim
Copy link
Contributor Author

@neerhaj
Copy link
Member

neerhaj commented Jul 26, 2021

The xml you have shared is for launcher icon.

When a launcher icon xml is used as a notification icon, there is a padding added by the system.

Firebase SDK reads the icon xml as a launcher icon, so the padding is not added by the system.

Responsys SDK reads the icon xml as a notification icon, so the padding is added by the system.

There are two ways to resolve this,

  1. Don't set the small Icon in Responsys SDK. This will force the Responsys SDK to read the icon as a launcher icon.
    OR
  2. Create a copy of the launcher icon xml and use it as a notification icon.
    -- In Android Studio, go to File > New > Image Asset
    -- Select Icon Type as Notification Icons and Asset Type as Image.
    -- Pick the icon xml file in the Path entry.
    -- Once the icon xml is loaded, you should be able to see the extra padding added (even though Padding displays 0%).
    -- To remove the padding, select Trim as Yes and save the file.

@shamilovtim
Copy link
Contributor Author

shamilovtim commented Aug 17, 2021

Just wanted to let you know the following does not work.

Don't set the small Icon in Responsys SDK. This will force the Responsys SDK to read the icon as a launcher icon.

Not setting the icon in Responsys causes a blank white circle icon. Otherwise we wouldn't be setting the icon in Responsys at all. Can you just make Responsys use the FCM / App icon from the AppManifest?

@shamilovtim
Copy link
Contributor Author

Hello @neerhaj just checking back in. Any plans to allow Responsys to use the app icon like FCM does? If we don't set the icon in Responsys, it shows up as a white dot.

@neerhaj
Copy link
Member

neerhaj commented Sep 29, 2021

We are looking into the possible ways to allow apps to set the smallIcon. We'll get back with an update shortly.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants