WWDC23 SALE: Save 50% on all my Swift books and bundles! >>

Sync contacts when app is closed

Forums > iOS

Hi! I have an app that relies on User's Contacts and I need to synchronize them daily (run some code and update application data) even if the app is closed (not in background). I've found BGTaskScheduler and NotificationCenter observer for CNContactStoreDidChange but they don't seem to be working when app is closed. Is it possible to do that in iOS?

1      

Nope. You can't do anything if your app isn't at least running in the background. Why would you need to sync contacts then, anyway? The user won't see them until the next time they open the app, which is when you should sync the contacts (probably using a background thread so as not to lock up the UI).

1      

Why would you need to sync contacts then, anyway? The user won't see them until the next time they open the app, which is when you should sync the contacts

I'd like to notify the user about upcoming birthdays. User can add a new contact, edit existing contacts details and the app will not be able to track these changes if there is no mechanism to do so when the app is not running in iOS.

1      

Hi, Have you found any solution for the app which you use need updating and sychronization daily. As I am also facing the same issue. We are using different apps for arunachal results in our mobile phone. And we have to do the same which you are doing on daily basis. Now this work is so boring. Is there any permanent solution for it?

   

Save 50% in my WWDC23 sale.

SAVE 50% To celebrate WWDC23, all our books and bundles are half price, so you can take your Swift knowledge further without spending big! Get the Swift Power Pack to build your iOS career faster, get the Swift Platform Pack to builds apps for macOS, watchOS, and beyond, or get the Swift Plus Pack to learn advanced design patterns, testing skills, and more.

Save 50% on all our books and bundles!

Archived topic

This topic has been closed due to inactivity, so you can't reply. Please create a new topic if you need to.

All interactions here are governed by our code of conduct.

 
Unknown user

You are not logged in

Log in or create account
 

Link copied to your pasteboard.