'Can background fetch be triggered by push notifications or app open?

I have a background task handled in performFetchWithCompletionHandler and it has complex logic including API request and iCloud sync. It's working fine by itself but according to user feedbacks/events sometimes it runs in the foreground and it causes some data corruption and concurrency problems.

cloud_sync_bg_started -> Background fetch starts.

splash_view -> First ViewController when the app starts.

ic_document_open -> Event about related background fetch logic.

I'm assuming that the application is awaking with a push notification and Operating System decides to run the background task at that time and it continues to run after the app opens but I couldn't find anything that proves this.

Can background fetch (performFetchWithCompletionHandler) be triggered by push notifications or app open?



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source