A Notification Service Extension downloads a media file to display it as attachment of the UNNotification
. However when the host app is in foreground, no notification is displayed, so it is unnecessary to for the notification extension to download the media file.
How can the download be prevented, depending on the app state?
First from ios 10 you can present it with
UNUserNotificationCenterDelegate
delegate methodsecond it may be strange but you can share app state with userDefaults if you have app groups enabled with the extension