background fetch

hello Devs, I am trying to fetch data while my app is terminated i need to check for new notifications while my app is terminated like Instagram or messages how can I do this? I tried using background fetch but it's not working, in this case, is there any other solutions??

Replies

There is no reliable way to do polling in the background.


The only fairly reliable way is to use remote notification, effectively doing the polling on the server side. The server sends a user-visible notification when there’s something new. You can also use “silent push” (content-available) notifications but those are not guaranteed to be delivered either. Just like background fetch, you may or may not get them depending on how important the OS thinks they are to the user. The OS uses deliberately undocumented heuristics to decide whether or not to delay or discard silent push and background fetch. Basically, if the user opens your app a lot, you’ll get more execution time. But there are no guarantees.

how does reminders do location Alerts??

There are APIs to do location based things (region monitoring, visit monitoring etc.) in Core Location. But in any case, if you’re referring to an Apple app, they don’t have to follow the same rules we third party developers do. That’s why the Clock app, for example, gets to provide an animated app icon but we are not allowed.

CloudKit is set up to send notifications to your app when records are changed or created. Those notifications can cause your app to update from CloudKit.


https://developer.apple.com/library/archive/documentation/DataManagement/Conceptual/CloudKitQuickStart/SubscribingtoRecordChanges/SubscribingtoRecordChanges.html