Forum Xamarin.Forms
We are excited to announce that the Xamarin Forums are moving to the new Microsoft Q&A experience. Q&A is the home for technical questions and answers at across all products at Microsoft now including Xamarin!

We encourage you to head over to Microsoft Q&A for .NET for posting new questions and get involved today.

Why is my OnResume breakpoint not getting hit

I have a xamarin forms app I'm trying to implement some changes to support dark mode. I'd like to check theme and support dark mode whenever the app OnResume's in App.xaml.cs

https://github.com/edgiardina/Ifpa/blob/darkmode/Ifpa/Ifpa/App.xaml.cs#L45

The problem is, when I press the home button in the simulator, then, say, go to settings and change the Dark Appearance, and re-navigate to my app using the task switcher or tapping the icon, I don't ever get into OnResume with the debugger (on Android, I do).

I do however see this output in my Output window when I pause my app.

2019-12-24 20:00:21.836561+0000 Ifpa.iOS[25715:8579903] Can't end BackgroundTask: no background task exists with identifier 1 (0x1), or it may have already been ended. Break in UIApplicationEndBackgroundTaskError() to debug.

Does anyone know why OnResume in iOS is not working for me with Xamarin Forms 4.4.0?

Best Answer

  • EdwardGiardinaEdwardGiardina USMember ✭✭
    Accepted Answer

    Sorry for this, I figured it out. I have an OnActivated override to handle jumplists/shortcuts in iOS. Unfortunately I failed to put a base.OnActivated call in my override which is probably what Xamarin Forms uses to hook those OnResume methods.

Answers

  • LandLuLandLu Member, Xamarin Team Xamurai

    It seems this is a known issue on iOS 13 and hasn't been fixed yet: https://forums.developer.apple.com/thread/121990
    However, this is only a warning and OnResume could be successfully triggered.
    I can't test the project you posted above due to the IFPA API Key and Syncfusion License.
    Therefore, I created a simple project for testing and placed an alert in OnResume like:

    protected override void OnResume()
    {
        MainPage.DisplayAlert("Warning", "Comes from background!", "OK");
    }
    

    Here is the effect:

  • EdwardGiardinaEdwardGiardina USMember ✭✭
    Accepted Answer

    Sorry for this, I figured it out. I have an OnActivated override to handle jumplists/shortcuts in iOS. Unfortunately I failed to put a base.OnActivated call in my override which is probably what Xamarin Forms uses to hook those OnResume methods.

Sign In or Register to comment.