2

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!

Oliver D
  • 2,579
  • 6
  • 37
  • 80

2 Answers2

0

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

thomasciv
  • 120
  • 6
  • Sorry, I'm not an Android developer, but where should I add this builder? I'm using a `react-native-onesignal` and it's not mentioned about this before! So could you help in this case where should I achieve it? – Oliver D Oct 29 '20 at 07:55
  • Hey again :) @thomasciv, I just updated the Q, Can you please check the Edit section above? – Oliver D Oct 29 '20 at 23:32
  • @OliverD Either one would probably have to be registered in the manifest file. You might try something like this to get the it working without firebase: `com.onesignal.messaging.default_notification_icon` for the name. – thomasciv Oct 30 '20 at 00:01
  • Yes, its work :D but I'm just why with firebase also work – Oliver D Oct 30 '20 at 00:33
  • 1
    Possibly wherever you are referencing the `android:name` from the manifest file, it will tie back to the correct icon regardless of whether you're actually using Firebase. The `name/value` pair should be all that's important. As long as you have a meta-data tag in the manifest. – thomasciv Oct 30 '20 at 00:37
  • Fair enough you're right, and you should use the name `ic_stat_onesignal_default` otherways will not work and will appear the bell default icon :)). Thanks for your time. – Oliver D Oct 30 '20 at 00:43
0

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

Sid009
  • 421
  • 5
  • 16
  • As I said before to @thomasciv where should I put these things as I'm using react native onesignal? – Oliver D Oct 29 '20 at 11:00