Mail App Extensions were announced by Apple at WWDC21. The implementation is very similar to Safari App Extensions. With the method showPreferencesForExtension(withIdentifier:completionHandler:)
of the SFSafariApplication
class it is possible to launch Safari and open the preferences panel for a specific Safari app extension.
Example Code:
import SafariServices
SFSafariApplication.showPreferencesForExtension(withIdentifier: "example") { error in
// error handling...
}
In addition, the state of the extension can be checked. This is useful to show the user in the container app if the extension is enabled. You can implement this using the getStateOfSafariExtension(withIdentifier:completionHandler:)
method of the SFSafariExtensionManager
class.
Example Code:
import SafariServices
SFSafariExtensionManager.getStateOfSafariExtension(withIdentifier: "example") { state, error in
// check state and error handling...
}
Unfortunately, I haven't found any ways to implement this for Mail App Extensions yet. Of course, I know that I can open the Mail App quite easily with NSWorkspace
:
if let url = NSWorkspace.shared.urlForApplication(withBundleIdentifier: "com.apple.mail") {
NSWorkspace.shared.open(url)
}
...but this is just a workaround and not a solution. I want to open the "Mail App Extension" preferences panel and read the status of the extension. Am I missing an API for this?