How to make a background request when a notification arrives on iOS

33 Views Asked by At

I'm trying to intercept the receipt of a notification through some delegate so I can make a request and save a model in the device's memory to avoid loading while the user navigates the app.

The problem is that every implementation I make only works when the app is in the foreground, when it is in the background the delegates are not activated...

I tried using delegates

func application(_ application: UIApplication, didReceiveRemoteNotification userInfo: [AnyHashable : Any], fetchCompletionHandler completionHandler: @escaping (UIBackgroundFetchResult) -> Void)

I created a NotificationExtension and captured the notification through the didReceive() function but nothing worked.

Notifications are coming, I can click on them. But the actions configured in the delegates are only triggered with the app in the foreground.

0

There are 0 best solutions below