Skip to content
This repository has been archived by the owner on Jan 10, 2024. It is now read-only.

nsWebViewBridge undefined, ns-bridge-ready event never fires #117

Open
tskweres opened this issue May 4, 2021 · 4 comments
Open

nsWebViewBridge undefined, ns-bridge-ready event never fires #117

tskweres opened this issue May 4, 2021 · 4 comments

Comments

@tskweres
Copy link

tskweres commented May 4, 2021

My HTML webview looks like this:

<!DOCTYPE html>
	<html>
	<script>
	  window.addEventListener("ns-bridge-ready", function(e) {
			var nsWebViewBridge = e.detail || window.nsWebViewBridge;
			try {
				nsWebViewBridge.emit('loadWindow');
			} catch (err) {
				console.log(err);
			}
	  });
	</script>
	<body>
	  <h1>My First Heading</h1>
	</body>
	</html>

The event ns-bridge-ready never fires. If i change to DOMContentLoaded, it fires, but window.nsWebViewBridge is undefined

Nativescript 8+
package.json:

{
  "name": "Test",
  "main": "./src/main.ts",
  "displayName": "Test",
  "templateType": "App template",
  "version": "7.0.8",
  "description": "Test",
  "author": "[email protected]",
  "license": "SEE LICENSE IN <your-license-filename>",
  "publishConfig": {
    "access": "public"
  },
  "keywords": [
  ],
  "repository": "<fill-your-repository-here>",
  "homepage": "https://github.com/NativeScript/nativescript-app-templates",
  "bugs": {
    "url": "https://github.com/NativeScript/NativeScript/issues"
  },
  "dependencies": {
    "@angular/animations": "~11.2.7",
    "@angular/cdk": "^11.2.8",
    "@angular/common": "~11.2.7",
    "@angular/compiler": "~11.2.7",
    "@angular/core": "~11.2.7",
    "@angular/forms": "~11.2.7",
    "@angular/localize": "~11.0.0",
    "@angular/platform-browser": "~11.2.7",
    "@angular/platform-browser-dynamic": "~11.2.7",
    "@angular/router": "~11.2.7",
    "@nativescript/angular": "~11.8.0",
    "@nativescript/core": "^8.0.0",
    "@nativescript/secure-storage": "^3.0.0",
    "@nativescript/theme": "~3.0.0",
    "@ng-bootstrap/ng-bootstrap": "^9.1.0",
    "@nota/nativescript-webview-ext": "^8.0.0",
    "@nstudio/nativescript-checkbox": "^2.0.4",
    "@nstudio/nativescript-loading-indicator": "^4.0.0",
    "@nstudio/nativescript-pulltorefresh": "^3.0.1",
    "@schematics/angular": "^9.1.0",
    "@triniwiz/nativescript-image-cache-it": "^7.0.5",
    "@triniwiz/nativescript-pager": "^13.0.1",
    "@types/mocha": "^8.2.2",
    "bootstrap": "^4.5.0",
    "email-validator": "^2.0.4",
    "ethers": "^5.1.4",
    "etherspot": "^1.2.4",
    "libphonenumber-js": "^1.9.13",
    "moment": "^2.29.1",
    "nativescript-contacts-lite": "^0.2.7",
    "nativescript-lottie": "^5.0.3",
    "nativescript-materialdropdownlist": "^1.0.15",
    "nativescript-statusbar": "^5.0.0",
    "nativescript-taptic-engine": "^2.1.0",
    "nativescript-ui-chart": "^8.0.2",
    "nativescript-ui-listview": "^9.1.0",
    "nativescript-websockets": "^1.5.6",
    "numeral": "^2.0.6",
    "reflect-metadata": "^0.1.13",
    "rxjs": "^6.6.7",
    "util": "^0.12.3",
    "zone.js": "~0.11.1"
  },
  "devDependencies": {
    "@angular/compiler-cli": "~11.2.7",
    "@nativescript/ios": "8.0.0",
    "@nativescript/schematics": "^11.0.0",
    "@nativescript/webpack": "~5.0.0-beta.0",
    "@ngtools/webpack": "~11.2.6",
    "node-sass": "^5.0.0",
    "prettier": "^2.2.1",
    "tslint": "^6.1.3",
    "typescript": "~4.0.0"
  },
  "private": "true",
  "readme": "NativeScript Application"
}
@meightythree
Copy link

meightythree commented Feb 27, 2022

Same issue. Any update on it?

@m-abs
Copy link
Contributor

m-abs commented Feb 28, 2022

I've just published v8.0.1, I hope that fixes the issue.

I think it is a timing issue, so I tried to change how we emit the ns-bridge-ready.

I'm not sure why but in DOMContentLoaded window.nsWebViewBridge is always undefined, at least on Android's webview.

If you're still having this issue, I need to know if it just iOS or Android or both, which versions etc.

@meightythree
Copy link

@m-abs Thanks for the update! That was really quick!

@BenasApulskis190
Copy link

I am facing the same issue but for me ios simulation works as expected but then i connect device bridge is not working like in this issue #138

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants