How to enable Background Fetch for iOS in Codename One

29 Views Asked by At

The original documentation of the Codename One BackgroundFetch interface says: "include fetch in the ios.background_modes build hint". The build hints can be found in the Codename One simulator in the "Tools" menu. So I entered fetch in this field and saved. This will be written into file /appname-common/codenameone_settings.properties as codename1.arg.ios.background_modes=fetch

But it has no effect. Method public void performBackgroundFetch(final long deadline, final Callback<Boolean> onComplete) in class MyApp of my iOS enterprise app will never be called by iOS while the app is sleeping in background. My code is the same as in various examples I have found. Method start() in main class MyApp (which extends Lifecycle) includes

Display.getInstance().setPreferredBackgroundFetchInterval(300);
if (Display.getInstance().isBackgroundFetchSupported()) {
    log.p("Background fetching is supported");
}

Whenever I bring my app to front, it starts again with

[EDT] 0:0:0,167 - MyApp.start()
[EDT] 0:0:0,176 - Background fetching is supported
[EDT] 0:0:0,176 - MyApp.runApp()
etc.

What have I done wrong? What's missing?

Codename One 7.0.108 Apple iPhone 14 Pro Apple iOS 16.5.1

0

There are 0 best solutions below