0

アプリで大規模なオーバーホールが行われる前に、以前は機能していた通知があった既存の Telerik AppBuilder アプリケーションがあります。このアプリは Cordova 3.7.0 を使用し、localnotifications プラグインの実装を試みています。そのソース コードはhttps://github.com/katzer/cordova-plugin-local-notificationsにあります。. Telerik の「検証済みプラグイン」ドキュメントに記載されている手順を使用してインストールしました。ただし、機能しなくなりました。さまざまなアラートを通じて、alert(windows.plugins) と alert(cordova.plugins) は、alert(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") のショートカット関数であり、正常に動作します。

どうして

4

1 に答える 1

0

このプラグインはcordova.plugins...またはwindow.plugin...を使用していますが、それを試すことができますか? これを担当するコード行を参照してください

于 2016-04-01T15:32:25.490 に答える