-
Notifications
You must be signed in to change notification settings - Fork 11
Description
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.
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'
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_MAPportion ofsrc/brazeAndroidConstants.ts:
"notificationSmallIcon": ["com_braze_push_small_notification_icon", 'drawable'],
"notificationAccentColor": ["com_braze_default_notification_accent_color", 'color'],- Add the following entries to
ConfigPropsinsrc/types.ts:
notificationSmallIcon?: string,
notificationAccentColor?: string- Add a default xml tag case to
src/withBrazeAndroid- or add new explicit cases fordrawable/colorif 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.

