I'm using Mailcore2 for an app that im developing by myself, and everything is perfect with Mailcore but now I'm trying to retrieve the emails when the user minimize the app (enter on background), I tried using background notifications but didn't work because time between the close and the first window to enter on my background function is too long.
So I tried to keep the idleOperation working when the user minimize the app but sometimes work perfect and sometime don't work at all.
Anyone have a solution to this?
I'm using Xcode and iOS 8.
Thanks.
The time slice provided by iOS for background fetch is based on an algorithm unknown to the developers.
If you want to use the IMAP IDLE operation, then you will have to start inside the performFetchWithCompletionHandler:
and make sure you are done before the app goes to sleep again i.e. anything from a few seconds to max 30 seconds.
I would suggest creating an IMAP session as soon as you enter background, poll IMAP for new changes, process and go to sleep ASAP. But again, iOS decides when and how long you get that time slice for background fetch.
UPDATED ANSWER:
If requirement is just getting the notifications for new emails, then just register for push notifications on your app and push them from your server or use services like Pushwoosh.