0

I need to have my app sync with a server via HTTPS GET at least once daily so it can provide the most up-to-date information to its users. I am currently using the Background Fetch API, but it triggers very infrequently, to the point where the app becomes useless. On the Android app, I have made a reoccurring timer that triggers every 6 hours then runs the HTTPS request.

I am wondering if there is an alternative to the Background Fetch API that triggers more often, and if not, how do apps like Instagram, Twitter, Outlook, Snapchat, and so on deliver notifications to the user seemingly when the event occurs (i.e., an email is received)?

Tidal5
  • 110
  • 1
  • 12
  • Currently I don't think that there is anything similar to the AlarmManager you seem to use on Android instead of Background Fetch... But if you just want to send Notifications, won't push notifications do the job? If you send a push notification to your users and update the data right after starting the app...? – Dennis Weidmann Mar 24 '18 at 16:37
  • @DennisWeidmann I am trying to make it where the user does not have to do anything, they just open the app, and it is the most recent data. I would also like to alert the user of a change of the information from the server, as close to the time that it happened, just like if an email was received. Running the request on app launch is what I was going to do next, but it would take a while (the server takes around 7 seconds to execute), and I see other apps having no problem executing background tasks whenever they need, especially email and social media apps. – Tidal5 Mar 24 '18 at 16:42
  • What have you set your background fetch interval to? Are you calling the completion handler at the end of your fetch? At least once every six hours should easily be achievable with background fetch? – Paulw11 Mar 24 '18 at 20:12
  • @Paulw11 I have the minimum set to 3600 (1hr), and it does call the completion handler correctly. I only seem to receive a background fetch call about once per day, generally at night on the test devices. I am looking for at least twice a day. – Tidal5 Mar 25 '18 at 00:11
  • It takes some time for iOS to analyse your app's behaviour and for things to settle down. How often and at what times of day you pass `newData` to the completion handler will impact when iOS triggers a background refresh. Simply setting the refresh time to minimum won't get you frequent calls, particularly at first. – Paulw11 Mar 25 '18 at 00:17

2 Answers2

0

You can use Background Update Notification to wake up your app periodically in the background.

nakano531
  • 498
  • 7
  • 13
  • Would this allow me to execute code in the background, as well as an HTTPS request? How would I go about doing this? – Tidal5 Mar 25 '18 at 00:12
  • Yes, but you need to send the push notification from a server somewhere at the required time – Paulw11 Mar 25 '18 at 00:15
0

Notifications are not part of any app, Notifications are executed by "Apple Push Notification service" or "APNs" for short.

so if you see a notification from Instagram, Whatsapp or Telegram displayed on your iOS device screen - understand that 0 code of Instagram, Whatsapp, Telegram were activated to show this notification, it's all 100% the APNs, and APNs only.

Ori
  • 21
  • 4