【发布时间】:2017-12-01 13:31:59
【问题描述】:
我想在NotificationContentExtension 下调试我的以下代码。它不工作。甚至打印语句也不起作用。我还尝试为我的自定义视图添加模糊效果。这是行不通的。我也在特定的行上放了一个断点,它也不起作用。
请检查以下代码。
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
}
}
}
【问题讨论】:
-
您是否将情节提要中的视图控制器设置为 NotificationViewController 类型?
-
尝试从您的应用程序中评论远程通知委托,然后进行调试。
标签: ios swift push-notification ios-extensions