简体   繁体   中英

Receive iOS notification in background :: local notifications

We are working on a iOS application which is like the native calendar application. The application syncs the data from the native calendar database. It also triggers local notifications for each calendar entry/meeting before the start time (like 10 mins before).

Can someone please help us with the below issues we are facing.

1) How can I ensure that my application is updated as soon as there is any change in the native calendar database. Whenever there is any new meeting, or an existing meeting is rescheduled, I would like a custom piece of code to be invoked. I understand that this can be achieved by subscribing to the App Foreground notification, however is there anyway to execute the code even while the application is in background.

2) What is the best approach to trigger local notifications 10 mins before every meeting? Should I run a background service and keep checking regularly if there are any meetings in next 10 mins ? Or should I schedule all the local Notifications at once. However in this case, I am not sure how to handle the case where the meeting can get rescheduled while the app is in background or if any new meeting comes up.

  1. You can not, since your app does not fall in the categorie for running in the background.
  2. You can not run a background service on iOS, you will have to scheudule the local notifications when your app is running. But be aware there is maximum of 64 scheduled local notifications. Als you will never know when the notification is displayed since this is handled by iOS and not you app.

The best option is to use push notification, these wil be server side and therefor do not have the 64 scheduled restriction. With the push notification option when an event changes only the server will have to know about it. Since it is the one sending the notification.

An other option could be use EventKit and schedule the event in the user calendar.

You aren't going to like the answer to this. In a non-jailbroken environment the answers are as follows:

1) You can't

2) The only choice is to schedule all meetings at once, but it leaves you open to the problem you mentioned.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM