iOS: how to run code in background when app is closed?

Viewed 1250

Using Swift5.2, iOS13.4,

I try to run code in the background (when app is fully closed) at a particular date.

Local Notifications work great if App is foreground (or if user-interaction then also in background).

Some people say (here or here, that you will have to use "background timer" or "Packet Tunnel VPN" tricks in order to keep your app alive in background and in order to have a chance to run some callback-method eventually.

But is there no easier way ?

My goal is to execute code at a particular date in the future (fully from background when app is closed). How would you do that with Swift5 and >iOS12 ?

1 Answers

Short answer, there is no easy way to do this. You can use Background Fetch to perform some actions if the app is running in the background (not fully closed). The easiest way I’ve found to perform actions when the app is fully closed is connecting to Google Firebase and using cloud functions (but those are written in JavaScript? I believe and it’s fairly complex).

Related