tauri-apps / tauri

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

[bug] Notification API shows wrong permission and does not ask for permissions #5813

Open bitjip opened 1 year ago

bitjip commented 1 year ago

Describe the bug

The isPermissionGranted() method in javascript returns true, while the permissions for the notifications are disabled. See screenshot.

The requestPermission() also returns granted. Because of this I don't get a popup to change the notification permissions?

The notifications work if I manually switch the toggle. But it would be nice if the application could request the permissions.

I am using a MacBook Pro (15-inch, 2019), with macOS Monterey 12.4

screenshot_permissions

Reproduction

  1. Disable the permissions for the application
  2. Run the following code
import { isPermissionGranted, requestPermission } from '@tauri-apps/api/notification';

async function testPermissions() {
  const permissionGranted = await isPermissionGranted();
  console.log(`Permission granted: ${permissionGranted}`);

  const permission = await requestPermission();
  console.log(`Permission: ${permission}`);
}

testPermissions();

Expected behavior

I would expect that when I turn off the permissions, the isPermissionGranted() method returns false; I would expect that if the permissions are turned off, the requestPermission() method gives a popup to change the permissions.

Platform and versions

Environment › OS: Mac OS 12.4.0 X64 › Node.js: 16.18.0 › npm: 8.12.1 › pnpm: Not installed! › yarn: Not installed! › rustup: 1.24.3 › rustc: 1.60.0 › cargo: 1.60.0 › Rust toolchain: stable-x86_64-apple-darwin

Packages › @tauri-apps/cli [NPM]: 1.2.2 › @tauri-apps/api [NPM]: 1.2.0 › tauri [RUST]: 1.2.2, › tauri-build [RUST]: 1.2.1, › tao [RUST]: 0.15.7, › wry [RUST]: 0.23.3,

App › framework: Vue.js (Vue CLI) › bundler: Webpack

App directory structure ├─ dist ├─ node_modules ├─ public ├─ src-tauri ├─ .git └─ src

Stack trace

No response

Additional context

No response

wesin commented 1 year ago

windows is also not working. when i close the powershell notification.