How to listen to calendar events when the application is in the background of iOS?

I wrote an Android application that listens for incoming calendar events and starts my thread when the application is in the background.

Now I'm trying to do the same for iOS.

I read a lot and ran a few demos that use the EKEventStore and background selection.

However, this approach does not satisfy me.

Is there any other way to do this?

[EDIT]

The application uses only the open API.

Thanks,

+8
ios ekeventstore
source share
2 answers

Short answer: you cannot. Apple will not allow any application to do such things in the background, as this requires the processor to be turned on when it would otherwise be disabled.

When your application is running, you can read all the events in the near future (say, two weeks?) And set up a β€œlocal” push notification for the time of the event.

In addition, if the user launches your application quite often, Apple will be able to update your application using Background Refresh. The device will usually do this in the morning, before any time the user usually wakes up and turns on his phone for the first time every day, as well as during the day also based on user activity. You can do whatever you want while updating the background application.

Another wrench at work is how full disk encryption works. If the phone is locked, there really is little that your application can do. Most of the data on the phone is encrypted with a user password. As long as the user does not enter his access code, little can be done. In this case, the background application update will be launched as soon as they enter their access code, but before launching your application.

Perhaps you may have a remote server to send push notifications to your phone. Not sure if this is an option for you at all or not. Obviously, this means that the server will need access to the user's calendar data.

+5
source share

In general, the background model of Android does not apply to iOS.

You can register for calendar events as shown below, but your application will only be notified when it starts. In iOS, this means that it is either in the foreground, which was recently launched and started, or was started / woken up by the system as part of a given background mode (for example, background fetching, location updates, VoIP, etc.).

  [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(receiveEventStoreChangedNotification:) name:EKEventStoreChangedNotification object:eventStore]; 

If your application needs one of the designated background modes, you will at least receive notifications from time to time (when you woke up). I have seen approved apps use location updates to get more lead time, of course, YMMV.

+4
source share

All Articles