I am doing some file download work using a notification service extension; just noticed that I'm unable to save the files if the device is locked. Getting the following error:
You don’t have permission to save the file “1604427874_24344399xxxxxx.json” in the folder “posts”."
Have tried manually setting the permissions of that folder like so, with no luck:
var attributes = [FileAttributeKey : Any]()
attributes[.posixPermissions] = 0o777
try FileManager.default.createDirectory(at: postsDirectory, withIntermediateDirectories: true, attributes: attributes)
We suspect this is an issue in the main application as well, if the device is trying to do this download work while the device is locked.
Post
Replies
Boosts
Views
Activity
I'm sure I'm missing something obvious here, but:
I am scheduling local notifications in the main app when the app is backgrounded.
With the app backgrounded, I send a notification and the Notification Service Extension intercepts it.
From my NSE code, I call UNUserNotificationCenter.current().getPendingNotificationRequests but that yields an empty array, even though I have just scheduled a few notifications above.
I have implemented AppShortcuts in my app like the below and the shortcut seems to work correctly by tapping on the shortcut directly (within Shortcuts app) for all devices.
For two of my test devices, only had to utter the first phrase after app install and we correctly got the notification:
"Turn on 'MyApp` shortcuts with Siri?"
After saying yes, Siri + MyApp Shortcuts continued to work correctly.
Unfortunately on two of my other test devices, after uttering the first phrase, never got the notification, it merely opened my app (which, openAppWhenRun is set to false for that AppIntent, so it shouldn't).
Can you help me with any hints as to what may be causing the two different results?
@available(iOS 16, *)
struct MyAppShortcuts: AppShortcutsProvider {
@AppShortcutsBuilder
static var appShortcuts: [AppShortcut] {
AppShortcut(intent: MyAppIntent(), phrases: ["Get my \(.applicationName) code", "What's my \(\.$service) code with \(.applicationName)", "What's my code for \(\.$service)"])
}
}