ExamplePlugin.swift 504 B

12345678910111213141516171819
  1. // Copyright 2019-2023 Tauri Programme within The Commons Conservancy
  2. // SPDX-License-Identifier: Apache-2.0
  3. // SPDX-License-Identifier: MIT
  4. import UIKit
  5. import WebKit
  6. import Tauri
  7. class ExamplePlugin: Plugin {
  8. @objc public func ping(_ invoke: Invoke) throws {
  9. let value = invoke.getString("value")
  10. invoke.resolve(["value": value as Any])
  11. }
  12. }
  13. @_cdecl("init_plugin_sample")
  14. func initPlugin(webview: WKWebView?) {
  15. Tauri.registerPlugin(webview: webview, name: "sample", plugin: ExamplePlugin())
  16. }