I enquired Apple the issue via Code-Level Support but they didn't answer, they just asked me to post to Developer Forums. But I've already done that.
It seems that Locked Camera Capture Extension doesn’t support interface orientation flexibility.
I understand now the specification to prevent complex since it’s a Lock Screen feature.
So, we should consider simple spec for our extension.
Post
Replies
Boosts
Views
Activity
I made Feedback. FB15550992
Xcode is no more supported under Rosetta.
https://developer.apple.com/documentation/xcode-release-notes/xcode-14_3-release-notes
Apple released new API which is replaced with setValue:forKey:"orientation".
And it's quite easy to use.
iOS apps can now request rotation using [UIWindowScene requestGeometryUpdate:errorHandler:] and providing a UIWindowSceneGeometryPreferencesIOS object containing the desired orientations. (95229615)
https://developer.apple.com/documentation/uikit/uiwindowscene/3975944-requestgeometryupdate/
https://developer.apple.com/documentation/ios-ipados-release-notes/ios-ipados-16-release-notes
This issue seems to be resolved with iOS 15.5 beta 4.
So, I think we should wait for its release and my user for updating iOS.
I found the answer in developer documentation.
Apple say that "Calls to the API only prompt when the application state is: UIApplicationStateActive. Calls to the API through an app extension do not prompt.".
We have to check UIApplicationState before attempt to show the prompt.
fileDataRepresentation contains its metadata. But UIImage class does't have metadata property. This is the reason.
You can get image source to keep maintain image's metadata.
CGImageSourceCreateWithData(::)
CGImageSourceCopyPropertiesAtIndex(::_:)
Seems solve issue for me. This is my answer.
First, write method below which can get VoiceShortcut object with UserActivity's Identifier if any.
private func getShortcut(id: String, completion: ((INVoiceShortcut?) -> Void)?) {
INVoiceShortcutCenter.shared.getAllVoiceShortcuts { (shortcuts, error) in
let result = shortcuts?.filter { $0.shortcut.userActivity?.persistentIdentifier == id }.first
completion?(result)
}
}
Next, we should call present(editVoiceShortcutViewController) but not present(addVoiceShortcutViewController) in func present(_ addVoiceShortcutViewController: INUIAddVoiceShortcutViewController, for addVoiceShortcutButton: INUIAddVoiceShortcutButton).
We need VoiceShortcut object to instantiate INUIEditVoiceShortcutViewController. So we need to wait until the shortcut's generated by system.
In my code, delayed 300 milli sec, I don't think this is the best way to solve the issue.
func present(_ addVoiceShortcutViewController: INUIAddVoiceShortcutViewController,
for addVoiceShortcutButton: INUIAddVoiceShortcutButton) {
addVoiceShortcutViewController.delegate = self
// do not call this !!! // present(addVoiceShortcutViewController, animated: true)
let id = addVoiceShortcutButton.shortcut!.userActivity!.persistentIdentifier!
DispatchQueue.main.asyncAfter(deadline: .now() + .milliseconds(300)) {
self.getShortcut(id: id) { sc in
if let sc = sc {
DispatchQueue.main.async {
let vc = INUIEditVoiceShortcutViewController(voiceShortcut: sc)
self.present(vc, for: addVoiceShortcutButton)
}
} else {
fatalError()
}
}
}
Remember this code is for iOS 15. If you support iOS 14, just call previous present(addVoiceShortcutViewController).
I still don't figure out this is the best solution and need to keep watching another iOS beta version.
The bug still remains in iOS 14.7 beta 2.
But there's one way to solve the issue.
Just set your UITableView top layout constraint attach to super view, instead of attaching to safe area.
Remember this is just like a hack.
We should still wait to be fixed the bug by Apple.