简体   繁体   English

iOS10(Swift 3.0)中不推荐使用UILocalNotification接收功能

[英]UILocalNotification receiving function deprecated in iOS10 (Swift 3.0)

I was wondering which delegate function, we should use in swift 3.0 instead of : 我想知道应该在swift 3.0中使用哪个委托函数,而不是:

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

for handling notifications, when received as this delegate function is deprecated. 用于处理通知的消息,因为不赞成使用此委托函数。 I checked this link as well: UILocalNotification is deprecated in iOS10 but didn't find receiving delegate. 我也检查了此链接: iOS10中不推荐使用UILocalNotification ,但未找到接收委托。 If I Use same delegate function, the delegate isn't is getting called. 如果我使用相同的委托函数,则不会调用委托。

Thanks. 谢谢。

I think there is a misunderstanding with your case UILocalNotification is deprecated so far (as you already mentioned " UILocalNotification is deprecated in iOS10 " in your question) and that's what are you asking about: 我认为到目前为止您的案例UILocalNotification已被弃用(您已经在问题中提到“ iOS10中已弃用UILocalNotification ”),这是您的问题所在:

UILocalNotification receiving function deprecated in iOS10 (Swift 3.0) iOS10 (Swift 3.0)中不推荐使用UILocalNotification接收功能

But method: userNotificationCenter(_:didReceive:withCompletionHandler:) has nothing to do with UILocalNotification , instead, it is related to the UserNotifications Framework, which does supports iOS 10 -as mentioned in its documentation-: 但是方法: userNotificationCenter(_:didReceive:withCompletionHandler:) 无关UILocalNotification ,相反,它是关系到UserNotifications框架,它支持在其文档-提到iOS的10 -as:

在此处输入图片说明

So basically, you should go UserNotification instead of -deprecated- UILocalNotification, therefore: 因此,基本上,您应该转到UserNotification而不是-deprecated- UILocalNotification,因此:

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

should work as expected with iOS 10. 应该可以在iOS 10上正常使用。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM