1
0
mirror of https://github.com/yattee/yattee.git synced 2024-12-15 06:40:32 +05:30
yattee/Open in Yattee/SafariWebExtensionHandler.swift

16 lines
616 B
Swift
Raw Normal View History

2021-10-24 18:01:10 +05:30
import os.log
import SafariServices
final class SafariWebExtensionHandler: NSObject, NSExtensionRequestHandling {
func beginRequest(with context: NSExtensionContext) {
let item = context.inputItems[0] as! NSExtensionItem
let message = item.userInfo?[SFExtensionMessageKey]
os_log(.default, "Received message from browser.runtime.sendNativeMessage: %@", message as! CVarArg)
let response = NSExtensionItem()
response.userInfo = [SFExtensionMessageKey: ["Response to": message]]
context.completeRequest(returningItems: [response], completionHandler: nil)
}
}