我有一个现有的Telerik AppBuilder应用程序,该应用程序之前在应用程序上进行了大修之前有工作通知。该应用程序使用Cordova 3.7.0并尝试实现localnotifications插件,其源代码可在此处找到:https://github.com/katzer/cordova-plugin-local-notifications。我使用Telerik"已验证的插件"中指定的说明安装它。文档。但是,它不再起作用。通过各种警报,警报(windows.plugins)和警报(cordova.plugins)始终未定义,警报(windows.plugins.notifications)及其所有排列也是如此。我看到对其他回复的回复说window.plugins总是未定义和弃用,但是window.plugins。[PLUGIN_NAME]会存在。但是,这似乎并非如此,而是打破了javascript。以下是正在使用的代码电流
define(['jQuery', 'base64'], function ($, base64) {
....
var that = this;
that.alert("starting");
document.addEventListener("deviceready", function() {
that.alert(JSON.stringify(window.plugins));
}, false);
....
}
之前正在运行的代码是
if (that.hasNotificationPlugin()) {
that.clearNotifications(function() {
console.info('Setting notifications');
// Schedule notifications for each day from the schedule
$.each(data.DeliveryDaysThisWeek, function (i, day) {
var dow = day.DayOfWeek;
// Schedule notifications for each store within a day
$.each(day.Stores, function (i, store) {
// Only schedule the notification if the user
// hasn't disabled notifications for this store
if (that.get('notification' + store.StoreId) !== 'false') {
var cutoffDate = new Date(store.CutOffDateTime);
var cutoffString = $.format.date(cutoffDate, 'h:mm a');
// Schedule it 30 minutes before the cutoff time
// or using the user defined time
var time = parseInt(that.get('notificationTime'));
if (isNaN(time)) {
that.set('notificationTime', "30");
time = 30;
}
var notifDate = new Date(cutoffDate.getTime() - time * 60 * 1000);
// Only schedule it if it's in the future
if (notifDate > new Date()) {
window.plugin.notification.local.add({
id: (dow * 100000 + store.DeliveryTimes[0].DeliveryTimeId).toString(),
date: notifDate,
message: "The cutoff time is almost up! Place your order by " + cutoffString,
title: store.Store.Restaurant.RestaurantName.trim(),
json: JSON.stringify({StoreId: store.StoreId}),
icon: 'icon'
});
that.alert(message)是navigator.notificaiton.alert的一个快捷方式功能(message,false," COMPANY_NAME")并且运行正常。
为什么
答案 0 :(得分:0)
此插件使用cordova.plugins...
或window.plugin...
,您可以试试吗? see the line of code responsible for this