0

In my app I need a background-fetch task that queries a server and notifies the user with a local notification if there's any new data.

I can't seem to get the app to push the notifications when it's in the background, even if I simulate background fetch with xcode. The most I've managed is to simulate background fetch with a xcode terminal command (e -l objc -- (void)[[BGTaskScheduler sharedScheduler] _simulateLaunchForTaskWithIdentifier:@"TASK_IDENTIFIER"]) while the app was in the foreground, but I can't get it to work when the app is running in the background.

I have enabled background fetch in capabilites and device settings, I have the task identifier defined in Info.plist and I followed this tutorial to implement background fetch: https://www.andyibanez.com/posts/modern-background-tasks-ios13/

I've been stuck on this for a while now. I'd really appreciate any help.

Dávid Pásztor
  • 51,403
  • 9
  • 85
  • 116
  • 2
    Please [edit] your question to show the relevant code as the debugging you have performed (have you set a breakpoint to check that your task is/isn't being started?). Is your problem that the task doesn't run or the local notification isn't scheduled? Show the code for the scheduling of the notification. Have you asked for and received notification permissions? – Paulw11 Mar 15 '21 at 20:46
  • did you get any solution?, I am also looking solution for same. https://stackoverflow.com/questions/68737745/background-task-ios-not-trigger-local-notification – Jagdev Sendhav Aug 11 '21 at 18:57

0 Answers0