iOS Swift - 推送通知 : Save all Remote-Notifications in a Database (also while App is terminated)

标签 ios swift push-notification apple-push-notifications

我想将所有收到的通知保存在数据库中。

如果有人点击通知或应用程序位于前台时收到通知,则此方法有效。

但挑战是在应用程序终止时保存通知(大声推送)。

启动已终止的应用程序后,会调用函数didFinishLaunchingWithOptions,但launchOptionsaways为nil,因此我无法处理推送通知。

有人有办法解决这个问题吗?

提前谢谢您。

最佳答案

感谢 Goergisn。

我的问题的解决方案:

  1. 创建 UNNotificationServiceExtension( https://developer.apple.com/documentation/usernotifications/modifying_content_in_newly_delivered_notificationshttps://medium.com/gits-apps-insight/processing-notification-data-using-notification-service-extension-6a2b5ea2da17 )
  2. 创建应用组
  3. 将通知服务中的数据保存到应用组
  4. 在 ViewController 中创建一个函数,将数据从应用组传输到 sql 数据库

关于iOS Swift - 推送通知 : Save all Remote-Notifications in a Database (also while App is terminated),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/64771872/

相关文章:

ios - 连接SignalR服务器的流程

swift - Swift 中带背景的计时器

iphone - iOS 从通知中心删除通知

iphone - 在 Xcode 外部调试

ios - 如何让函数每秒执行一次?

ios - 如何在 SpriteKit Swift 中只要我触摸就重复操作,当我停止触摸时操作停止

ios - Swift 数组 : Keeping the order while filtering an array using another

android - 在android中根据用户当前设备​​位置生成推送通知

ios - 当应用程序处于终止( kill )状态时保持实时 websocket

ios - 使用 [UIView new] 的任何注意事项;?