【问题标题】:How to debug the code under NotificationContentExtension?如何调试 UNNotificationContentExtension 下的代码?
【发布时间】: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


【解决方案1】:

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

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2011-05-06
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多