在生产版本 ionic 3 中没有获得本地通知声音

Not getting local Notification Sound in production build ionic 3

我对 ionic 3 本地通知声音有疑问。当我调试构建时,声音就来了。

它不会出现在生产版本中,我也尝试将声音值设置为 "res://platform_default"(听不到声音)。请帮我。提前致谢。

下面是我的代码。

import {Component} from '@angular/core';
import {IonicPage, NavController, NavParams, Platform, AlertController} from 'ionic-angular';
import {LocalNotifications} from '@ionic-native/local-notifications';

@IonicPage()

@Component({
    selector: 'page-notifications',
    templateUrl: 'notifications.html',
})

export class NotificationsPage {

    data = {title: '', description: '', date: '', time: ''};

    constructor(public navCtrl: NavController,
                public localNotifications: LocalNotifications,
                public platform: Platform,
                public alertCtrl: AlertController) {
    }

    submit() {
        console.log(this.data);
        var date = new Date(this.data.date + " " + this.data.time);
        console.log(date);
        this.localNotifications.requestPermission().then((permission) => {
            this.localNotifications.schedule({
                id: 0,
                text: 'Delayed ILocalNotification',
                trigger: {at: date},
                foreground:true,
                vibrate: true,
                led: {color: '#FF00FF', on: 500, off: 500},
                data: {mydata: 'My hidden message this is'},
                // sound: 'res://platform_default',
                sound: this.setSound(),
            });
            let alert = this.alertCtrl.create({
                title: 'Congratulation!',
                subTitle: 'Notification setup successfully at ' + date,
                buttons: ['OK']
            });
            alert.present();
            this.data = {title: '', description: '', date: '', time: ''};
        });
    }

    setSound() {
        if (this.platform.is('android')) {
            return 'file://assets/sounds/Rooster.mp3'
        } else {
            return 'file://assets/sounds/Rooster.caf'
        }
    }
}

在仪表板页面

this.localNotifications.on('click').subscribe(
            (datas: any) => {
                alert('in_is');
                alert(JSON.stringify(datas));
                /*let alert = alertCtrl.create({
                    title: notification.title,
                    subTitle: json.mydata
                });
                alert.present();*/
            });

尝试使用三元运算符来分配 mp3 声音,而不调用分配它的函数

 this.localNotifications.schedule({
                id: 0,
                text: 'Delayed ILocalNotification',
                trigger: {at: date},
                foreground:true,
                vibrate: true,
                led: {color: '#FF00FF', on: 500, off: 500},
                data: {mydata: 'My hidden message this is'},
                sound: this.platform.is('android') ? 'file://assets/sounds/Rooster.mp3' : 'file://assets/sounds/Rooster.caf',
            });

参考离子文档https://ionicframework.com/docs/native/local-notifications/