feat(deeplink): register and handle whatsapp:// links (all platforms) - #25
Open
karem505 wants to merge 2 commits into
Open
feat(deeplink): register and handle whatsapp:// links (all platforms)#25karem505 wants to merge 2 commits into
karem505 wants to merge 2 commits into
Conversation
…age never notifies (#3) The v0.3.3 diagnostic build proved that on some Windows 11 installs WhatsApp Web never calls window.Notification NOR ServiceWorkerRegistration.showNotification (log: session start + AUMID registered, but no `commands::notify` when messages arrive), so the JS-driven path silently produces no toast. A page-injected script cannot reach the service worker's own context, so the fallback must live in Rust. - set_unread: detect unread-count rises from the <title> and raise a Rust-side toast (count only, generic body — no PII) - notify: record_shim_notify() marks a page-driven toast so the fallback stays quiet for 10s (SHIM_GRACE) — no double toast for the same message - maybe_unread_toast gates: app locked -> suppress; notifications disabled -> suppress; account window focused -> suppress; shim fired within grace -> suppress; same count within 90s -> suppress - attribution + logging follow the existing no-PII dlog rules
…macOS) (#23) Clicking a WhatsApp link (whatsapp://send?phone=...) did nothing: the installers never registered the scheme, and even with a manual xdg-mime default the app opened without opening the requested chat. Registration (all platforms, one config): - tauri.conf.json: plugins.deep-link.desktop = [{schemes: ["whatsapp"]}]. The Tauri CLI turns this into MimeType=x-scheme-handler/whatsapp in the generated .desktop for deb AND AppImage, registry handlers in NSIS/MSI, and CFBundleURLTypes in the macOS Info.plist. Verified end-to-end on Linux: the built deb's whatRust.desktop now carries the MimeType line. - Flatpak ships its own .desktop file: add the same MimeType (plus TryExec) there. Handling: - new deeplink.rs: pure URL parser (send?phone=&text=, digits-only normalisation, case-insensitive scheme, malformed-escape safe) with full unit-test coverage - single-instance callback: a second launch carrying a whatsapp:// URL routes to open_whatsapp_link() instead of just show_main() - open_whatsapp_link: translates the link to https://wa.me/<digits> (with ?text= carried over) and navigates the active account window — wa.me is the exact click-to-chat page WhatsApp Web handles natively. Lock-screen aware: while locked, shows the lock screen like every other reveal path. - on_navigation: reject whatsapp:// in the webview so a stray in-page link can't bounce back to the OS handler and re-launch the app
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes #23 (WhatsApp links don't open the app / don't open the chat on Linux).
Root causes (two separate gaps)
.desktophad noMimeType=entry, soxdg-mime query default x-scheme-handler/whatsappreturned empty after install — the OS had no reason to handwhatsapp://links to whatRust.show_mainonly), so the chat never opened.What this PR does
Registration — one config, all platforms
tauri.conf.jsongains:The Tauri CLI maps this to
MimeType=x-scheme-handler/whatsapp;in the generated.desktopfor deb and AppImage, registry handlers in NSIS/MSI, andCFBundleURLTypesin the macOS Info.plist. Verified end-to-end on Linux: built a deb with this config and confirmed the packagedwhatRust.desktopnow containsMimeType=x-scheme-handler/whatsapp. The Flatpak ships its own.desktopfile, so it gets the sameMimeType(plusTryExec) added directly.Handling
src-tauri/src/deeplink.rs(new): pure parser forwhatsapp://send?phone=...&text=...— digits-only phone normalization (wa.me style),+/%XXdecoding, case-insensitive scheme, byte-wise prefix compare (no panics on multi-byte input). 8 unit tests.whatsapp://URL routes toopen_whatsapp_link()instead of plainshow_main().open_whatsapp_link: translateswhatsapp://send?phone=1555...&text=hi→https://wa.me/1555...?text=hiand navigates the active account window. wa.me is the exact click-to-chat page WhatsApp Web handles natively, so the chat opens inside the logged-in session. Falls back to the first open account window, and while app-locked it shows the lock screen like every other reveal path.on_navigation: now also rejectswhatsapp://inside the webview, so a stray in-page link can't bounce to the OS handler and re-launch the app.whatsapp://sendwithout a phone (share-sheet style) opens/focuses the app at the chat list.Verification
cargo checkclean;cargo test --lib85 passed (8 new deeplink tests)tauri build --debug --bundles debsucceeds and the deb'susr/share/applications/whatRust.desktopcontainsMimeType=x-scheme-handler/whatsapp(verified by extracting the package)Post-install note
xdg-mime query default x-scheme-handler/whatsappreturns whatRust after install for deb/AppImage (bundler wiresupdate-desktop-databasevia the maintainer scripts); Flatpak exports the .desktop with the scheme through its own pipeline. On the Flatpak sandbox, incomingwhatsapp://launches go throughflatpak run— the single-instance D-Bus name (already scoped to the Flatpak ID) hands the URL to the running instance.