2016-03-31 63 views
0

我有一个现有的Telerik AppBuilder应用程序,该应用程序在应用程序完成大修之前曾有工作通知。该应用程序使用科尔多瓦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。以下正在使用的当前代码Cordova/Window.plugins undefined

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(消息)是用于navigator.notificaiton.alert快捷功能(消息,假 “COMPANY_NAME” )并且工作正常。

为什么

回答