title: How to play a custom ringtone on new firebase message(pushed notification) when app is in background for IOS?
body: <p>App runs correctly on android(notification is pushed and the device starts ringing), but on IOS, <strong>app receives notification but ringtone starts after opening the app again...</strong></p>
  <p>I have capabilities set too, background modes(audio background fetch, remote notifications, and background proccessing) and push notifications</p>
  <p>I'm trying to play a custom sound in onMessage method...</p>
  <br/>
  <p><strong>Firebase listener</strong></p>
  <pre><code>void firebaseCloudMessagingListeners(BuildContext context) {
      final deliveryCubit = BlocProvider.of&lt;DeliveryCubit&gt;(context);
      final playerService = PlayerService();
  
      if (Platform.isIOS) getIOSPermission();
  
      _firebaseMessaging.configure(
        onMessage: (Map&lt;String, dynamic&gt; message) async {
             debugPrint('FMC -&gt; $message');
             if(appInBackground){
             playerService.playRingtone();
           }
         
        },
        onResume: (Map&lt;String, dynamic&gt; message) async {
          debugPrint('on resume $message');
        },
        onLaunch: (Map&lt;String, dynamic&gt; message) async {
  
          debugPrint('on launch $message');
        },
      );
    }
  </code></pre>
  <p><strong>Player service</strong></p>
  <pre><code>
  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() =&gt; _instance ?? PlayerService._internal();
  
    PlayerService._internal(){
      _instance = this;
    }
  
    void playRingtone(){
      assetsAudioPlayer.open(
      Audio(&quot;assets/audios/iosRingtone.mp3&quot;),
        showNotification: false,
    );
      assetsAudioPlayer.play();
    }
  
    void pauseRingtone(){
      assetsAudioPlayer.pause();
    }
  }
  </code></pre>
  <p>And I try to stop the player on lifeCycleStateChange...</p>
  <pre><code>  @override
    void didChangeAppLifecycleState(AppLifecycleState state) {
      switch(state){
        case AppLifecycleState.resumed:
          socketService.appInBackground = false;
          firebaseService.appInBackground = false;
          playerService.pauseRingtone();
          setState(() {
            appLifecycleState = AppLifecycleState.resumed;
          });
          print(&quot;LifecycleState resumed&quot;);
          break;
        case AppLifecycleState.inactive:
          print(&quot;LifecycleState inactive&quot;);
          socketService.appInBackground = true;
          firebaseService.appInBackground = true;
          setState(() {
            appLifecycleState = AppLifecycleState.inactive;
          });
          break;
        case AppLifecycleState.paused:
          socketService.appInBackground = true;
          firebaseService.appInBackground = true;
          print(&quot;LifecycleState paused&quot;);
          break;
        case AppLifecycleState.detached:
          print(&quot;LifecycleState detached&quot;);
          break;
      }
    }
  </code></pre>