Safari App Extensions don’t allow you to change toolbar button images dynamically, but they do let you add a string to the button as a badge by passing a string to the extension handler’s validationHandler
method:
override func validateToolbarItem(in window: SFSafariWindow, validationHandler: @escaping ((Bool, String) -> Void)) {
// This is called when Safari's state changed in some way that would require the extension's toolbar item to be validated again.
validationHandler(true, "1")
}
Unfortunately, this badged text doesn’t look great:
I can’t find anything in the documentation about customising the look of the badged text, but just in case, is there any way to avoid the clipping of what is presumably meant to be a circular badge?