Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

iOS background process similar to Android AlarmManager

I've to schedule a fixed task that check some info from internet at fixed interval timer.

Into Android, I use AlarmManager with setRepeating, but I'm newbie to iOS. There are some similar api that help me? I need a task that survive when app is killed by operating system.

Do you know a tutorial about it?

like image 794
CeccoCQ Avatar asked Jan 15 '13 12:01

CeccoCQ


3 Answers

AFAIK in iOS you cannot implement such service that will stay alive after its host app is killed, also only several types of applications can run some background tasks - see documentation here. You can do your task on server side and send push notification when you need users attention - if only user will allow your app to receive push notifications.

like image 161
lupatus Avatar answered Nov 15 '22 12:11

lupatus


Check link on Apple's Multitasking Guide that add's the voip tag to UIBackgroundModes in Info.plist and use setKeepAliveTimeout:handler: method of UIApplication to relaunch it if needed once the app is going to sleep.

Note : For this you need to take special permissions from Apple and mostly Apple rejects such app.

Another solution :-

You can store last sync date and if sync date has crossed your interval when application comes from background, you can start sync your data.

Hope this info helps you..

like image 3
P.J Avatar answered Nov 15 '22 12:11

P.J


You need local notifications of iOS

like image 1
Anson Yao Avatar answered Nov 15 '22 12:11

Anson Yao