2016-03-31 5 views
0

Ich habe eine bestehende Telerik AppBuilder-Anwendung, die zuvor funktionierende Benachrichtigungen hatte, bevor eine Generalüberholung der App durchgeführt wurde. Die App verwendet Cordova 3.7.0 und versucht, das localnotifications-Plugin zu implementieren, dessen Quellcode hier zu finden ist: https://github.com/katzer/cordova-plugin-local-notifications. Ich habe es unter Verwendung der in Teleriks "Verified Plugins" -Dokumentation angegebenen Anweisungen installiert. Es funktioniert jedoch nicht mehr. Alarme (windows.plugins) und Warnungen (cordova.plugins) sind durch verschiedene Warnungen immer undefiniert, ebenso wie alert (windows.plugins.notifications) und alle Permutationen davon. Ich sah Antworten auf andere Antworten, die besagen, dass window.plugins immer undefiniert und veraltet sei, aber window.plugins. [PLUGIN_NAME] würde existieren. Dies scheint jedoch nicht der Fall zu sein, und stattdessen bricht das Javascript. Im Folgenden wird der CodestromCordova/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); 

.... 

} 

Die zuvor funktionierenden Code war

 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) verwendet wird, ist eine Abkürzung für die Funktion navigator.notificaiton.alert (message, false, "COMPANY_NAME") und funktioniert gut.

Warum

Antwort