tauri-apps / tauri

Build smaller, faster, and more secure desktop and mobile applications with a web frontend.
https://tauri.app
Apache License 2.0
85.81k stars 2.6k forks source link

Notifications not working in Windows 10 #2693

Closed kubijo closed 3 years ago

kubijo commented 3 years ago

Describe the bug

The windows build of my app doesn't show notifications, nor asks if I want to allow them.

This is the code that I use for notifications permission request (since published version of API still has a bug in this code):

notification.isPermissionGranted().then(isGranted => {
    console.log({isGranted});
    if (isGranted) return;

    const answer = window.__TAURI__._invoke('tauri', {
        __tauriModule: 'Notification',
        message: { cmd: 'requestNotificationPermission' },
    });

    console.log({answer});
});

and this is the code I'm using to test the notification

notification.sendNotification({
    body: 'Yo-ho-ho, yer not desiring me without a fortune!',
    title: 'Oh, punishment!',
});

To Reproduce

I'd give more info if I'd know what would help, but at this point I haven't got a clue, but will cooperate if you have an idea what I should try & report back. The console in debug build doesn't show anything and both request and then notifications sending do work on latest Ubuntu

Platform and Versions (required):

Operating System - Windows, version 10.0.19043 X64
Webview2 - 94.0.992.31

Node.js environment
  Node.js - 14.17.0
  @tauri-apps/cli - 1.0.0-beta.10
  @tauri-apps/api - 1.0.0-beta.8

Global packages
  npm - 6.14.13
  yarn - 1.22.11

Rust environment
  rustc - 1.57.0-nightly
  cargo - 1.57.0-nightly

App directory structure
/src-tauri
/.yarn
/node_modules

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'

Additional context

tauri.conf

{
  "package": {
    "productName": "Braiins OS Toolbox",
    "version": "0.1.0"
  },
  "build": {
    "distDir": "../../../web-ui/build/js/bundle/toolbox-tauri",
    "devPath": "http://localhost:3001",
    "withGlobalTauri": false
  },
  "tauri": {
    "bundle": {
      "active": true,
      "targets": "all",
      "identifier": "com.tauri.dev",
      "icon": [
        "icons/32x32.png",
        "icons/128x128.png",
        "icons/128x128@2x.png",
        "icons/icon.icns",
        "icons/icon.ico"
      ],
      "resources": [],
      "externalBin": [],
      "copyright": "",
      "category": "Utility",
      "shortDescription": "",
      "longDescription": "",
      "deb": {
        "depends": [],
        "useBootstrapper": false
      },
      "macOS": {
        "frameworks": [],
        "minimumSystemVersion": "",
        "useBootstrapper": false,
        "exceptionDomain": "",
        "signingIdentity": null,
        "entitlements": null
      },
      "windows": {
        "certificateThumbprint": null,
        "digestAlgorithm": "sha256",
        "timestampUrl": ""
      }
    },
    "updater": {
      "active": false
    },
    "systemTray": {
      "iconPath": "icons/icon.png",
      "iconAsTemplate": false
    },
    "allowlist": {
      "all": true,
      "notification": {
        "all": true
      }
    },
    "windows": [
      {
        "title": "Braiins OS Toolbox",
        "resizable": true,
        "fullscreen": false
      }
    ],
    "security": {
      "csp": "default-src blob: data: filesystem: ws: wss: http: https: tauri: 'unsafe-eval' 'unsafe-inline' 'self' img-src: 'self'"
    }
  }
}

Stack Trace

None seen anywhere

FabianLars commented 3 years ago

Your tauri.rs version is outdated. You're at beta.5, current one is beta.8, BUT iirc notifications are broken on beta.8 too with unreleased fixes in the next branch. So you may want to try that one out...

kubijo commented 3 years ago

I see ... I can certainly test it out, but would very much appretiate any help with bumping the version to the next branch … I can manage on the javascript side, but rust is very much not my area of expertize

FabianLars commented 3 years ago

For beta.8: tauri = {version = "1.0.0-beta.8", features = [...] } For git: tauri = {git = "https://github.com/tauri-apps/tauri", branch = "next", features = [...] } Run cargo update after changing between published and git versions!

kubijo commented 3 years ago

Neither of those helped, but I've just discovered what might be the problem with the persmission request image

FabianLars commented 3 years ago

Does it work if you just use Notification.requestPermission()?

kubijo commented 3 years ago

AFAIK there is still this error: https://github.com/tauri-apps/tauri/issues/2330

FabianLars commented 3 years ago

Not if you're using the next branch or tauri.rs >= beta.6. Also, that error in your screenshot is because _invoke got renamed to __TAURI_INVOKE__ (don't know when, but should be released too)

But again, just try Notification.requestPermission() it really should work (on the next branch at least. i think it panics on beta.8)

kubijo commented 3 years ago

I'd think that this is about @tauri-aps/api and so this should still be an issue since there is no newer version of that package, but I've changed it anyway and just started the re-compilation to try it out and confirm (w10 is pretty slow in Virtualbox :-))

kubijo commented 3 years ago

OK ... I stand corrected! Thanks for your time and patience!

kubijo commented 3 years ago

Is the fact that the notification has a title Windows Powershell here to stay, or will we get our App name once this gets out?

image

FabianLars commented 3 years ago

It should be your app name in a release build (tauri build) and PowerShell in debug builds/tauri dev-runs.