I have an existing Telerik AppBuilder application that previously had working notifications before a major overhaul was done on the app. The app uses Cordova 3.7.0 and is attempting to implement the localnotifications plugin, whose source code can be found here : https://github.com/katzer/cordova-plugin-local-notifications . I installed it using the instructions specified in Telerik's "Verified Plugins" Documentation. However, it no longer functions. Through various alerts, alert(windows.plugins) and alert(cordova.plugins) is always undefined, as is alert(windows.plugins.notifications) and all permutations thereof. I saw responses to other replies saying that window.plugins would always be undefined and deprecated, but window.plugins.[PLUGIN_NAME] would exist. However, this does not seem to be the case. Below is the code current being used
define(['jQuery', 'base64'], function ($, base64) {
....
var that = this;
that.alert("starting");
document.addEventListener("deviceready", function() {
that.alert(JSON.stringify(window.plugins));
}, false);
....
}
The previously functioning code was
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) is a shortcut function for navigator.notificaiton.alert(message, false, "COMPANY_NAME") and works fine.
Why