2

I have a NotificationService Extension in my iOS app which I use to modify the text and download attachments.

This works fine as long as the screen is unlocked. The moment the screen is locked, the service extension is not invoked and the notification is shown in its default state with no message.

I have an iPhone 7s running 11.2.5. Has anyone else come across this and have a solution for the same?

trshivku
  • 41
  • 3
  • How do you know that your service extension is not getting called?? – Manish Malviya Mar 08 '18 at 06:53
  • 1
    My extension decrypts the notification text from the payload. So when it is called the notification will have the clear text. When it is not invoked the text will be base64 encoded string. When the screen is locked the text is base64. When I unlock it is clear text. Same with images. – trshivku Mar 08 '18 at 12:46

2 Answers2

2

Turns out the issue was with the NotificationService Extension not having access to the keychain when the device was locked! duh... feel like an idiot :)

I set the kSecAttrAccessible to kSecAttrAccessibleAfterFirstUnlock while creating the key pair and problem was solved.

[keyDict setObject:(__bridge id)kSecAttrAccessibleAfterFirstUnlock forKey:(__bridge id)kSecAttrAccessible];

So my assumption that OS was not initiating the service extension was incorrect.

trshivku
  • 41
  • 3
1

Check for the size of the file that you are passing in the Payload. As we have limited time to download the content. For file sizes refer https://developer.apple.com/documentation/usernotifications/unnotificationattachment.

Thanks, Hope it helps.

manishsharma93
  • 1,039
  • 1
  • 11
  • 26