0
你好我試着去當地的通知添加到Android的phonegapp一個項目,我有這樣的錯誤,進出口使用這個插件https://github.com/katzer/cordova-plugin-local-notifications:的PhoneGap本地通知錯誤
var LocalNotification = function() {
};
LocalNotification.prototype = {
/**
* Fügt einen neuen Eintrag zur Registry hinzu.
*
* @param {Object} options
* @return {Number} Die ID der Notification
*/
add: function (options) {
var defaults = {
date: new Date(),
message: '',
title: '',
badge: 0,
id: 0,
repeat: '',
background: '',
foreground: ''
};
switch (device.platform) {
case 'Android':
defaults.icon = 'icon';
defaults.sound = 'TYPE_NOTIFICATION'; break;
case 'iOS':
defaults.sound = ''; break;
case 'WinCE': case 'Win32NT':
defaults.smallImage = null;
defaults.image = null;
defaults.wideImage = null;
};
var callbackFn = function (cmd) {
eval(cmd);
};
for (var key in defaults) {
if (options[key] !== undefined) {
defaults[key] = options[key];
}
}
if (defaults.id) {
defaults.id = defaults.id.toString();
}
if (typeof defaults.date == 'object') {
defaults.date = Math.round(defaults.date.getTime()/1000);
}
cordova.exec(callbackFn, null, 'LocalNotification', 'add', [defaults]);
return defaults.id;
},
/**
* Entfernt die angegebene Notification.
*
* @param {String} id
*/
cancel: function (id) {
cordova.exec(null, null, 'LocalNotification', 'cancel', [id.toString()]);
},
/**
* Entfernt alle registrierten Notifications.
*/
cancelAll: function() {
cordova.exec(null, null, 'LocalNotification', 'cancelAll', []);
}
};
var plugin = new LocalNotification();
module.exports = plugin;
var now = new Date().getTime(),
_60_seconds_from_now = new Date(now + 60*1000);
LocalNotification.add({
id: 1, // is converted to a string
date: _60_seconds_from_now,
message: 'Hello world!',
title: 'Check that out!',
repeat: 'weekly', // will fire every week on this day
foreground: 'foreground',
background: 'background'
});
function foreground (id) {
console.log('I WAS RUNNING ID='+id)
}
function background (id) {
console.log('I WAS IN THE BACKGROUND ID='+id)
}
的index.html
<!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>
<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="js/index.js"></script>
<script type="text/javascript" src="local-notification.js"></script>
<script type="text/javascript">
app.initialize();
</script>
</body>
</html>
這是我的錯誤:
控制檯(5501):未捕獲的ReferenceError:模塊沒有在file:///android_asset/www/local-notification.js中定義:87