If an iOS app crashes in the background, silent push notifications are supposed to be able to relaunch the app, and I've seen this to be true.
However, my app uses core data, so when the app re-launches in the background on a locked device, the core data resources are inaccessible until the device is unlocked.
I rely on what's in core data to process the incoming data, and so updates to the Today Widget or Apple Watch complications don't occur in a timely manner. I also rely on these updates to generate local notifications and to provide responses via Siri.
All of these interfaces are accessible to the user while the device is locked. But the core data is not.
Am I understanding this correctly, and is this the expected behavior? Any way around it?
However, my app uses core data, so when the app re-launches in the background on a locked device, the core data resources are inaccessible until the device is unlocked.
I rely on what's in core data to process the incoming data, and so updates to the Today Widget or Apple Watch complications don't occur in a timely manner. I also rely on these updates to generate local notifications and to provide responses via Siri.
All of these interfaces are accessible to the user while the device is locked. But the core data is not.
Am I understanding this correctly, and is this the expected behavior? Any way around it?
Had a separate exchange via Apple Feedback Assistant, and concluded part of this was user error with respect to file protection levels.
I had been using an NSPersistentContainer, with the defaults - i.e., FileProtection = completeUntilFirstUserAuthentication.
My mistake was in keying on UIApplication.shared.isProtectedDataAvailable, which - when the device is once authenticated but subsequently locked - is FALSE.
But in that case - if the device had once been authenticated - the NSPersistentContainer IS available.
It was my misinterpretation of when the file was available, separate from what isProtectedDataAvailable told me. So - it’s not a bug, though it would be useful if there was a way to tell - whether by notification or a property somewhere - if the device has been authenticated. I don't know that that is available from any APIs/properties.
I had been using an NSPersistentContainer, with the defaults - i.e., FileProtection = completeUntilFirstUserAuthentication.
My mistake was in keying on UIApplication.shared.isProtectedDataAvailable, which - when the device is once authenticated but subsequently locked - is FALSE.
But in that case - if the device had once been authenticated - the NSPersistentContainer IS available.
It was my misinterpretation of when the file was available, separate from what isProtectedDataAvailable told me. So - it’s not a bug, though it would be useful if there was a way to tell - whether by notification or a property somewhere - if the device has been authenticated. I don't know that that is available from any APIs/properties.