App.OnResume() not called on iOS

Hello guys,

I am having some trouble on the iOS App life cycle. I need to do some stuff inside the OnResume() method. My Android application calls it whenever it returns from the background. But when I am running my app on iOS, the OnResume() is never called when I bring my app to foreground.
It is a Location app and it keeps running in background until the user manually stops it.

This is how my code looks like:

public App () 
{
    InitApp();
}

private void InitApp() 
{
    //Do stuff
}

protected override void OnStart ()
{
    System.Diagnostics.Debug.WriteLine (TAG + ".OnStart() called.");
}

protected override void OnSleep ()
{
    // Handle when your app sleeps
    System.Diagnostics.Debug.WriteLine (TAG + ".OnSleep() called.");
}

protected override void OnResume ()
{
    // Do some stuff when it returns from the background.

    // Handle when your app resumes
    System.Diagnostics.Debug.WriteLine (TAG + ".OnResume() called.");
}

Best Answers

  • imkumarsaurabhimkumarsaurabh IN ✭✭
    Accepted Answer

    I don't see any issue in this, I just tried on iPhone 6s iOS Emulator, Run the app, Pulled the notification window down and then pulled it up again, The debugger was gone to OnResume of Xamarin.Forms app. Issue should be different, please cross check.

Answers

  • imkumarsaurabhimkumarsaurabh INMember ✭✭
    Accepted Answer

    I don't see any issue in this, I just tried on iPhone 6s iOS Emulator, Run the app, Pulled the notification window down and then pulled it up again, The debugger was gone to OnResume of Xamarin.Forms app. Issue should be different, please cross check.

  • SomeshThati.9145SomeshThati.9145 USUniversity ✭✭

    @BernardoSalgueiro.0082 said:
    You were right, @imkumarsaurabh. The problem was in the AppDelegate class.
    The public override void WillEnterForeground(UIApplication application) method was't calling base.WillEnterForeground (application). When I included this call, my App.OnResume() worked perfectly again.

    I had the same problem and fixed now :) Thank you

  • DevologyDevology GBMember ✭✭

    Hi all, I had the same issue, I'd added some logging to the methods and didn't invoke super.

Sign In or Register to comment.