Is a a workaround to play custom audio files or device ringing tones on ionic Cordova local notifications IOS. I want to play audios recorded on my app on Local notifications trigger
Your Environment Device OS is IOS 16.1.2 Ionic:
Ionic CLI : 5.4.5 (/usr/local/lib/node_modules/ionic) Ionic Framework : @ionic/angular 5.9.4 @angular-devkit/build-angular : 12.1.4
Cordova:
Cordova CLI : 11.0.0 Cordova Platforms : ios 6.2.0 Cordova Plugins : cordova-plugin-ionic-keyboard 2.2.0, cordova-plugin-ionic-webview 4.2.1, (and 14 other plugins)
Utility:
cordova-res : 0.15.4 native-run : 1.6.0 (update available: 1.7.1)
System:
ios-deploy : 1.10.0 ios-sim
CodePudding user response:
You can archive it like this:
export class HomePage {
constructor(
public navCtrl: NavController,
public alertCtrl: AlertController,
public platform: Platform
) {
this.platform.ready()
.then(() => {
console.log(this.platform.is('android'))
LocalNotifications.schedule({
id: 1,
text: 'Single LocalNotification',
sound: this.setSound(),
data: { secret: 'hellloo' }
});
})
}
setSound() {
if (this.platform.is('android')) {
return 'file://assets/sounds/shame.mp3'
} else {
return 'file://assets/sounds/bell.mp3'
}
}
}
The old answer from here.
CodePudding user response:
it does play from the device folder Library/sounds but the problem l have is that the file plugin cannot access the Library folder to move the custom audio recordings.
IOS local notifications is also not subscribing to events when the notification triggers and the app is in background its not triggering the onTrigger event only when the app is in foreground.