简体   繁体   中英

Android Webview Desktop Notification Support

I'm trying to implement a webview of my desktop notification. In desktop application I had already implemented the use of desktop notification using the following Javascript code

function notifyMe() {
    // Let's check if the browser supports notifications
    if (!("Notification" in window)) {
        alert("This browser does not support desktop notification");
    }

    // Let's check whether notification permissions have already been granted
    else if (Notification.permission === "granted") {
        // If it's okay let's create a notification
        var notification = new Notification("Hi there!");
    }

    // Otherwise, we need to ask the user for permission
    else if (Notification.permission !== "denied") {
        Notification.requestPermission(function (permission) {
            // If the user accepts, let's create a notification
            if (permission === "granted") {
                var notification = new Notification("Hi there!");
            }
        });
    }

    // At last, if the user has denied notifications, and you
    // want to be respectful there is no need to bother them any more.
}

When I opened the view in the android application an alert shown that this device does not support desktop notification. However, using the mobile browser (Chrome) this code let me allow to request notification but fails to give me the same notification in the desktop interface. Thank you so much :)

您应该像这里发送未决的意图查看此

Visit this link for a complete fragment tutorial. I have learned about Fragments by this tutorial. It is a complete Responsive by the Admin in the Tutorial Tutorial

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM