Quantcast
Channel: Recent Threads — Xamarin Community Forums
Viewing all articles
Browse latest Browse all 204402

Couldn't find the method 'PerformFetch' when implementing iOS 7 Background Fetch

$
0
0

I've implemented Background Fetch in a MonoTouch application, but iOS can't seem to find the PerformFetch method I've added to the AppDelegate:

[...]

namespace MyApp.iOS
{
    [Register ("AppDelegate")]
    public partial class AppDelegate : UIApplicationDelegate
    {
        public override bool FinishedLaunching (UIApplication application, NSDictionary options)
        {
            [ ...Window initialization... ]

            UIApplication.SharedApplication.SetMinimumBackgroundFetchInterval (UIApplication.BackgroundFetchIntervalMinimum);

            return true;
        }

        public override async void PerformFetch (UIApplication application, Action<UIBackgroundFetchResult> completionHandler)
        {
            Console.WriteLine ("AppDelegate PerformFetch");

            bool success = await PerformAsyncTask ();
            UIBackgroundFetchResult result = success ? UIBackgroundFetchResult.NewData : UIBackgroundFetchResult.Failed;
            completionHandler (result);
        }
    }
}

When executing this application, everything works perfectly as expected until iOS calls PerformFetch. The following message appears in the Application Output:

Couldn't find the method 'PerformFetch' in the type MyApp.iOS.AppDelegate

When calling PerformFetch myself from FinishedLaunching for example, everything executes without problems, no exceptions what soever. Do I need to register anything beside putting fetch in the Required background modes in the Info.plist? It seems that works as expected as my app is showing up in the corresponding section in the Settings app, and the fact that iOS tries to call the PerformFetch method. Why can't the system find the method?

I've also tried removing the async keyword and making the method synchronous, but that didn't help either.


Viewing all articles
Browse latest Browse all 204402

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>