【问题标题】:status bar notification in web applicationWeb 应用程序中的状态栏通知
【发布时间】:2015-11-30 21:08:34
【问题描述】:

我有一个响应式 Web 应用程序,并希望当应用程序在移动浏览器中运行时在移动设备的状态栏中显示通知。 谷歌搜索后我能找到的最好的是:status-bar-notification

我无法理解这将如何帮助显示通知。 与上述链接中的问题类似,我想在点击时显示通知。

<!DOCTYPE html>
<html>
    <head>
        <meta charset="utf-8" />
        <meta name="format-detection" content="telephone=no" />
        <meta name="viewport" content="user-scalable=no, initial-scale=1, maximum-scale=1, minimum-scale=1, width=device-width, height=device-height, target-densitydpi=device-dpi" />
        <link rel="stylesheet" type="text/css" href="css/index.css" />
        <title>Hello World</title>
    </head>
    <body>
        <input type="button" value="Notiiiiiiif" id="btNotif"/>
        <script type="text/javascript" src="cordova.js"></script>  
        <script type="text/javascript" src="js/index.js"></script>

        <script type="text/javascript">
            app.initialize();
            btNotif = document.getElementById('btNotif');
            btNotif.addEventListener('click', function(){
                //There I want a notification to appear in the mobile status bar
            });
        </script>
    </body>
</html>

有什么办法可以做到吗?

【问题讨论】:

标签: javascript android html cordova notifications


【解决方案1】:

有两种类型的通知:

– 本地通知,您可以在应用中生成。

– 推送通知,由 Apple、Google 等或某些通知提供商提供。

你需要一个插件,看看cordova plugin site

如果你使用本地通知,那么插件会在状态栏中生成消息,而不是你的 JS!但是你给插件一个消息、一个图标和一个徽章编号。

所有通知处理都必须在您的应用中。这意味着例如:您必须删除通知,如果不再使用,徽章编号的数量等。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2011-06-26
    • 2011-02-23
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多