本地通知在PhoneGap的3.3.0 [英] Local notification in phonegap 3.3.0

查看:212
本文介绍了本地通知在PhoneGap的3.3.0的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

谢谢道森!下面提到的问题已经解决了机器人。但可悲的是,当我打造的ios项目不起作用,任何人都可以帮忙吗?

我要使用这个插件打造一款Android / IOS与本地通知应用程序。 https://github.com/katzer/cordova-plugin-local-notifications/wiki

I am going to using this plugin to build a android/ios apps with local notification. https://github.com/katzer/cordova-plugin-local-notifications/wiki

首先,我创建了一个的PhoneGap项目

First I created a phonegap project

phonegap create notification

添加插件

cordova plugin add https://github.com/katzer/cordova-plugin-local-notifications.git

修改/www/config.xml

Modify the /www/config.xml

<gap:plugin name="de.appplant.cordova.plugin.local-notification" />

我复制本地notification.js到/ WWW目录和index.html的

I copied local-notification.js to /www dir and referenced it in the index.html

<html>
<head>
    <meta charset="utf-8" />
    <meta name="format-detection" content="telephone=no" />
    <!-- WARNING: for iOS 7, remove the width=device-width and height=device-height attributes. See https://issues.apache.org/jira/browse/CB-4323 -->
    <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>
    <div class="app">
        <h1>PhoneGap</h1>
        <div id="deviceready" class="blink">
            <p class="event listening">Connecting to Device</p>
            <p class="event received">Device is Ready</p>
        </div>
    </div>
    <script type="text/javascript" src="cordova.js"></script>
    <script type="text/javascript" src="local-notification.js"></script>
    <script type="text/javascript">]
        window.plugin.notification.local.add({ message: 'Great app!' });
    </script>
</body>

我建立使用该命令的Andr​​oid应用程序

I built the android apps using the command

phonegap build android

我能成功地构建了Android应用程序,但没有通知poped了预期。 任何人都可以知道什么是我错了,在上面的seetting?非常感谢大家。

I can successfully built the android apps but there is no notification poped up as expected. Can anyone know whats wrong with me at the above seetting? Many thanks to all of you.

推荐答案

您将无法调用该函数后才deviceReady事件触发。

You wont be able to call that function until after the deviceReady event has fired.

有关测试,我总是把我的插件功能,并将其添加为点击动作到设备准备就绪p标签。

For testing I always take my plugin function and add it as a click action to the "device is ready" p tag.

例如:

<p class="event received">Device is Ready</p>

更改为:

<p class="event received" onclick="window.plugin.notification.local.add({ message: 'Great app!' });">Device is Ready</p>

我这样做是使用默认科尔多瓦示例应用程序,因为我知道,设备已准备就绪'将不会显示,直到后deviceReady事件触发。这是你在​​你的项目中的任何实际工作之前进行测试,如果插件是工作的好办法。

I do this with the default cordova example app since I know that 'Device is ready' will not display until after the deviceReady event has fired. This is a good way to test if plugins are working before you do any real work on your project.

这篇关于本地通知在PhoneGap的3.3.0的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆