Background Fetch is not working in real iOS devices

I have created an iOS native app using Swift 5.0, which internally fetch data from the server using background fetch feature of iOS if the App is running in background mode.
Background fetching is working properly in Simulator and http request reaches in the server. But background fetches not at all working in the real device (iPad Air & iOS 12.2).
  1. I have enabled Background fetch of 'Background modes' under "Capabilities" on the target in Xcode.

  2. Configured minimum background fecth interval and 'performFetchWithCompletionHandler' method in AppDelegate.swift class

  3. I manually verified that real device has Background Refresh is enabled in App's settings.

But while running the App in a real device the Background Fetch is not working.
Please help me to resolve.

AppDelegate.swift code

Code Block import UIKit
@UIApplicationMain
class AppDelegate: UIResponder, UIApplicationDelegate {
var window: UIWindow?
func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool {
UIApplication.shared.setMinimumBackgroundFetchInterval(TimeInterval(60*15))
return true
}
func application(_ application: UIApplication, performFetchWithCompletionHandler completionHandler: @escaping (UIBackgroundFetchResult) -> Void) {
if let url = URL(string: "http://192.168.225.24:80/product") {
URLSession.shared.dataTask(with: url, completionHandler: { (data, respone, error) in
guard let `data` = data else { completionHandler(.failed); return }
let result = String(data: data, encoding: .utf8)
print("performFetchWithCompletionHandler result: \(String(describing: result))")
completionHandler(.newData)
}).resume()
}
}
}

Background Fetch operations are throttled the same way many background operations are, and whether the task will be run as scheduled, and what that schedule will be is based on various aspects and states on the device.

In the context of Background Fetch, one important point to understand is what the “minimum fetch interval” is. We have a lot of developers misunderstand this interval as the interval they expect the fetches to happen at. Actually, what this means is that the background fetch will not happen any sooner than what you specify.

So, if you specify your interval as 1 hour, we are only guaranteeing that the fetch will not happen any sooner than 1 hour. Outside of that the system will take this interval as a general suggestion for scheduling the fetches.
It is important to understand the difference - the reverse, a guarantee that the fetch will happen once 1 hour has past, is not true.

The WWDC 2020 video "Background execution demystified" (https://developer.apple.com/videos/play/wwdc2020/10063/) explains the factors that effect background runtime.


Background Fetch is not working in real iOS devices
 
 
Q