Introduce an NSNotificationCenter shared by members of an App Group

Originator:jrturton
Number:rdar://21118929 Date Originated:27/05/2015
Status:Open Resolved:
Product:iOS Product Version:8
Classification:Enhancement Reproducible:Always
 
Summary:
Communication between members of an App Group (be they an app and its extensions, or multiple apps) is not straightforward. In the case of multiple App Group members sharing a Core Data store, if one member writes to the persistent store then there is no simple mechanism to communicate these changes to the other group members.

The ability to send notifications between App Group members would simplify this process and bring additional benefits to developers and users of app groups, extensions and Watch apps.

Steps to Reproduce:
1. Have two applications, A and B, that are members of an App Group and share a Core Data store in the group’s folder
2. Application A is running in the background, perhaps receiving network or bluetooth events.
3. Application B is running in the foreground
4. Application A writes to the core data store

Expected Results:
The above situation is analogous to the persistent store being updated by iCloud. A similar notification to NSPersistentStoreDidImportUbiquitousContentChangesNotification should be available to be consumed by a managed object context, which will update the relevant objects. A mechanism to pass this notification from one app group member to the others is also required.

Actual Results:
Application B is unaware of these changes

Version:
iOS 8

Notes:
The workaround is simulated in the attached project:
- Having the writing application listen for the NSManagedObjectContextDidSave notification
- Translating the userInfo dictionary from this notification into a serialisable form by extracting the URIs of the object IDs of the managed objects held therein
- Writing this dictionary to a folder in the app group shared folder
- Having the reading application watch the folder using GCD, and when a file is written, read in the dictionary, convert the URIs back to managed object IDs, create a NSPersistentStoreDidImportUbiquitousContentChangesNotification and pass this to the managed object context to be consumed.

A notification centre shared between app group members would greatly simplify this process if the NSManagedObjectContextDidSave notification would work when passed across members. If not, a separate notification would be needed which has similar content to NSPersistentStoreDidImportUbiquitousContentChangesNotification.

Configuration:
Any

Comments


Please note: Reports posted here will not necessarily be seen by Apple. All problems should be submitted at bugreport.apple.com before they are posted here. Please only post information for Radars that you have filed yourself, and please do not include Apple confidential information in your posts. Thank you!