我想在NotificationContentExtension
下调试以下代码。它不起作用。即使是print语句也不起作用。我还尝试为自定义视图添加模糊效果。这不起作用。我还在特定的一行上设置了一个断点,它也没有用。
请检查以下代码。
import UIKit
import UserNotifications
import UserNotificationsUI
class NotificationViewController: UIViewController, UNNotificationContentExtension {
@IBOutlet var label: UILabel?
override func viewDidLoad() {
super.viewDidLoad()
let blurEffect = UIBlurEffect(style: .extraLight)
let blurEffectView = UIVisualEffectView(effect: blurEffect)
blurEffectView.frame = self.view.frame
print("blurEffect") // Can't see this on my console
self.view.insertSubview(blurEffectView, at: 0) //not working blur effect
}
func didReceive(_ notification: UNNotification) {
if let number = notification.request.content.userInfo["customNumber"] as? Int {
label?.text = "\(number)"
print("didReceive") // Can't see this on my console
}
}
}
答案 0 :(得分:0)
选择您的UNNotificationContentExtension作为活动方案。然后构建并运行。