Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Ionic v3 webkit undefined #204

Open
poohia opened this issue Nov 9, 2020 · 0 comments
Open

Ionic v3 webkit undefined #204

poohia opened this issue Nov 9, 2020 · 0 comments

Comments

@poohia
Copy link

poohia commented Nov 9, 2020

With InAppBrowser it's possible to use webkit.messageHandlers.cordova_iab.postMessage.
But with ThemeableBrowser webkit is undefined

private options: ThemeableBrowserOptions = {
        statusbar: {
            color: "#ffffffff",
        },
        toolbar: {
            color: "#ffffffff",
            height: 44,
        },
        title: {
            color: "#ffffffff",
            showPageTitle: false,
        },
        backButton: {
            wwwImage: "assets/icon/arrow-back.png",
            align: "left",
            event: "backPressed",
        },
        closeButton: {
            wwwImage: "assets/icon/close.png",
            align: "right",
            event: "closePressed",
        },
        backButtonCanClose: false,
        hidden: true,
    };

const browserSSO: ThemeableBrowserObject = this.themeableBrowser.create(
            this.currentPage,
            "_blank",
            this.options
        );

browserSSO.on("loadstop").subscribe(() => {
            if (browserSSO != undefined) {
                browserSSO.executeScript({
                    code: "\
                     var message = 'this is the message';\
                     var messageObj = {my_message: message};\
                     var stringifiedMessageObj = JSON.stringify(messageObj);\
                     webkit.messageHandlers.cordova_iab.postMessage(stringifiedMessageObj);",
                });

                browserSSO.show();
            }
        });

browserSSO.on("message").subscribe(e => {
           alert("message received");
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant