How to use @nota/nativescript-webview-ext - 4 common examples

To help you get started, we’ve selected a few @nota/nativescript-webview-ext examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github Notalib / nativescript-webview-ext / tests / app / ui / web-view / web-view-tests-common.ts View on Github external
private runWebViewJavaScriptInterfaceTest(done: DoneCallback, scriptCode: string, expected: T, msg: string) {
        const webView = this.testView;

        // >> webview-interface-tests
        webView.on(WebViewExt.loadFinishedEvent, async (args: LoadEventData) => {
            // >> (hide)

            try {
                TKUnit.assertNull(args.error, args.error);

                TKUnit.assertDeepEqual(await webView.executeJavaScript(scriptCode), expected, msg);
                done();
            } catch (err) {
                done(err);
            }
            // << (hide)
        });

        webView.src = javascriptCallsFile;
        // << webview-interface-tests
    }
github Notalib / nativescript-webview-ext / tests / app / ui / web-view / web-view-tests-common.ts View on Github external
public create(): WebViewExt {
        // >> declare-webview
        const webView = new WebViewExt();
        webView.debugMode = true;
        // << declare-webview
        return webView;
    }
github Notalib / nativescript-webview-ext / demo / app / main-page.ts View on Github external
if (isAndroid) {
        webview.src = "http://10.0.2.2:8080";
    } else {
        webview.src = "http://localhost:8080";
    }

    webview.on(WebViewExt.shouldOverrideUrlLoadingEvent, (args: ShouldOverrideUrlLoadEventData) => {
        console.log(args.url);
        console.log(args.httpMethod);
        if (args.url.indexOf("google.com") !== -1) {
            args.cancel = true;
        }
    });

    webview.on(WebViewExt.loadFinishedEvent, (args: LoadFinishedEventData) => {
        console.log(`WebViewExt.loadFinishedEvent: ${args.url}`);
        webview.loadStyleSheetFile("local-stylesheet.css", "~/assets/test-data/css/local-stylesheet.css", false);
    });

    webview.on("gotMessage", (msg) => {
        gotMessageData = msg.data;
        console.log(`webview.gotMessage: ${JSON.stringify(msg.data)} (${typeof msg})`);
    });
}
github Notalib / nativescript-webview-ext / demo / app / main-page.ts View on Github external
export function webviewLoaded(args: LoadEventData) {
    webview = args.object;

    if (isAndroid) {
        webview.src = "http://10.0.2.2:8080";
    } else {
        webview.src = "http://localhost:8080";
    }

    webview.on(WebViewExt.shouldOverrideUrlLoadingEvent, (args: ShouldOverrideUrlLoadEventData) => {
        console.log(args.url);
        console.log(args.httpMethod);
        if (args.url.indexOf("google.com") !== -1) {
            args.cancel = true;
        }
    });

    webview.on(WebViewExt.loadFinishedEvent, (args: LoadFinishedEventData) => {
        console.log(`WebViewExt.loadFinishedEvent: ${args.url}`);
        webview.loadStyleSheetFile("local-stylesheet.css", "~/assets/test-data/css/local-stylesheet.css", false);
    });

    webview.on("gotMessage", (msg) => {
        gotMessageData = msg.data;
        console.log(`webview.gotMessage: ${JSON.stringify(msg.data)} (${typeof msg})`);
    });

@nota/nativescript-webview-ext

Extended WebView for NativeScript which adds 'x-local' scheme for local-files. events between WebView and native-layer, javascript execution, injecting CSS and JS-files.

Apache-2.0
Latest version published 2 years ago

Package Health Score

54 / 100
Full package analysis