Setting local notifications on all devices Swift

Published

I have added date triggered local notifications to my app and now I want the user to be able to get the notification they set on one device on all of their devices that have the app. I save the notification they set in a core data entity (saving the notifcation identifier and date it’s suppose to be triggered). The app uses a NSPersistentCloudKitContainer to sync the users devices together.

Since I save the notifications the user sets to this iCloud container, is there a way I can listen to iCloud changes in the app’s background so when a notification is added in iCloud, I can read it and set it as a local notification on their other devices?

I was able to do this when the app is in the foreground with NotificationCenter.default.addObserver(self, selector: #selector(type(of: self).storeRemoteChange(_:)), name: .NSPersistentStoreRemoteChange, object: container.persistentStoreCoordinator) in my core data manager file. But I would like to do this when the app is not opened at all.

You can think of this as a user setting a reminder in the Apple reminders app and how that notification pops up on all of my iCloud devices at the time I set it at. I prefer to not make any type server to handle this because I am not familiar with using servers.

Thank you in advance for your help!

Source: Ios

Published
Categorised as icloud, ios, notifications, swift, xcode

Answers

Leave a Reply

Your email address will not be published. Required fields are marked *

Still Have Questions?


Our dedicated development team is here for you!

We can help you find answers to your question for as low as 5$.

Contact Us
faq