Swift-我可以在通知服务扩展中使用领域吗?
作为标题,我可以在通知服务扩展中使用领域吗?
当我收到通知时,我需要从领域中获取一些数据,然后在向用户显示之前编辑通知内容。
我在Podfile中进行下面的操作
pod 'RealmSwift'
target 'NotificationServiceExtension' do
inherit! :search_paths
end
,然后在Notificationservice.swift中导入Realmswift。
但这似乎不起作用,因为它不使用相同的数据库,也找不到我已经创建的范围。
As the title, can I use realm in Notification Service Extension ?
When I receive a notification, I need to get some data from realm, then edit notification content before showing to user.
I do below in the Podfile
pod 'RealmSwift'
target 'NotificationServiceExtension' do
inherit! :search_paths
end
Then I import RealmSwift in NotificationService.swift .
But it seems not working because it doesn't use the same database and can not find the scope I've already created.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
是的,它有效,您需要创建
appGroup
才能在应用程序之间共享数据。扩展。Yes it works, you need to create an
AppGroup
in order to share data between your app & the Extension.