change notification default icon in android?

Viewed 930

I'm using onesignal and trying to change the default notification "bell icon" in the app

so after generating my icon from Android Asset Studio and name it to ic_stat_onesignal_default and add it into /android/app/src/main/res/ folders, after that I uninstall the app and rebuild it, and add it to payload notification "API"

small_icon: 'ic_stat_onesignal_default'

But still, I got the default one (Bell) as a notification icon :(

is there any step I forget?

here's my AndroidManifest.xml file if you wondering

 <manifest xmlns:android="http://schemas.android.com/apk/res/android"
  package="com.salonyUser">

    <uses-permission android:name="android.permission.INTERNET" />
    <uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
    <uses-permission android:name="android.permission.ACCESS_NOTIFICATION_POLICY"/>

    <application
      android:name=".MainApplication"
      android:label="@string/app_name"
      android:icon="@mipmap/ic_launcher"
      android:roundIcon="@mipmap/ic_launcher_round"
      android:allowBackup="false"
      android:theme="@style/AppTheme">
      <meta-data android:name="com.onesignal.NotificationAccentColor.DEFAULT" android:value="0F0F0F" />
      <activity
        android:name=".MainActivity"
        android:label="@string/app_name"
        android:configChanges="keyboard|keyboardHidden|orientation|screenSize|uiMode"
        android:launchMode="singleTask"
        android:windowSoftInputMode="adjustResize">
        <intent-filter>
            <action android:name="android.intent.action.MAIN" />
            <category android:name="android.intent.category.LAUNCHER" />
        </intent-filter>
      </activity>
      <activity android:name="com.facebook.react.devsupport.DevSettingsActivity" />
    </application>

</manifest>

EDIT

After added AndroidManifest.xml

<meta-data
    android:name="com.google.firebase.messaging.default_notification_icon"
    android:resource="@drawable/ic_stat_onesignal_default" /> // I choose mipmap-xxxhdpi icon size for test. :)

I just was wanted to test if firebase meta-data will work or not and Actually it's work and I got the icon I want!! have anybody explanation to this!

2 Answers

You may need to also set both .setSmallIcon() and .setLargeIcon() in the NotificationCompat.Builder

See this answer for additional info: How to set the app icon

Set icon in the NotificationCompat.Builder using .setSmallIcon() for smaller icon and .setLargeIcon() for large icon.

Related