title: How to get notifications in background and data synchronization
body: <p>I have here some requirements and now I want to check if these requirements are possible and how they could be reached. It is about notifications and running in background:</p>
  
  <ul>
  <li>The app should show notifications if new data is available and the app is in background (if the app is not running there should be no notifications)</li>
  <li>Also the app should synchronize the data so that the data is up-to-date</li>
  <li>The user should be able to choose an interval when the synchronization should take place (5 seconds, 30 seconds, ...)</li>
  <li>The app should run on iOS 6 and above.</li>
  </ul>
  
  <p><strong>Notifications:</strong><br>
  The problem with <em>local notifications</em> is that you only can set seconds, minutes, hours ... as interval. It is not possible to set a custom interval. But this type would only be appropriate if I have a background task, which searches for updates and if an update is available, it immediatetly displays a local notification.</p>
  
  <p><em>Remote notifications</em> on the other side needs an additional server for the notifications. Also the port 5223 has to be open to receive the notifications (but most of the time cellular network is used and here the port should be open). How many remote notifications can be send and presented to the user? For local notifications it is 64.</p>
  
  <p><strong>Running in background:</strong><br>
  Only in iOS 7 <code>Background Fetch</code> and <code>Remote Notficiations</code> are available. The problem with the <code>Background Fetch</code> is that only small data should be transferred and the OS determines when the app gets a timeslot (own algorithm which learns from the user). Sources reports a max. execution time from 30 seconds, but I didn't found an official statement from Apple.</p>
  
  <p><code>Remote Notifications</code> also seems to need a provider. But here the user would get a notification and the app could download/sync the new data in background (again max. 30 seconds). </p>
  
  <p>What about iOS 6?</p>
  
  <p>Another option would be to let the app run in background / have a background thread which checks for updates/synchronize at a certain intervall and than creates a local notification. But how long does the app run in background? I read about 5 seconds which would be to short.</p>
  
  <p>And another one would be to use push notifications and if the user starts the app it does the synchronization process.</p>
  
  <p><code>beginBackgroundTaskWithExpirationHandler</code> seems not to suite here for my case.</p>
  
  <p>How would I get notifications when running in background together with synchronization?</p>