Skip to content

Commit 725ff42

Browse files
authored
fix(notification/windows): Grant permission without invoking backend (#1556)
* fix(notification/windows): Grant permission without invoking backend * fmt
1 parent 117c67d commit 725ff42

File tree

4 files changed

+12
-3
lines changed

4 files changed

+12
-3
lines changed
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
notification: patch
3+
---
4+
5+
Fixed an issue that caused the `notification` plugin's initialization script to cause the WebView on Windows to throw a `STATUS_ACCESS_VIOLATION` error on remote websites.

plugins/notification/guest-js/init.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,8 @@ import type { Options } from "./index";
1010
let permissionValue = "default";
1111

1212
async function isPermissionGranted(): Promise<boolean> {
13-
if (window.Notification.permission !== "default") {
13+
// @ts-expect-error __TEMPLATE_windows__ will be replaced in rust before it's injected.
14+
if (window.Notification.permission !== "default" || __TEMPLATE_windows__) {
1415
return await Promise.resolve(
1516
window.Notification.permission === "granted",
1617
);

plugins/notification/src/init-iife.js

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

plugins/notification/src/lib.rs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -227,7 +227,10 @@ pub fn init<R: Runtime>() -> TauriPlugin<R> {
227227
commands::request_permission,
228228
commands::is_permission_granted
229229
])
230-
.js_init_script(include_str!("init-iife.js").to_string())
230+
.js_init_script(include_str!("init-iife.js").replace(
231+
"__TEMPLATE_windows__",
232+
if cfg!(windows) { "true" } else { "false" },
233+
))
231234
.setup(|app, api| {
232235
#[cfg(mobile)]
233236
let notification = mobile::init(app, api)?;

0 commit comments

Comments
 (0)