0

I have an Ionic 5 application which handles perfectly push notification on platform Android.
But when I would like to set custom sound like customring.wav, it doesn't work..
I have already copied the mentioned file into res/raw folder however it doesn't work as I expected.
When the device receives a notification the device's default notification sound plays every time...
For fcm we use this one: https://ionicframework.com/docs/native/fcm

Our server sends the following json:

{
  "message": {
    "name": null,
    "data": null,
    "notification": {
      "title": "auction",
      "body": "lorem ipsum etc..",
      "image": null
    },
    "android": {
      "collapse_key": null,
      "priority": null,
      "ttl": null,
      "restricted_package_name": null,
      "data": null,
      "notification": {
        "title": null,
        "body": null,
        "icon": null,
        "color": null,
        "sound": "customring",
        "tag": null,
        "click_action": null,
        "body_loc_key": null,
        "body_loc_args": null,
        "title_loc_key": null,
        "title_loc_args": null,
        "channel_id": null,
        "ticker": null,
        "sticky": null,
        "event_time": null,
        "local_only": null,
        "notification_priority": null,
        "default_sound": null,
        "default_vibrate_timings": null,
        "default_light_settings": null,
        "vibrate_timings": null,
        "visibility": null,
        "notification_count": null,
        "image": null
      },
      "fcm_options": null
    },
    "webpush": null,
    "apns": null,
    "fcm_options": null,
    "token": null,
    "topic": "auctions",
    "condition": null
  }
}

Should I set anything else to work as I mentioned above?

Beller
  • 828
  • 1
  • 6
  • 19
  • I think the file should be .mp3 and not .wav – Mostafa Harb May 14 '20 at 01:40
  • We have tried it, but didn't work. – Beller May 14 '20 at 13:17
  • Ah this is not onesignal or fcm notification, its a static notification like local notification right? – Mostafa Harb May 14 '20 at 13:20
  • No, it's a push notification, fcm – Beller May 14 '20 at 13:23
  • Maybe try to put sound at main level of android and not inside notification, like android.sound and ios.sound and not android.noyification.sound.... – Mostafa Harb May 14 '20 at 13:30
  • Same result.. I have tried to add FCMPlugin.createNotificationChannelAndroid() but same https://github.com/andrehtissot/cordova-plugin-fcm-with-dependecy-updated – Beller May 14 '20 at 14:19
  • No no i mean like this ...,"android": { sound : "customring",... }, ... – Mostafa Harb May 14 '20 at 16:01
  • We have tried it in playload, but same – Beller May 14 '20 at 16:21
  • Ok wait, if you make the notification with no sound , will it work? What i need to see is if the objects inside android part are being read via fcm, i used onesignal before and even fcm and didn't remember i need to defragment each platform, check if this syntax android : {...} is correct – Mostafa Harb May 14 '20 at 16:24
  • We had tried without sound in playload, but the default notification sound played – Beller May 14 '20 at 16:44
  • https://stackoverflow.com/questions/52929138/no-custom-sound-with-android-firebase-notification ,check this link , its for native android but get the stratagy its made with. – Mostafa Harb May 14 '20 at 17:51
  • We have tried everything what the link above contains. However didn't work. – Beller May 15 '20 at 16:59
  • Look, now you have pit the custom ring in the device destination folder, try to go to firebase console, and send a notification and set ringingtone from the interface, and check if it works or not, if it didn't then try on higher sdk version device , maybe 28+, i usually use onesignal and not much familier with notfication properties of fcm. So try from firebase console and then tell me what happens with you. – Mostafa Harb May 15 '20 at 17:27
  • I have tried but same... it played the default notification sound. We set it without sound in firebase console, but played the sound... – Beller May 15 '20 at 17:44
  • Then sound file is not positioned in its correct place, wait i'll go make fast search and brb. – Mostafa Harb May 15 '20 at 17:47
  • https://youtu.be/5UDqjTXGl0k , check this video, its in indian language and i don't understand, but he made steps, i think he was testing on api 26 and didn't work but it worked on api lvl 25, try and do his steps, and as i told you the way you are sending the notficifation is wrong, check where sound property is located, and if didn't work tell me so i can make another search or make it myself for you.. – Mostafa Harb May 15 '20 at 17:55
  • Where should I put the createChannel part? Maybe this is what I have screwed up.. – Beller May 19 '20 at 20:53
  • At the end I have changed to NativeScript and it works.. – Beller May 25 '20 at 07:09
  • hmmm, its bad to change programming language for a single thing... – Mostafa Harb May 26 '20 at 10:28
  • Yeah.. I hate it, because I have put many hours in ionic project. However I like learning new things. On the other hand I think it should have worked with android 25. – Beller May 26 '20 at 10:31
  • What i mean is that you could try more or change the notficiation to onesignal, except if there are problems other than notdiciation sound, but anyway did you find working with nativescript better than ionic? – Mostafa Harb May 26 '20 at 10:33
  • Nativescript better I think. I mean it worked after 10 min setup. – Beller May 26 '20 at 10:37
  • Maybe i think they have better plugins support but for html elements its somehow complicated but for me i go used to ionic and found it perfect, but i would like to learn react-native or react js and xamrine , since they are the most to be near to 90% native . – Mostafa Harb May 26 '20 at 10:41

0 Answers0