In my app I am trying to play a specific sound when new notification comes. It is working fine in android. But in IOS if the app is in background it will work. If the app is killed it will play default notification sound.
Future<void> _firebaseMessagingBackgroundHandler(RemoteMessage message) async {
// If you're going to use other Firebase services in the background, such as Firestore,
// make sure you call `initializeApp` before using other Firebase services.
await Firebase.initializeApp();
if(message.data['navigate_to']=='idea'){
FlutterRingtonePlayer.play(fromAsset: "assets/alerts/trade.mp3",
ios : IosSounds.electronic,
asAlarm: true,);
}
}
I am using flutter_ringtone_player for playing audio. Also tried with just_audio, assets_audio_player, audioPlayers. Everything is working when the app is in background only not when killed. (only in IOS)