I'm using Tauri 2.0 with Vite/Vue in the frontend, building for Windows only. I've followed the instructions to integrate notifications: https://v2.tauri.app/plugin/notification/
Even with a fresh app with all default configuration, everything works great in dev
, in build
, and when running the built exe from the release folder.
But if I move that exe outside the release folder, the app runs and everything works, except the notifications are non-existent. There are no errors in the console. Why? My config is below, but again, even a brand new project with nothing changed except to add notifications experiences the same issue.
tauri.conf.json
:
{
"$schema": "https://schema.tauri.app/config/2",
"productName": "myapp",
"version": "0.1.0",
"identifier": "com.myapp.app",
"build": {
"beforeDevCommand": "npm run dev",
"devUrl": "http://localhost:5173",
"beforeBuildCommand": "npm run build",
"frontendDist": "../dist"
},
"app": {
"windows": [
{
"title": "myapp",
"width": 400,
"height": 320,
"minWidth": 320,
"minHeight": 80
}
],
"security": {
"csp": null
}
},
"bundle": {
"active": true,
"targets": [ "app" ],
"icon": [
"icons/32x32.png",
"icons/128x128.png",
"icons/128x128@2x.png",
"icons/icon.icns",
"icons/icon.ico"
]
}
}
lib.rs
:
#[cfg_attr(mobile, tauri::mobile_entry_point)]
pub fn run() {
tauri::Builder::default()
.plugin(tauri_plugin_notification::init())
.plugin(tauri_plugin_shell::init())
.invoke_handler(tauri::generate_handler![greet])
.run(tauri::generate_context!())
.expect("error while running tauri application");
}
I know this works, but here is the JavaScript for sending notifications:
async request() {
let permissionGranted = await isPermissionGranted();
if (!permissionGranted) {
const permission = await requestPermission();
permissionGranted = permission === 'granted';
}
return permissionGranted;
}
async send(options) {
const hasPermission = await this.request();
if(hasPermission) {
sendNotification(options);
}
}
I created a bug report in the Github repo and learned this is a known issue and not expected to change.
Notifications simply won't work outside of the installation folder. The standalone .exe considers the release
folder to be the installation folder. So you need to build with an installer if you want them to work elsewhere.