I'm using Tauri 2.0 with Vite/Vue in the frontend, building for Windows only. I've followed the instructions to integrate notifications: /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": "/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/[email protected]",
"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'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/[email protected]",
"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);
}
}
Share
Improve this question
edited Nov 20, 2024 at 20:09
Dan
asked Nov 20, 2024 at 12:10
DanDan
63.2k18 gold badges110 silver badges119 bronze badges
1 Answer
Reset to default 0I 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.
发布者:admin,转转请注明出处:http://www.yc00.com/questions/1742358666a4428946.html
评论列表(0条)