We implemented Notification Service Extension
in our app. Our goal is to download some data from our server and modify the notification content in didReceive(_:withContentHandler:)
.
It's working fine when the app is running in the background, or has just been terminated. When the app is not running however, it can not download the data and the service extension time expires.
EDIT: Okay, I edited this question, and removed my networking code, because I figured out what my issue was. However, this led to another problem.
My networking code did not run when the app was terminated, because I store the user's access token on the keychain, which can not be accessed when the phone is locked.
So, I'm at a stalemate right now: On the one hand, I do not want to store the access token in UserDefaults
, because that's just unsafe. On the other hand, I need to use the access token when the device is locked, to display the proper notification content.
Any help appreciated.