App runs correctly on android(notification is pushed and the device starts ringing), but on IOS, **app receives notification but ringtone starts after opening the app again...**

I have capabilities set too, background modes(audio background fetch, remote notifications, and background proccessing) and push notifications

I'm trying to play a custom sound in onMessage method...

**Firebase listener**

```
void firebaseCloudMessagingListeners(BuildContext context) {
    final deliveryCubit = BlocProvider.of<DeliveryCubit>(context);
    final playerService = PlayerService();

    if (Platform.isIOS) getIOSPermission();

    _firebaseMessaging.configure(
      onMessage: (Map<String, dynamic> message) async {
           debugPrint('FMC -> $message');
           if(appInBackground){
           playerService.playRingtone();
         }

      },
      onResume: (Map<String, dynamic> message) async {
        debugPrint('on resume $message');
      },
      onLaunch: (Map<String, dynamic> message) async {

        debugPrint('on launch $message');
      },
    );
  }

```

**Player service**

```

import 'package:assets_audio_player/assets_audio_player.dart';
import 'package:path_provider/path_provider.dart' as path_provider;

class PlayerService {
  static PlayerService _instance;
  final assetsAudioPlayer = AssetsAudioPlayer();

  factory PlayerService() => _instance ?? PlayerService._internal();

  PlayerService._internal(){
    _instance = this;
  }

  void playRingtone(){
    assetsAudioPlayer.open(
    Audio("assets/audios/iosRingtone.mp3"),
      showNotification: false,
  );
    assetsAudioPlayer.play();
  }

  void pauseRingtone(){
    assetsAudioPlayer.pause();
  }
}

```

And I try to stop the player on lifeCycleStateChange...

```
  @override
  void didChangeAppLifecycleState(AppLifecycleState state) {
    switch(state){
      case AppLifecycleState.resumed:
        socketService.appInBackground = false;
        firebaseService.appInBackground = false;
        playerService.pauseRingtone();
        setState(() {
          appLifecycleState = AppLifecycleState.resumed;
        });
        print("LifecycleState resumed");
        break;
      case AppLifecycleState.inactive:
        print("LifecycleState inactive");
        socketService.appInBackground = true;
        firebaseService.appInBackground = true;
        setState(() {
          appLifecycleState = AppLifecycleState.inactive;
        });
        break;
      case AppLifecycleState.paused:
        socketService.appInBackground = true;
        firebaseService.appInBackground = true;
        print("LifecycleState paused");
        break;
      case AppLifecycleState.detached:
        print("LifecycleState detached");
        break;
    }
  }

```