Thank you Dawson! The problem mentioned below has been solved in android. But sadly it does not work when I build the project in ios, could anyone help?
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
First I created a phonegap project
phonegap create notification
Add the plugin
cordova plugin add https://github.com/katzer/cordova-plugin-local-notifications.git
Modify the /www/config.xml
<gap:plugin name="de.appplant.cordova.plugin.local-notification" />
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>
I built the android apps using the command
phonegap build android
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.
Hi guys just in case this is another example...it has custom sound and other properties such as title, badge type is interesting how this plugin doc is not finished yet, creating local notifications for android working absolutely beautiful with latest cordova (3.4.x) just create a var and assign your package name (the one you use when created the phonegap/cordova project with the command line something like this for example:
Should be used in the plugin with these values:
Download local notificator plugin (working on Android ONLY)
Download beep.mp3
stack overflow original comment
You wont be able to call that function until after the deviceReady event has fired.
For testing I always take my plugin function and add it as a click action to the "device is ready" p tag.
Example:
change to:
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.