Skip to content

[Feature]: Support configuration of com_braze_push_small_notification_icon (and possibly others) via this plugin #18

@joeyuscca

Description

@joeyuscca

What problem are you facing?

When setting up push notifications for android following the expo docs here there was no mention of custom small icons, as well as other custom configuration that is available through the standard docs via configuration in the braze.xml file.

I was stuck with one of those sexy mono-color squares for a small icon until I stumbled across the standard integration docs and realized what was up.

Screenshot 2023-04-10 at 10 59 01 PM

To simplify the workflow and avoid needing to edit the braze.xml file directly, it'd be nice if some new config options were added to ConfigProps and the ANDROID_CONFIG_MAP so that way these items could be configured when calling, withBraze.

The workaround described allows me to do this by passing config including these to withBraze

  'notificationSmallIcon': '@drawable/notification_icon',
  'notificationAccentColor': '@color/notification_icon_color'

Screenshot 2023-04-10 at 11 24 44 PM

Workarounds

As an npm postinstall I currently run this script to modify ANDROID_CONFIG_MAP and withBrazeAndroid implementation so that I can set notification icon and accent color with the config I pass to withBraze.

const brazeAndroidConstantsPath = `${process.cwd()}/node_modules/@braze/expo-plugin/build/brazeAndroidConstants.js`;
let brazeAndroidConstantsContents = fs.readFileSync(brazeAndroidConstantsPath).toString();
brazeAndroidConstantsContents = brazeAndroidConstantsContents.replace(
  'exports.ANDROID_CONFIG_MAP = {',
  `exports.ANDROID_CONFIG_MAP = {
    "notificationSmallIcon": ["com_braze_push_small_notification_icon", 'drawable'],
    "notificationAccentColor": ["com_braze_default_notification_accent_color", 'color'],`);
fs.writeFileSync(brazeAndroidConstantsPath, brazeAndroidConstantsContents);

const withBrazeAndroidPath = `${process.cwd()}/node_modules/@braze/expo-plugin/build/withBrazeAndroid.js`;
let withBrazeAndroidContents = fs.readFileSync(withBrazeAndroidPath).toString();
withBrazeAndroidContents = withBrazeAndroidContents.replace(`break;
            }`, `break;
                default:
                    brazeXml += \`<\${xmlKeyType} name="\${xmlKeyName}">\${value}</\${xmlKeyType}>\`;
            }`);
fs.writeFileSync(withBrazeAndroidPath, withBrazeAndroidContents);

Ideal Solution

Something along the lines of this...

  • Add the following entries to the ANDROID_CONFIG_MAP portion of src/brazeAndroidConstants.ts:
"notificationSmallIcon": ["com_braze_push_small_notification_icon", 'drawable'],
"notificationAccentColor": ["com_braze_default_notification_accent_color", 'color'],
  • Add the following entries to ConfigProps in src/types.ts:
notificationSmallIcon?: string,
notificationAccentColor?: string
  • Add a default xml tag case to src/withBrazeAndroid - or add new explicit cases for drawable/color if you prefer that
default:
    brazeXml += `<${xmlKeyType} name="${xmlKeyName}">${value}</${xmlKeyType}>`;

Other Information

It'd be worth considering other braze.xml configurable options to add to this type/map as well. Unless there are particular reasons to exclude certain options from being configured via withBraze might as well add them.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions