无法在ios 10通知中调试通知内容扩展

rah*_*mar 3 notifications apple-push-notifications ios10

print语句在通知内容扩展中不起作用,虽然我能够修改Label文本和其他字段,下面是我的代码

class NotificationViewController: UIViewController, UNNotificationContentExtension {


@IBOutlet weak var label: UILabel!

override func viewDidLoad() {
    super.viewDidLoad()
    print("inside viewDidLoad of notificationViewController")
}

func didReceive(_ notification: UNNotification) {
    self.label?.text = notification.request.content.body
    print("inside didReceive of notificationViewController")

}
Run Code Online (Sandbox Code Playgroud)

}

小智 16

这里指出的以下步骤对我有用:

运行包含扩展程序的应用程序后,

  • 在扩展中设置断点
  • 选择Debug/Attach to Process by PID或name
  • 输入扩展目标的名称
  • 触发推送通知
  • 扩展中的断点需要永远触发.耐心,最终你的断点将受到打击

每次通过Xcode重启应用程序时都必须这样做.