草庐IT

didReceive

全部标签

ios - 应用程序终止时未调用 UNUserNotificationCenter didReceive 响应

我正在处理本地通知,但我遇到的问题是当应用程序终止时没有调用didReceiveResponse方法,所以当我点击通知操作时它只是启动应用程序而没有做任何其他事情。但是,当该应用程序仅在后台运行时,一切正常。我的代码有什么问题吗?//MyClassNameViewController.swiftoverridefuncviewDidLoad(){super.viewDidLoad()UNUserNotificationCenter.current().delegate=self}functriggerAlarm1(){//Createaninstanceofnotificationce

ios - UNUserNotificationCenter didReceive 未被调用

当我发送推送通知时,应用程序在前台willPresent被调用。didReceive永远不会被调用。当应用程序在后台并收到推送通知时,会显示警报,但应用程序不会调用didReceive或willPresent。在Project>Capabilities中,我检查了后台模式Locationupdates和Remotenotifications。位置更新用于不相关的代码。我还启用了推送通知。这工作正常,因为他们正在收到。我已经在我的AppDelegate中实现了UNUserNotificationCenter通知内容,如下所示:importUserNotifications...class