Attempting to create a local notification fails with the following error:
Adding notification request failed with error: Error
Domain=NSCocoaErrorDomain Code=4097 "connection to service named
com.apple.usernotifications.usernotificationservice" UserInfo=
{NSDebugDescription=connection to service named
com.apple.usernotifications.usernotificationservice}
What does that mean?
This is caused by attempting to pass a URL from objectID.uriRepresentation()
in userInfo
of the notification.
It is necessary to store objectID.uriRepresentation().absoluteString
instead.
When the notification is handled, the objectID
can be recovered by:
persistentStoreCoordinator
.managedObjectID(forURIRepresentation: URL(string: uri))