print statement does not work inside notification content extension, although I am able to modify the Label text and other fields, below is my code
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")
}
}
The following steps pointed here worked for me:
After running the app that contains the extension,
- Set your breakpoint in the extension
- Select Debug / Attach to Process by PID or name
- Enter the name of the extension target
- Trigger the push notification
- Breakpoints in extensions take forever to trigger. BE PATIENT, eventually your breakpoint will be hit
You will have to do this every time you restart your app via Xcode.