JavaScript Bridge1 min read
Bridge Calls From Links (URL Protocol)
Call simple native methods from plain links with wapp:// URLs, receive results with a callback, and send several commands at once.
Overview
Some simple bridge methods can be called from a link instead of JavaScript, for example from an email template or a CMS that strips scripts.
html
<a href="wapp://haptics/trigger?params=%7B%22style%22%3A%22impactHeavy%22%7D">Buzz</a>The format is wapp://<module>/<method>?params=<URL-encoded JSON>.
Methods that work as links
Only methods without personal data or native screens:
| Link | Method |
|---|---|
wapp://core/deviceInfo | Device info (use a callback to receive it) |
wapp://haptics/trigger | Vibration |
wapp://appReview/prompt, wapp://appReview/openStoreListing | Rating prompt, store page |
wapp://barcode/setPrompt | Scanner text |
wapp://firebaseAnalytics/logEvent | Analytics event |
wapp://crashlytics/log | Crashlytics log line |
Sign-in, payments, contacts and anything else that returns or sends personal data need JavaScript.
Receive the result
Add "callback" with the name of a global function to the parameters:
html
<script>
function onInfo(result) { console.log(result.platform); }
</script>
<a href="wapp://core/deviceInfo?params=%7B%22callback%22%3A%22onInfo%22%7D">Show device</a>Several commands
wapp://nativebridge/multi?data=<URL-encoded JSON array> runs up to 20 commands, each { "module", "method", "params" }.
Rules
- Links follow the same Website access rules as JavaScript calls.
- The older
wsta://andctn://schemes still work.