mirror of
https://github.com/status-im/status-react.git
synced 2025-01-10 02:56:07 +00:00
3e7c059b59
Signed-off-by: Goran Jovic <goranjovic@gmail.com>
29 lines
866 B
JavaScript
29 lines
866 B
JavaScript
(function () {
|
|
function bridgeSend(data){
|
|
WebViewBridge.send(JSON.stringify(data));
|
|
}
|
|
|
|
var history = window.history;
|
|
var pushState = history.pushState;
|
|
history.pushState = function(state) {
|
|
setTimeout(function () {
|
|
bridgeSend({
|
|
type: 'history-state-changed',
|
|
navState: { url: location.href, title: document.title }
|
|
});
|
|
}, 100);
|
|
return pushState.apply(history, arguments);
|
|
};
|
|
|
|
window.addEventListener('message', function (event) {
|
|
if (!event.data || !event.data.type) { return; }
|
|
if (event.data.type === 'STATUS_API_REQUEST') {
|
|
bridgeSend({
|
|
type: 'status-api-request',
|
|
permissions: event.data.permissions,
|
|
host: window.location.hostname
|
|
});
|
|
}
|
|
});
|
|
}());
|