0

I increased notifications in my app through the OneSignal plugin, I would like to customize the icon and sound of the notification, I followed the documentation, but it did not work.

What could I have done wrong? Here is a print of my config.xml

enter image description here

The code config.xml:

<platform name="android">
    <allow-intent href="market:*" />
    <resource-file src="resources/android/sound/open-ended.mp3" target="platforms/android/res/raw/open-ended.mp3" />
    <icon density="ldpi" src="resources/android/icon/drawable-ldpi-icon.png" />
    <icon density="mdpi" src="resources/android/icon/drawable-mdpi-icon.png" />
    <icon density="hdpi" src="resources/android/icon/drawable-hdpi-icon.png" />
    <icon density="xhdpi" src="resources/android/icon/drawable-xhdpi-icon.png" />
    <icon density="xxhdpi" src="resources/android/icon/drawable-xxhdpi-icon.png" />
    <icon density="xxxhdpi" src="resources/android/icon/drawable-xxxhdpi-icon.png" />
</platform>

the app.component.ts:

this.oneSignal.inFocusDisplaying(this.oneSignal.OSInFocusDisplayOption.InAppAlert);
this.oneSignal.handleNotificationReceived().subscribe(data => {
  data.payload.sound = 'open-ended',
  data.payload.smallIcon = 'drawable-hdpi-icon'
});
this.oneSignal.handleNotificationOpened().subscribe(() => {
  // do something when a notification is opened
});
this.oneSignal.endInit();

I'm using cordova-android:7.1.4, and onesignal-cordova-plugin:2.4.5

Jaqqe
  • 1
  • 1
  • Welcome to Stack Overflow ! You are more likely to receive support from the community if you post your code directly in the question rather than linking to some other location. – GMB Dec 16 '18 at 02:36
  • You need to do this on server end not on client end. This handler is to handle action on notification on client. Changing property inside it won't change anything. Check this https://documentation.onesignal.com/docs/customize-notification-icons – dhavalcengg Dec 16 '18 at 09:42
  • But i pass in onesignal panel the sound name and not work. I'm test in OneSignal message panel – Jaqqe Dec 16 '18 at 17:59
  • [follow this link](https://stackoverflow.com/questions/52474275/how-to-change-default-push-notification-icon-to-small-icon-in-onesignal-in-ionic?answertab=active#tab-top) how to send custom icon in one signal – naveen pandi Aug 22 '19 at 07:09

1 Answers1

0
<resource-file src="resources/android/sound/mysound.wav" target="app/src/main/res/raw/mysound.wav" />

This is how i placed and it works. For Android 8+ you need to create notification category in onesignal settings

  • can you please check [this](https://stackoverflow.com/questions/64580338/change-notification-default-icon-in-onesignal-react-native) – Oliver D Oct 28 '20 at 21:23