Selected sound file does not play for my notification! Ionic 4

I got a notification with default notification sound that default in the phone settings sound, but the sound that i choose to play in my scheduled notification wont work.
The only thing is i getting a notification but no sound file is played when i have set a own file.

Should i not get sound from the mp3 file i selected.

I got a notification with default notification sound that default in the phone settings sound, but the sound that i choose to play in my scheduled notification wont work.
The only thing is i getting a notification but no sound file is played when i have set a own file.

Should i not get sound from the mp3 file i selected.

Have i missed anything?

Your Environment

General summary of the issue:
When notification with sound is triggered while iphone is muted, it’s not playing.

  • Plugin version: beta 3
  • Platform: Android
  • OS version: Pie and Oreo
  • Ionic Version (if using Ionic): 4.0 latest uppdate

Expected Behavior

When getting a notification play a sound file i have selected.

sound: 'file://assets/tone_nokia.mp3',

Actual Behavior

I got a Notification but i can not get the mp3 file to start play.

Steps to Reproduce

import { Component } from '@angular/core';
import { LocalNotifications } from '@ionic-native/local-notifications/ngx';
import { Storage } from '@ionic/storage';
import { NavController, AlertController, Platform } from '@ionic/angular';
import { ToastController } from '@ionic/angular';

@Component({
  selector: 'app-home',
  templateUrl: 'home.page.html',
  styleUrls: ['home.page.scss'],
})

export class HomePage {
  constructor(
    public navController: NavController,
    public navCtrl: NavController,
    private platform: Platform,
    private localNotifications: LocalNotifications,
    private alertController: AlertController,
    private toastController: ToastController) {



      this.localNotifications.on('trigger').subscribe(notification => {
          this.presentToast();
      });
      this.localNotifications.on('yes').subscribe(notification => {
          this.presentAlert(notification.data.meetingId);
      });
      this.localNotifications.on('no').subscribe(notification => {
          this.presentAlert(notification.data.meetingId);
      });
    }


// TRIGGER
  async presentToast() {
    const toast = await this.toastController.create({
      message: 'Athan spelas upp!',
      duration: 2000
    });
    toast.present();
  }

  async presentAlert(test) {
    const alert = await this.alertController.create({
      header: 'Alert',
      subHeader: 'Subtitle',
      message: test,
      buttons: ['OK']
    });

    await alert.present();
  }



// On load or every check!
  scheduleNotification() {
    var myDate = new Date(2019, 1, 12, 9, 4, 5, 0);  // create a date object fo the 'trigger' 'at'
    var arrayOfNotifications = [{
        id: 1,
        foreground: true,
        trigger: { at: myDate }, // MUST be a date object
        text: 'Abdelbaset Athan spela upp.',
        title: 'Spela upp Athan',
        data: { meetingId:"Athan - 1" },
        sound: 'file://assets/sms.mp3',
      }];
      this.localNotifications.schedule(arrayOfNotifications);

  }


}

I tried to put it in scheduleNotification() method but no buttons or sound are working.

Any ide? I tried to clear upp the code so you easy can see what i am doing.

Or should i install the beta version? if so how do I do that?hat?

I’m pretty sure Local notifications only works on a device with a --release build

I getting the notification to work but i can not get any sound to play…

I got the local notification to work but not the sound part.
Have you manage to accomplish own sound file when a notification triggers.

Best regards

perhaps try adjusting the file path? the Local Notification docs do not use the assets directory as part of the sound file path

Okej if it is not the right path in ionic 4. How should i know where the path is?

My structure is: SRC/App/services/data/data.service.ts ← this is where my service is:

And my path to my file is:

src/assets/audio/my.mp3

Are there anything i have done wrong here.

How should path begin and whrere should i put the file. can not find any information how the path should look like.

Best gretings.

if that is is the case maybe try adding audio to the path:

sound: 'file://assets/audio/sms.mp3',

I have tried that already, no luck i got an email from the plugin develpper, and he said that i should use the same path in www root and if i look at the path in the www root it is the same as the Src. So i dont know what the problem is. I think it is a bug in Ionic plugin.

if you can follow the conversation. You may comment there.

You may also download the notification sample from there and test yourself. To see what going wrong. Go to the like above on github.

sure ?? i tested in debug and working but there are many other problems…

have u found solution ?