Swift-我可以在通知服务扩展中使用领域吗?

发布于 2025-02-07 20:13:24 字数 310 浏览 0 评论 0原文

作为标题,我可以在通知服务扩展中使用领域吗?

当我收到通知时,我需要从领域中获取一些数据,然后在向用户显示之前编辑通知内容。

我在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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

风筝在阴天搁浅。 2025-02-14 20:13:24

是的,它有效,您需要创建appGroup才能在应用程序之间共享数据。扩展。

Yes it works, you need to create an AppGroup in order to share data between your app & the Extension.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文