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

[question]: Set small icon accent color #183

Closed
1 task done
dakshshah96 opened this issue Apr 29, 2023 · 4 comments · Fixed by #196
Closed
1 task done

[question]: Set small icon accent color #183

dakshshah96 opened this issue Apr 29, 2023 · 4 comments · Fixed by #196
Labels
Enhancement / Feature New feature or request

Comments

@dakshshah96
Copy link

dakshshah96 commented Apr 29, 2023

How can we help?

Just like how one can specify smallIcons in the app config, is it also possible to define the small icon accent color in the same place? If not, that would be a great feature to implement in this SDK.

Is there any workaround to set the accent color in the meanwhile?

OneSignal Expo SDK version

1.3.2

Platform

Android

Relevant log output

No response

Code of Conduct

  • I agree to follow this project's Code of Conduct
@rgomezp rgomezp added the Enhancement / Feature New feature or request label May 15, 2023
@karengrigoryan
Copy link

A custom config plugin can be used as a temporary solution, based on the Android SDK documentation.

Something along these lines:

// plugins/one-signal-android-icon-accent/withOneSignalAndroidIconAccent.js

import { withStringsXml } from '@expo/config-plugins';

/**
 * A simple config plugin for One Signal that sets the push notification icon accent color on Android.
 *
 * @see {@link https://documentation.onesignal.com/docs/customize-notification-icons#set-default-small-icon-and-accent-colors} Set default Small Icon and Accent Colors
 * @see {@link https://github.com/OneSignal/onesignal-expo-plugin/issues/183} Related GitHub issue
 */
export function withOneSignalAndroidIconAccent(config, props) {
  return withStringsXml(config, (config) => {
    const colorInARGB = `FF${props.color.replace('#', '')}`;
    const strings = config.modResults.resources.string ?? [];
    const accentColorEntry = {
      $: { name: 'onesignal_notification_accent_color' },
      _: colorInARGB,
    };

    config.modResults.resources.string = [...strings, accentColorEntry];

    return config;
  });
};

export default withOneSignalAndroidIconAccent;
// app.config.js

module.exports = {
  expo: {
    // ...
    plugins: [
      ['onesignal-expo-plugin', { //... }],
      ['./plugins/one-signal-android-icon-accent/withOneSignalAndroidIconAccent.js', { color: '#e3e3e3' }]
    ]
  },
}

@AdamGerthel
Copy link

@karengrigoryan this is great! Could easily create a PR for this, no?

@AdamGerthel
Copy link

Small update: The script adds the line every time it's run no matter if it already exists or not, which isn't ideal for bare workflows (i.e. when the ios/android folders exist in the project already). Might want to add a check.

@rgomezp
Copy link
Contributor

rgomezp commented Sep 11, 2023

@AdamGerthel I have created a PR for this. Please feel free to test it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Enhancement / Feature New feature or request
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants