2016-03-31 65 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」 )並且工作正常。

爲什麼

回答