NativeJS - Multiple calls
When making multiple simultaneous calls to the NativeJS bridge, subsequent assignments of window.location.href will overwrite the earlier assignments. The result is that only the last command will be executed. For example:
1
window.location.href = ... // first command
2
// later...
3
window.location.href = ... // second command overwrites the first one
Copied!
One solution is to introduce a small (500ms) delay before running the second command:
1
window.location.href = ... // first command
2
3
setTimeout(function() {
4
window.location.href = ... // second command
5
}, 500);
Copied!
The second solution is to pack both commands into a single NativeJS call to gonative://nativebridge/multi:
1
var urls = ['gonative://...', 'gonative://...'];
2
var json = JSON.stringify({urls: urls});
3
window.location.href = 'gonative://nativebridge/multi?data=' + encodeURIComponent(json);
Copied!
Last modified 1yr ago
Copy link