Skip to content

Commit

Permalink
fix(web): registerWebMethod visibilitychange (#46)
Browse files Browse the repository at this point in the history
  • Loading branch information
gronxb authored Jun 19, 2024
1 parent 1c81104 commit c73de98
Showing 1 changed file with 11 additions and 0 deletions.
11 changes: 11 additions & 0 deletions packages/web/src/registerWebMethod.ts
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,17 @@ export const registerWebMethod = <BridgeObject extends WebBridge>(
return bridge;
}

document.addEventListener("visibilitychange", () => {
if (document.visibilityState === "visible") {
window.ReactNativeWebView?.postMessage(
JSON.stringify({
type: "registerWebMethod",
body: { bridgeNames },
}),
);
}
});

register();
return bridge;
};

0 comments on commit c73de98

Please sign in to comment.