AppDelegate.PerformFetch(UIApplication, UIBackgroundFetchResult)': no suitable method found to override

Jassim Al Rahma 1,521 Reputation points
2023-05-06T14:38:23.2066667+00:00

Hi,

I am trying to use background service in .NET MAUI app and here is my AppDelegate:

using Foundation;
using UIKit;
using UserNotifications;

namespace MyApp;

[Register("AppDelegate")]
public class AppDelegate : MauiUIApplicationDelegate
{
    protected override MauiApp CreateMauiApp() => MauiProgram.CreateMauiApp();

    protected override async void PerformFetch(UIApplication application, UIBackgroundFetchResult completionHandler)
    {
        // Perform your background fetch here

        completionHandler(UIBackgroundFetchResult.NewData);
    }
}

but I get this error:

/Users/jassim/Projects/MyApp/MyApp/Platforms/iOS/AppDelegate.cs(35,35): Error CS0115: 'AppDelegate.PerformFetch(UIApplication, UIBackgroundFetchResult)': no suitable method found to override (CS0115) (MyApp)

Kindly help..

Thanks

.NET MAUI
.NET MAUI
A Microsoft open-source framework for building native device applications spanning mobile, tablet, and desktop.
2,859 questions
{count} votes

1 answer

Sort by: Most helpful
  1. Wenyan Zhang (Shanghai Wicresoft Co,.Ltd.) 26,146 Reputation points Microsoft Vendor
    2023-05-08T05:57:21.3566667+00:00

    Hello,

    This is a known issue reported at GitHub. Please see iOS AppDelegate - PerformFetch override #1419 and iOS AppDelegate - Override for PerformFetch is not available #7957

    And it was fixed the in .Net8.0.0-preview.3.8149.

    For the usage of App lifecycle, you could refer to App lifecycle - .NET MAUI | Microsoft Learn.

    Best Regards,

    Wenyan Zhang


    If the answer is the right solution, please click "Accept Answer" and kindly upvote it. If you have extra questions about this answer, please click "Comment".

    Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.

    0 comments No comments