mirror of
https://github.com/lil-org/tokenary.git
synced 2024-12-25 04:53:05 +03:00
20 lines
669 B
Swift
20 lines
669 B
Swift
// Copyright © 2021 Tokenary. All rights reserved.
|
|
|
|
import SafariServices
|
|
import os.log
|
|
|
|
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)
|
|
}
|
|
|
|
}
|