Forum Xamarin.iOS


The Xamarin Forums have officially moved to the new Microsoft Q&A experience. Microsoft Q&A is the home for technical questions and answers at across all products at Microsoft now including Xamarin!

To create new threads and ask questions head over to Microsoft Q&A for .NET and get involved today.

Red bar is showing at the top of iPhone home screen when app is going to background

Hi All,

I have enabled one of the Background mode setting(Audio, Airplay and Picture in Picture) in Info.plist. i am getting red bar at top of Iphone home screen as soon as my app goes to background. please find the attached screenshot. Is it possible to hide that red bar in xamarin.IOS.


  • ColeXColeX Member, Xamarin Team Xamurai
    edited January 5

    The red bar shows up if the app go to background while audio is playing .

    To hide it you need to stop the audio before entering background , you can do it in method DidEnterBackground in AppDelegate .

    Refer to

    Xamarin forums are migrating to a new home on Microsoft Q&A!
    We invite you to post new questions in the Xamarin forums’ new home on Microsoft Q&A!
    For more information, please refer to this sticky post.

  • mahipalReddyNareddymahipalReddyNareddy INMember ✭✭

    Hi colex,

    i have tried to stop the audio in DidEnterBackground method but still i am able to see red bar.

  • ColeXColeX Member, Xamarin Team Xamurai

    Is your app doing other things(e.g recording screen) at that time ?

    If so , stop them all .

  • mahipalReddyNareddymahipalReddyNareddy INMember ✭✭

    Hi colex,

    Yes, but i am stoping in didEnterbackground event but it is not stoping. i have tried stoping the audio any click event in app, it is working fine.

  • ColeXColeX Member, Xamarin Team Xamurai

    Can you post the code in didEnterbackground ? How you stop the audio ?

  • mahipalReddyNareddymahipalReddyNareddy INMember ✭✭

    var currentSession = AVAudioSession.SharedInstance();
    currentSession.SetCategory(AVAudioSessionCategory.Playback, AVAudioSessionCategoryOptions.MixWithOthers);

  • ColeXColeX Member, Xamarin Team Xamurai

    From iOS 13, we need to override the lifecycle method in SceneDelegate , check details in .

    So move your code into the DidEnterBackground method in SceneDelegate .

    //SceneDelegate .cs
     [Export ("sceneDidEnterBackground:")]
    public void DidEnterBackground (UIScene scene)
        //stop your audio here . 
  • ColeXColeX Member, Xamarin Team Xamurai

    @mahipalReddyNareddy Have you solved the problem ?

Sign In or Register to comment.