Skip to content

Javascript Notification API throws an error upon invokation #2330

@elvinaspredkelis

Description

@elvinaspredkelis

Describe the bug

JS API for notifications throw an error upon invokation:

Unhandled Promise Rejection: TypeError: undefined is not a function (near '...window.__TAURI__.invoke...')

To Reproduce

Steps to reproduce the behavior:

  1. Install Tauri via Vue CLI
  2. Try to invoke any of the notification module methods via the JS API

Expected behavior

Default behavior for notification invokation.

Platform and Versions (required):

Operating System - Mac OS, version 11.2.3 X64

Node.js environment
  Node.js - 15.2.0
  @tauri-apps/cli - 1.0.0-beta.6
  @tauri-apps/api - 1.0.0-beta.5

Global packages
  npm - 6.14.9
  yarn - 1.22.10

Rust environment
  rustc - 1.51.0
  cargo - 1.51.0

App directory structure
/node_modules
/public
/src-tauri
/src

App
  tauri.rs - 1.0.0-beta.5
  build-type - bundle
  CSP - default-src blob: data: filesystem: ws: wss: http: https: tauri: 'unsafe-eval' 'unsafe-inline' 'self' img-src: 'self'
  distDir - Set automatically by Vue CLI plugin
  devPath - Set automatically by Vue CLI plugin
  framework - Vue.js (Vue CLI)
  bundler - Webpack

Additional context

Exact dummy snippet throwing an error, borrowed from the example repositories:

if (Notification.permission == "default") {
        Notification.requestPermission().then((response) => {
            if (response === "granted") {
              console.log("OK")
            } else {
              console.log("Permission is " + response);
            }
          })
      }

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions