【问题标题】:UILocalNotification receiving function deprecated in iOS10 (Swift 3.0)iOS10 (Swift 3.0) 中弃用 UILocalNotification 接收功能
【发布时间】:2018-02-08 07:34:34
【问题描述】:

我想知道我们应该在 swift 3.0 中使用哪个委托函数而不是:

func userNotificationCenter(_ center: UNUserNotificationCenter, didReceive response: UNNotificationResponse, withCompletionHandler completionHandler: @escaping () -> Void)

用于处理通知,因为此委托功能已弃用。我也检查了这个链接: UILocalNotification is deprecated in iOS10 但没有找到接收代表。 如果我使用相同的委托函数,则不会调用委托。

谢谢。

【问题讨论】:

标签: ios swift push-notification delegates uilocalnotification


【解决方案1】:

我认为到目前为止,您的案例 UILocalNotification 已被弃用(正如您在问题中已经提到的“UILocalNotification is deprecated in iOS10”),这就是您要问的问题:

UILocalNotification在 iOS10 (Swift 3.0) 中已弃用接收功能

但是方法:userNotificationCenter(_:didReceive:withCompletionHandler:)UILocalNotification 没有关系,而是与UserNotifications 框架有关,确实 支持 iOS 10 -如其文档中所述-:

所以基本上,您应该使用 UserNotification 而不是 -deprecated- UILocalNotification,因此:

func userNotificationCenter(_ center: UNUserNotificationCenter, didReceive response: UNNotificationResponse, withCompletionHandler completionHandler: @escaping () -> Void)

在 iOS 10 上应该可以正常工作。

【讨论】:

  • 好的。然后,我想我必须检查一下,为什么它不起作用。感谢您提供信息。
  • 很高兴为您提供帮助。如果遇到任何问题,请随时询问...
  • 当然。谢谢你:)
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2014-03-11
  • 1970-01-01
  • 1970-01-01
  • 2021-11-18
  • 1970-01-01
相关资源
最近更新 更多