0

I am trying to get access the to AppDelegate from NotificationContentExtension like this:

private var appDelegate = UIApplication.shared.delegate as! AppDelegate

I was thinking that the app will never crash, because it won't even launch without appDelegate. But it crashed and the console output is:

    Failed to inherit CoreMedia permissions from 21734: (null)

Is it because I can't use a reference to AppDelegate in NotificationContentExtension?

Thank you.

Jess Bowers
  • 2,846
  • 1
  • 22
  • 42
Dmytro Pashkov
  • 350
  • 3
  • 11
  • 1
    If it's like app extensions I've used, you are not able to reference `UIApplication`. It's an "extension" to an *Apple* app (maybe in this case the OS?) and not *your* app. –  Feb 02 '18 at 17:38

1 Answers1

2

App extensions (including Notification extensions) do not have an application delegate. Also, they run as a separate process from your application and cannot access your application's delegate.

Jake
  • 13,097
  • 9
  • 44
  • 73