Reputation: 33
I'm building a simple notification/alarm app to play a notification at the time a user picks. I'm building this in Ionic3, using the local-notification cordova plugin. Everything worked fine while I used a default sound: User picked a time, notification displayed at that time with sound and the text I wanted. Now, I want to play a song when the notification goes off. I put the path that goes to the song in the www folder, but now when the notification goes off at the specified time, the app crashes. I'm not getting any error message when I use chrome://inspect/#devices so I can't even see what the error is, but it has to be something with the path to the file. It is in fact the right path, spelled correctly, but maybe when using local-notification there's something quirky that I don't know about the paths for sound. Here is how I have the notification defined:
let notification = {
title: 'WAKE UP!!!!!',
text: 'Get up and Go!!!!',
at: alarmDate,
sound: 'file://assets/default_tracks/the_number_of_the_beast.mp3'
};
so I store this as a variable and then later call:
this.LocalNotifications.schedule(this.notifications);
Like I said, it worked with default sound, so I know it's not with the way I set anything up, it must be something with the path to the song. Any help would be appreciated. Thanks!
Upvotes: 0
Views: 432
Reputation: 4292
www folder is recreated every time when building
copy the sound file in src/assets
folder,not in www/assets
. so the file path will look like src/assets/sound.mp3
Configure sound for path Local notification
sound: 'file://assets/sound.mp3'
check www/assets folder after building.
Upvotes: 1