← all modules

Std.Native

Std.Native

Types
  type alias Coords = { lat : Float , lng : Float , accuracy : Float }
  type alias ShareContent = { title : String , text : String , url : String }
  type alias BatteryStatus = { charging : Bool , level : Float }
  type alias PickedFile = { name : String , mime : String , dataUrl : String }
  type CodeFormat = Qr | Aztec | DataMatrix | Pdf417 | Ean8 | Ean13 | UpcE | Code39 | Code93 | Code128 | Itf | Codabar
  type alias ScanOptions = { formats : List CodeFormat , prompt : String }
  type alias ScannedCode = { format : CodeFormat , text : String }

Values
  authenticate : String -> Task Error Bool
      Ask the user to confirm it is them with the device's biometrics — Face ID or
  batteryStatus : () -> Task Error BatteryStatus
      Read the current `BatteryStatus`. A function so each call reads the CURRENT
  bridge : String -> String -> Task Error String
      Call a CUSTOM native capability the app registers itself — the extension
  capturePhoto : () -> Task Error PickedFile
      Take a photo with the device camera (on mobile; a file picker on desktop).
  clipboardRead : () -> Task Error String
      Read the text currently on the device clipboard — the "Paste" gesture. A
  clipboardWrite : String -> Task Error ()
      Copy text to the device clipboard — the "Copy link" / "Copy code" gesture.
  geolocation : () -> Task Error Coords
      Ask the device for the current location. A function (not a bare `Task`) so
  isOnline : () -> Task Error Bool
      Whether the device currently reports a network connection
  language : () -> Task Error String
      The device's preferred UI language as a BCP-47 tag (`"en-US"`, `"fr"`, …),
  notify : String -> String -> Task Error ()
      Show a system notification with a `title` and `body`. The first call asks
  openUrl : String -> Task Error ()
      Open a URL in a new tab / the system browser (`window.open`) — use it to
  pickFile : () -> Task Error PickedFile
      Open the device file picker and read the chosen file. `Err` on cancel — the
  pickImage : () -> Task Error PickedFile
      Open the photo gallery / image picker (files filtered to images). Same
  prefersDarkMode : () -> Task Error Bool
      Whether the device is currently in dark mode (the `prefers-color-scheme:
  scanCode : ScanOptions -> Task Error (Maybe ScannedCode)
      Scan a QR code or a barcode with the device camera. The native shell shows
  secureGet : String -> Task Error (Maybe Secret)
      Read the secret stored under a `key`: `Ok (Just secret)`, `Ok Nothing` when
  secureRemove : String -> Task Error ()
      Delete the secret stored under a `key` (a no-op `Ok` if it was never set).
  secureSet : String -> Secret -> Task Error ()
      Store a secret `value` under a `key` in the device's SECURE store: the
  setTitle : String -> Task Error ()
      Set the document / window title (the browser tab label, the webview window
  share : ShareContent -> Task Error ()
      Open the platform share sheet (iOS/Android native sheet, or the browser's
  storageGet : String -> Task Error (Maybe String)
      Read the value stored under a `key`, `Nothing` if the key was never set. A
  storageRemove : String -> Task Error ()
      Delete the value stored under a `key` (a no-op `Ok` if it was never set).
  storageSet : String -> String -> Task Error ()
      Persist a `value` under a `key` in the device's local storage (the browser /
  vibrate : Int -> Task Error ()
      Vibrate the device for `ms` milliseconds — a haptic tap on a phone. On