当前位置: 首页>>代码示例>>TypeScript>>正文


TypeScript local-notifications.CoreLocalNotificationsProvider类代码示例

本文整理汇总了TypeScript中@providers/local-notifications.CoreLocalNotificationsProvider的典型用法代码示例。如果您正苦于以下问题:TypeScript CoreLocalNotificationsProvider类的具体用法?TypeScript CoreLocalNotificationsProvider怎么用?TypeScript CoreLocalNotificationsProvider使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


在下文中一共展示了CoreLocalNotificationsProvider类的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的TypeScript代码示例。

示例1: constructor

    constructor(platform: Platform, device: Device, appProvider: CoreAppProvider, fileProvider: CoreFileProvider,
            initDelegate: CoreInitDelegate, langProvider: CoreLangProvider, sitesProvider: CoreSitesProvider,
            localNotificationsProvider: CoreLocalNotificationsProvider, pushNotificationsProvider: AddonPushNotificationsProvider) {

        const currentSite = sitesProvider.getCurrentSite();

        this.appName = appProvider.isDesktop() ? CoreConfigConstants.desktopappname : CoreConfigConstants.appname;
        this.versionName = CoreConfigConstants.versionname;
        this.versionCode = CoreConfigConstants.versioncode;
        this.compilationTime = CoreConfigConstants.compilationtime;
        this.lastCommit = CoreConfigConstants.lastcommit;

        // Calculate the privacy policy to use.
        this.privacyPolicy = (currentSite && (currentSite.getStoredConfig('tool_mobile_apppolicy') ||
                currentSite.getStoredConfig('sitepolicy'))) || CoreConfigConstants.privacypolicy;

        this.navigator = window.navigator;
        if (window.location && window.location.href) {
            const url = window.location.href;
            this.locationHref = url.substr(0, url.indexOf('#'));
        }

        this.appReady = initDelegate.isReady() ? 'core.yes' : 'core.no';
        this.deviceType = platform.is('tablet') ? 'core.tablet' : 'core.phone';

        if (platform.is('android')) {
            this.deviceOs = 'core.android';
        } else if (platform.is('ios')) {
            this.deviceOs = 'core.ios';
        } else if (platform.is('windows')) {
            this.deviceOs = 'core.windowsphone';
        } else {
            const matches = navigator.userAgent.match(/\(([^\)]*)\)/);
            if (matches && matches.length > 1) {
                this.deviceOs = matches[1];
            } else {
                this.deviceOs = 'core.unknown';
            }
        }

        langProvider.getCurrentLanguage().then((lang) => {
            this.currentLanguage = lang;
        });

        this.networkStatus = appProvider.isOnline() ? 'core.online' : 'core.offline';
        this.wifiConnection = appProvider.isWifi() ? 'core.yes' : 'core.no';
        this.deviceWebWorkers = !!window['Worker'] && !!window['URL'] ? 'core.yes' : 'core.no';
        this.device = device;

        if (fileProvider.isAvailable()) {
            fileProvider.getBasePath().then((basepath) => {
                this.fileSystemRoot = basepath;
                this.fsClickable = fileProvider.usesHTMLAPI();
            });
        }

        this.localNotifAvailable = localNotificationsProvider.isAvailable() ? 'core.yes' : 'core.no';
        this.pushId = pushNotificationsProvider.getPushId();
    }
开发者ID:santosleonardo,项目名称:moodlemobile2,代码行数:59,代码来源:about.ts

示例2: constructor

    constructor(platform: Platform, pushNotificationsProvider: AddonPushNotificationsProvider, eventsProvider: CoreEventsProvider,
            localNotificationsProvider: CoreLocalNotificationsProvider, loggerProvider: CoreLoggerProvider,
            updateManager: CoreUpdateManagerProvider, cronDelegate: CoreCronDelegate,
            registerCronHandler: AddonPushNotificationsRegisterCronHandler,
            unregisterCronHandler: AddonPushNotificationsUnregisterCronHandler) {

        const logger = loggerProvider.getInstance('AddonPushNotificationsModule');

        // Register the handlers.
        cronDelegate.register(registerCronHandler);
        cronDelegate.register(unregisterCronHandler);

        // Register device on GCM or APNS server.
        platform.ready().then(() => {
            pushNotificationsProvider.registerDevice();
        });

        eventsProvider.on(CoreEventsProvider.NOTIFICATION_SOUND_CHANGED, () => {
            // Notification sound has changed, register the device again to update the sound setting.
            pushNotificationsProvider.registerDevice();
        });

        // Register device on Moodle site when login.
        eventsProvider.on(CoreEventsProvider.LOGIN, () => {
            pushNotificationsProvider.registerDeviceOnMoodle().catch((error) => {
                logger.warn('Can\'t register device', error);
            });
        });

        eventsProvider.on(CoreEventsProvider.SITE_DELETED, (site) => {
            pushNotificationsProvider.unregisterDeviceOnMoodle(site).catch((error) => {
                logger.warn('Can\'t unregister device', error);
            });
            pushNotificationsProvider.cleanSiteCounters(site.id);
        });

        // Listen for local notification clicks (generated by the app).
        localNotificationsProvider.registerClick(AddonPushNotificationsProvider.COMPONENT,
            pushNotificationsProvider.notificationClicked.bind(pushNotificationsProvider));

        // Allow migrating the table from the old app to the new schema.
        updateManager.registerAppTableMigration({
            name: 'mma_pushnotifications_badge',
            newName: AddonPushNotificationsProvider.BADGE_TABLE,
            fields: [
                {
                    name: 'siteid',
                    newName: 'siteId'
                }
            ]
        });

        // Migrate the component name.
        updateManager.registerLocalNotifComponentMigration('mmaPushNotifications', AddonPushNotificationsProvider.COMPONENT);
    }
开发者ID:santosleonardo,项目名称:moodlemobile2,代码行数:55,代码来源:pushnotifications.module.ts

示例3: constructor

    constructor(mainMenuDelegate: CoreMainMenuDelegate, mainMenuHandler: AddonNotificationsMainMenuHandler,
            settingsDelegate: CoreSettingsDelegate, settingsHandler: AddonNotificationsSettingsHandler,
            cronDelegate: CoreCronDelegate, cronHandler: AddonNotificationsCronHandler, zone: NgZone,
            appProvider: CoreAppProvider, utils: CoreUtilsProvider, sitesProvider: CoreSitesProvider,
            notificationsProvider: AddonNotificationsProvider, localNotifications: CoreLocalNotificationsProvider,
            linkHelper: CoreContentLinksHelperProvider, pushNotificationsDelegate: AddonPushNotificationsDelegate) {
        mainMenuDelegate.registerHandler(mainMenuHandler);
        settingsDelegate.registerHandler(settingsHandler);
        cronDelegate.register(cronHandler);

        const notificationClicked = (notification: any): void => {
            sitesProvider.isFeatureDisabled('CoreMainMenuDelegate_AddonNotifications', notification.site).then((disabled) => {
                if (disabled) {
                    // Notifications are disabled, stop.
                    return;
                }

                notificationsProvider.invalidateNotificationsList().finally(() => {
                    linkHelper.goInSite(undefined, 'AddonNotificationsListPage', undefined, notification.site);
                });
            });
        };

        if (appProvider.isDesktop()) {
            // Listen for clicks in simulated push notifications.
            localNotifications.registerClick(AddonNotificationsProvider.PUSH_SIMULATION_COMPONENT, notificationClicked);
        }

        // Register push notification clicks.
        pushNotificationsDelegate.on('click').subscribe((notification) => {
            if (utils.isTrueOrOne(notification.notif)) {
                // Execute the callback in the Angular zone, so change detection doesn't stop working.
                zone.run(() => {
                    notificationClicked(notification);
                });

                return true;
            }
        });
    }
开发者ID:SATS-Seminary,项目名称:moodlemobile2,代码行数:40,代码来源:notifications.module.ts

示例4: constructor

    constructor(mainMenuDelegate: CoreMainMenuDelegate, calendarHandler: AddonCalendarMainMenuHandler,
            initDelegate: CoreInitDelegate, calendarProvider: AddonCalendarProvider, loginHelper: CoreLoginHelperProvider,
            localNotificationsProvider: CoreLocalNotificationsProvider, updateManager: CoreUpdateManagerProvider) {
        mainMenuDelegate.registerHandler(calendarHandler);

        initDelegate.ready().then(() => {
            calendarProvider.scheduleAllSitesEventsNotifications();
        });

        localNotificationsProvider.registerClick(AddonCalendarProvider.COMPONENT, (data) => {
            if (data.eventid) {
                initDelegate.ready().then(() => {
                    calendarProvider.isDisabled(data.siteId).then((disabled) => {
                        if (disabled) {
                            // The calendar is disabled in the site, don't open it.
                            return;
                        }

                        loginHelper.redirect('AddonCalendarListPage', {eventId: data.eventid}, data.siteId);
                    });
                });
            }
        });

        // Allow migrating the table from the old app to the new schema.
        // In the old app some calculated properties were stored when it shouldn't. Filter only the fields we want.
        updateManager.registerSiteTableMigration({
            name: 'calendar_events',
            newName: AddonCalendarProvider.EVENTS_TABLE,
            filterFields: ['id', 'name', 'description', 'format', 'eventtype', 'courseid', 'timestart', 'timeduration',
                    'categoryid', 'groupid', 'userid', 'instance', 'modulename', 'timemodified', 'repeatid', 'visible', 'uuid',
                    'sequence', 'subscriptionid']
        });

        // Migrate the component name.
        updateManager.registerLocalNotifComponentMigration('mmaCalendarComponent', AddonCalendarProvider.COMPONENT);
    }
开发者ID:santosleonardo,项目名称:moodlemobile2,代码行数:37,代码来源:calendar.module.ts

示例5: constructor

    constructor(mainMenuDelegate: CoreMainMenuDelegate, mainMenuHandler: AddonNotificationsMainMenuHandler,
            settingsDelegate: CoreSettingsDelegate, settingsHandler: AddonNotificationsSettingsHandler,
            cronDelegate: CoreCronDelegate, cronHandler: AddonNotificationsCronHandler, zone: NgZone,
            appProvider: CoreAppProvider, utils: CoreUtilsProvider, sitesProvider: CoreSitesProvider,
            notificationsProvider: AddonNotificationsProvider, localNotifications: CoreLocalNotificationsProvider,
            linkHelper: CoreContentLinksHelperProvider, pushNotificationsDelegate: AddonPushNotificationsDelegate,
            urlUtils: CoreUrlUtilsProvider, forumProvider: AddonModForumProvider) {

        mainMenuDelegate.registerHandler(mainMenuHandler);
        settingsDelegate.registerHandler(settingsHandler);
        cronDelegate.register(cronHandler);

        const notificationClicked = (notification: any): void => {

            // Temporary fix to make forum notifications work. This will be improved in next release.
            if (notification.moodlecomponent == 'mod_forum' && notification.name == 'posts') {
                sitesProvider.isFeatureDisabled('CoreCourseModuleDelegate_AddonModForum', notification.site).then((disabled) => {
                    if (disabled) {
                        // Forum is disabled, stop.
                        return;
                    }

                    const contextUrlParams = urlUtils.extractUrlParams(notification.contexturl),
                        pageParams: any = {
                            courseId: Number(notification.courseid),
                            discussionId: Number(contextUrlParams.d),
                        };

                    if (contextUrlParams.urlHash) {
                        pageParams.postId = Number(contextUrlParams.urlHash.replace('p', ''));
                    }

                    forumProvider.invalidateDiscussionPosts(pageParams.discussionId).catch(() => {
                        // Ignore errors.
                    }).then(() => {
                        linkHelper.goInSite(undefined, 'AddonModForumDiscussionPage', pageParams, notification.site);
                    });
                });
            } else {
                goToNotifications(notification);
            }
        };
        const goToNotifications = (notification: any): void => {
            sitesProvider.isFeatureDisabled('CoreMainMenuDelegate_AddonNotifications', notification.site).then((disabled) => {
                if (disabled) {
                    // Notifications are disabled, stop.
                    return;
                }

                notificationsProvider.invalidateNotificationsList().finally(() => {
                    linkHelper.goInSite(undefined, 'AddonNotificationsListPage', undefined, notification.site);
                });
            });
        };

        if (appProvider.isDesktop()) {
            // Listen for clicks in simulated push notifications.
            localNotifications.registerClick(AddonNotificationsProvider.PUSH_SIMULATION_COMPONENT, notificationClicked);
        }

        // Register push notification clicks.
        pushNotificationsDelegate.on('click').subscribe((notification) => {
            if (utils.isTrueOrOne(notification.notif)) {
                // Execute the callback in the Angular zone, so change detection doesn't stop working.
                zone.run(() => {
                    notificationClicked(notification);
                });

                return true;
            }
        });
    }
开发者ID:santosleonardo,项目名称:moodlemobile2,代码行数:72,代码来源:notifications.module.ts

示例6: constructor

    constructor(mainMenuDelegate: CoreMainMenuDelegate, mainmenuHandler: AddonMessagesMainMenuHandler,
            contentLinksDelegate: CoreContentLinksDelegate, indexLinkHandler: AddonMessagesIndexLinkHandler,
            discussionLinkHandler: AddonMessagesDiscussionLinkHandler, sendMessageHandler: AddonMessagesSendMessageUserHandler,
            userDelegate: CoreUserDelegate, cronDelegate: CoreCronDelegate, syncHandler: AddonMessagesSyncCronHandler,
            network: Network, zone: NgZone, messagesSync: AddonMessagesSyncProvider, appProvider: CoreAppProvider,
            localNotifications: CoreLocalNotificationsProvider, messagesProvider: AddonMessagesProvider,
            sitesProvider: CoreSitesProvider, linkHelper: CoreContentLinksHelperProvider, updateManager: CoreUpdateManagerProvider,
            settingsHandler: AddonMessagesSettingsHandler, settingsDelegate: CoreSettingsDelegate,
            pushNotificationsDelegate: AddonPushNotificationsDelegate, utils: CoreUtilsProvider,
            addContactHandler: AddonMessagesAddContactUserHandler, blockContactHandler: AddonMessagesBlockContactUserHandler) {
        // Register handlers.
        mainMenuDelegate.registerHandler(mainmenuHandler);
        contentLinksDelegate.registerHandler(indexLinkHandler);
        contentLinksDelegate.registerHandler(discussionLinkHandler);
        userDelegate.registerHandler(sendMessageHandler);
        userDelegate.registerHandler(addContactHandler);
        userDelegate.registerHandler(blockContactHandler);
        cronDelegate.register(syncHandler);
        cronDelegate.register(mainmenuHandler);
        settingsDelegate.registerHandler(settingsHandler);

        // Sync some discussions when device goes online.
        network.onConnect().subscribe(() => {
            // Execute the callback in the Angular zone, so change detection doesn't stop working.
            zone.run(() => {
                messagesSync.syncAllDiscussions(undefined, true);
            });
        });

        const notificationClicked = (notification: any): void => {
            messagesProvider.isMessagingEnabledForSite(notification.site).then(() => {
                sitesProvider.isFeatureDisabled('CoreMainMenuDelegate_AddonMessages', notification.site).then((disabled) => {
                    if (disabled) {
                        // Messages are disabled, stop.
                        return;
                    }

                    messagesProvider.invalidateDiscussionsCache(notification.site).finally(() => {
                        linkHelper.goInSite(undefined, 'AddonMessagesIndexPage', undefined, notification.site);
                    });
                });
            });
        };

        if (appProvider.isDesktop()) {
            // Listen for clicks in simulated push notifications.
            localNotifications.registerClick(AddonMessagesProvider.PUSH_SIMULATION_COMPONENT, notificationClicked);
        }

        // Register push notification clicks.
        pushNotificationsDelegate.on('click').subscribe((notification) => {
            if (utils.isFalseOrZero(notification.notif)) {
                notificationClicked(notification);

                return true;
            }
        });

        // Allow migrating the table from the old app to the new schema.
        updateManager.registerSiteTableMigration({
            name: 'mma_messages_offline_messages',
            newName: AddonMessagesOfflineProvider.MESSAGES_TABLE,
            fields: [
                {
                    name: 'textformat',
                    delete: true
                }
            ]
        });

        // Migrate the component name.
        updateManager.registerLocalNotifComponentMigration('mmaMessagesPushSimulation',
                AddonMessagesProvider.PUSH_SIMULATION_COMPONENT);
    }
开发者ID:jleyva,项目名称:moodlemobile2,代码行数:74,代码来源:messages.module.ts


注:本文中的@providers/local-notifications.CoreLocalNotificationsProvider类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。