1

尝试创建本地通知失败并出现以下错误:

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}

这意味着什么?

4

2 回答 2

8

这是由于尝试从通知中传递 URL 引起的objectID.uriRepresentation()userInfo

有必要改为存储objectID.uriRepresentation().absoluteString

处理通知后,objectID可以通过以下方式恢复:

persistentStoreCoordinator
    .managedObjectID(forURIRepresentation: URL(string: uri))
于 2019-08-25T21:40:14.977 回答
1

我通过尝试添加带有 URL 类型值的 userInfo 来遇到问题。通过更改为URL修复String

您可以检查您的输入值是否为字符串值。如果没有,将其设为字符串可以解决此问题。

于 2020-03-30T10:05:45.877 回答