Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

iOS how to schedule task & execute randomly even when the app is closed

Tags:

xcode

ios

swift4

I have created an app in android where I have used FCM Job Dispatcher. Now I am working on the iOS app and did not find anything like that From the FCM.

Then I tried to look into something like that called "Services in android" to perform the background task even when the app is close. But sadly I did not find anything similar to it in iOS.

So all I am left with the is Local notifications in iOS. but I do not know if it will help me if my use case is as follow:

  • App must run service only and only if the Internet is connected (wifi not mobile data), device is idle
  • The service must run if the upper given conditions are fulfilled regardless of either app is running or not.

So I am very much confused what should I select to perform such type of task. I am really confused that apps like WhatsApp and others How they actually getting calls and messages if they are not running even in background.

Please share your views that what should I use in these cases?

like image 468
A.s.ALI Avatar asked Sep 16 '25 23:09

A.s.ALI


1 Answers

In context of performing tasks when your app is not in foreground:

1) App is in background - Simple background fetch will work

2) App has been terminated -

Note - If user forcefully quit the application nothing will work other than VOIP services but again VOIP services only available for the apps having audio/video calling feature

Case: 1 - User quit app forcefully

You can not do anything.

Case: 2 - System terminated the app for some reasons

Background fetch will work for the below conditions:

  • Location related services
  • Audio related services
  • Bluetooth/Peripheral devices data sync
  • Background downloads by silent-notifications (push message having key content-available key in the payload )

For more reference. read here

like image 51
Ankit Jayaswal Avatar answered Sep 19 '25 13:09

Ankit Jayaswal