ExamplePlugin.swift 544 B

1234567891011121314151617181920212223
  1. // Copyright 2019-2023 Tauri Programme within The Commons Conservancy
  2. // SPDX-License-Identifier: Apache-2.0
  3. // SPDX-License-Identifier: MIT
  4. import SwiftRs
  5. import Tauri
  6. import UIKit
  7. import WebKit
  8. class ExamplePlugin: Plugin {
  9. @objc public func ping(_ invoke: Invoke) throws {
  10. let onEvent = invoke.getChannel("onEvent")
  11. onEvent?.send(["kind": "ping"])
  12. let value = invoke.getString("value")
  13. invoke.resolve(["value": value as Any])
  14. }
  15. }
  16. @_cdecl("init_plugin_sample")
  17. func initPlugin() -> Plugin {
  18. return ExamplePlugin()
  19. }