如何在NotificationContentExtension下调试代码?

问题描述 投票:0回答:1

我想在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
        }
    }
}
ios swift push-notification ios-extensions
1个回答
0
投票

选择您的UNNotificationContentExtension作为活动方案。然后构建并运行。

© www.soinside.com 2019 - 2024. All rights reserved.