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?