MOBILE-2921 push: Move pushnotifications to core
parent
3c1163b2e6
commit
727fe58a52
|
@ -15,7 +15,7 @@
|
|||
import { Component, OnDestroy } from '@angular/core';
|
||||
import { IonicPage } from 'ionic-angular';
|
||||
import { CoreDomUtilsProvider } from '@providers/utils/dom';
|
||||
import { AddonPushNotificationsProvider } from '@addon/pushnotifications/providers/pushnotifications';
|
||||
import { CorePushNotificationsProvider } from '@core/pushnotifications/providers/pushnotifications';
|
||||
import { AddonMessageOutputAirnotifierProvider } from '../../providers/airnotifier';
|
||||
|
||||
/**
|
||||
|
@ -34,7 +34,7 @@ export class AddonMessageOutputAirnotifierDevicesPage implements OnDestroy {
|
|||
protected updateTimeout: any;
|
||||
|
||||
constructor(private domUtils: CoreDomUtilsProvider, private airnotifierProivder: AddonMessageOutputAirnotifierProvider,
|
||||
private pushNotificationsProvider: AddonPushNotificationsProvider ) {
|
||||
private pushNotificationsProvider: CorePushNotificationsProvider ) {
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -21,7 +21,7 @@ import { AddonMessagesProvider } from '../../providers/messages';
|
|||
import { CoreDomUtilsProvider } from '@providers/utils/dom';
|
||||
import { CoreUtilsProvider } from '@providers/utils/utils';
|
||||
import { CoreAppProvider } from '@providers/app';
|
||||
import { AddonPushNotificationsDelegate } from '@addon/pushnotifications/providers/delegate';
|
||||
import { CorePushNotificationsDelegate } from '@core/pushnotifications/providers/delegate';
|
||||
|
||||
/**
|
||||
* Component that displays the list of discussions.
|
||||
|
@ -54,7 +54,7 @@ export class AddonMessagesDiscussionsComponent implements OnDestroy {
|
|||
constructor(private eventsProvider: CoreEventsProvider, sitesProvider: CoreSitesProvider, translate: TranslateService,
|
||||
private messagesProvider: AddonMessagesProvider, private domUtils: CoreDomUtilsProvider, navParams: NavParams,
|
||||
private appProvider: CoreAppProvider, platform: Platform, private utils: CoreUtilsProvider,
|
||||
pushNotificationsDelegate: AddonPushNotificationsDelegate) {
|
||||
pushNotificationsDelegate: CorePushNotificationsDelegate) {
|
||||
|
||||
this.search.loading = translate.instant('core.searching');
|
||||
this.loadingMessages = translate.instant('core.loading');
|
||||
|
|
|
@ -35,7 +35,7 @@ import { CoreLocalNotificationsProvider } from '@providers/local-notifications';
|
|||
import { CoreContentLinksHelperProvider } from '@core/contentlinks/providers/helper';
|
||||
import { CoreSettingsDelegate } from '@core/settings/providers/delegate';
|
||||
import { AddonMessagesSettingsHandler } from './providers/settings-handler';
|
||||
import { AddonPushNotificationsDelegate } from '@addon/pushnotifications/providers/delegate';
|
||||
import { CorePushNotificationsDelegate } from '@core/pushnotifications/providers/delegate';
|
||||
import { CoreUtilsProvider } from '@providers/utils/utils';
|
||||
import { CoreUpdateManagerProvider } from '@providers/update-manager';
|
||||
|
||||
|
@ -75,7 +75,7 @@ export class AddonMessagesModule {
|
|||
localNotifications: CoreLocalNotificationsProvider, messagesProvider: AddonMessagesProvider,
|
||||
sitesProvider: CoreSitesProvider, linkHelper: CoreContentLinksHelperProvider, updateManager: CoreUpdateManagerProvider,
|
||||
settingsHandler: AddonMessagesSettingsHandler, settingsDelegate: CoreSettingsDelegate,
|
||||
pushNotificationsDelegate: AddonPushNotificationsDelegate, utils: CoreUtilsProvider,
|
||||
pushNotificationsDelegate: CorePushNotificationsDelegate, utils: CoreUtilsProvider,
|
||||
addContactHandler: AddonMessagesAddContactUserHandler, blockContactHandler: AddonMessagesBlockContactUserHandler,
|
||||
contactRequestLinkHandler: AddonMessagesContactRequestLinkHandler) {
|
||||
// Register handlers.
|
||||
|
|
|
@ -21,7 +21,7 @@ import { AddonMessagesProvider } from '../../providers/messages';
|
|||
import { AddonMessagesOfflineProvider } from '../../providers/messages-offline';
|
||||
import { CoreDomUtilsProvider } from '@providers/utils/dom';
|
||||
import { CoreUtilsProvider } from '@providers/utils/utils';
|
||||
import { AddonPushNotificationsDelegate } from '@addon/pushnotifications/providers/delegate';
|
||||
import { CorePushNotificationsDelegate } from '@core/pushnotifications/providers/delegate';
|
||||
import { CoreSplitViewComponent } from '@components/split-view/split-view';
|
||||
import { CoreUserProvider } from '@core/user/providers/user';
|
||||
|
||||
|
@ -84,7 +84,7 @@ export class AddonMessagesGroupConversationsPage implements OnInit, OnDestroy {
|
|||
constructor(eventsProvider: CoreEventsProvider, sitesProvider: CoreSitesProvider, translate: TranslateService,
|
||||
private messagesProvider: AddonMessagesProvider, private domUtils: CoreDomUtilsProvider, navParams: NavParams,
|
||||
private navCtrl: NavController, platform: Platform, private utils: CoreUtilsProvider,
|
||||
pushNotificationsDelegate: AddonPushNotificationsDelegate, private messagesOffline: AddonMessagesOfflineProvider,
|
||||
pushNotificationsDelegate: CorePushNotificationsDelegate, private messagesOffline: AddonMessagesOfflineProvider,
|
||||
private userProvider: CoreUserProvider) {
|
||||
|
||||
this.loadingString = translate.instant('core.loading');
|
||||
|
|
|
@ -22,8 +22,8 @@ import { CoreAppProvider } from '@providers/app';
|
|||
import { CoreTextUtilsProvider } from '@providers/utils/text';
|
||||
import { CoreUtilsProvider } from '@providers/utils/utils';
|
||||
import { CoreLocalNotificationsProvider } from '@providers/local-notifications';
|
||||
import { AddonPushNotificationsProvider } from '@addon/pushnotifications/providers/pushnotifications';
|
||||
import { AddonPushNotificationsDelegate } from '@addon/pushnotifications/providers/delegate';
|
||||
import { CorePushNotificationsProvider } from '@core/pushnotifications/providers/pushnotifications';
|
||||
import { CorePushNotificationsDelegate } from '@core/pushnotifications/providers/delegate';
|
||||
import { CoreEmulatorHelperProvider } from '@core/emulator/providers/helper';
|
||||
|
||||
/**
|
||||
|
@ -50,8 +50,8 @@ export class AddonMessagesMainMenuHandler implements CoreMainMenuHandler, CoreCr
|
|||
constructor(private messagesProvider: AddonMessagesProvider, private sitesProvider: CoreSitesProvider,
|
||||
eventsProvider: CoreEventsProvider, private appProvider: CoreAppProvider,
|
||||
private localNotificationsProvider: CoreLocalNotificationsProvider, private textUtils: CoreTextUtilsProvider,
|
||||
private pushNotificationsProvider: AddonPushNotificationsProvider, utils: CoreUtilsProvider,
|
||||
pushNotificationsDelegate: AddonPushNotificationsDelegate, private emulatorHelper: CoreEmulatorHelperProvider) {
|
||||
private pushNotificationsProvider: CorePushNotificationsProvider, utils: CoreUtilsProvider,
|
||||
pushNotificationsDelegate: CorePushNotificationsDelegate, private emulatorHelper: CoreEmulatorHelperProvider) {
|
||||
|
||||
eventsProvider.on(AddonMessagesProvider.UNREAD_CONVERSATION_COUNTS_EVENT, (data) => {
|
||||
this.unreadCount = data.favourites + data.individual + data.group;
|
||||
|
|
|
@ -26,7 +26,7 @@ import { CoreLocalNotificationsProvider } from '@providers/local-notifications';
|
|||
import { CoreSitesProvider } from '@providers/sites';
|
||||
import { CoreUrlUtilsProvider } from '@providers/utils/url';
|
||||
import { CoreUtilsProvider } from '@providers/utils/utils';
|
||||
import { AddonPushNotificationsDelegate } from '@addon/pushnotifications/providers/delegate';
|
||||
import { CorePushNotificationsDelegate } from '@core/pushnotifications/providers/delegate';
|
||||
import { AddonModForumProvider } from '@addon/mod/forum/providers/forum';
|
||||
|
||||
// List of providers (without handlers).
|
||||
|
@ -52,7 +52,7 @@ export class AddonNotificationsModule {
|
|||
cronDelegate: CoreCronDelegate, cronHandler: AddonNotificationsCronHandler, zone: NgZone,
|
||||
appProvider: CoreAppProvider, utils: CoreUtilsProvider, sitesProvider: CoreSitesProvider,
|
||||
notificationsProvider: AddonNotificationsProvider, localNotifications: CoreLocalNotificationsProvider,
|
||||
linkHelper: CoreContentLinksHelperProvider, pushNotificationsDelegate: AddonPushNotificationsDelegate,
|
||||
linkHelper: CoreContentLinksHelperProvider, pushNotificationsDelegate: CorePushNotificationsDelegate,
|
||||
urlUtils: CoreUrlUtilsProvider, forumProvider: AddonModForumProvider) {
|
||||
|
||||
mainMenuDelegate.registerHandler(mainMenuHandler);
|
||||
|
|
|
@ -21,7 +21,7 @@ import { CoreEventsProvider, CoreEventObserver } from '@providers/events';
|
|||
import { CoreSitesProvider } from '@providers/sites';
|
||||
import { CoreUtilsProvider } from '@providers/utils/utils';
|
||||
import { AddonNotificationsProvider } from '../../providers/notifications';
|
||||
import { AddonPushNotificationsDelegate } from '@addon/pushnotifications/providers/delegate';
|
||||
import { CorePushNotificationsDelegate } from '@core/pushnotifications/providers/delegate';
|
||||
|
||||
/**
|
||||
* Page that displays the list of notifications.
|
||||
|
@ -48,7 +48,7 @@ export class AddonNotificationsListPage {
|
|||
constructor(navParams: NavParams, private domUtils: CoreDomUtilsProvider, private eventsProvider: CoreEventsProvider,
|
||||
private sitesProvider: CoreSitesProvider, private textUtils: CoreTextUtilsProvider,
|
||||
private utils: CoreUtilsProvider, private notificationsProvider: AddonNotificationsProvider,
|
||||
private pushNotificationsDelegate: AddonPushNotificationsDelegate) {
|
||||
private pushNotificationsDelegate: CorePushNotificationsDelegate) {
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -18,8 +18,8 @@ import { CoreSitesProvider } from '@providers/sites';
|
|||
import { CoreUtilsProvider } from '@providers/utils/utils';
|
||||
import { CoreMainMenuHandler, CoreMainMenuHandlerData } from '@core/mainmenu/providers/delegate';
|
||||
import { AddonNotificationsProvider } from './notifications';
|
||||
import { AddonPushNotificationsProvider } from '@addon/pushnotifications/providers/pushnotifications';
|
||||
import { AddonPushNotificationsDelegate } from '@addon/pushnotifications/providers/delegate';
|
||||
import { CorePushNotificationsProvider } from '@core/pushnotifications/providers/pushnotifications';
|
||||
import { CorePushNotificationsDelegate } from '@core/pushnotifications/providers/delegate';
|
||||
|
||||
/**
|
||||
* Handler to inject an option into main menu.
|
||||
|
@ -41,8 +41,8 @@ export class AddonNotificationsMainMenuHandler implements CoreMainMenuHandler {
|
|||
|
||||
constructor(eventsProvider: CoreEventsProvider, private sitesProvider: CoreSitesProvider,
|
||||
utils: CoreUtilsProvider, private notificationsProvider: AddonNotificationsProvider,
|
||||
private pushNotificationsProvider: AddonPushNotificationsProvider,
|
||||
pushNotificationsDelegate: AddonPushNotificationsDelegate) {
|
||||
private pushNotificationsProvider: CorePushNotificationsProvider,
|
||||
pushNotificationsDelegate: CorePushNotificationsDelegate) {
|
||||
|
||||
eventsProvider.on(AddonNotificationsProvider.READ_CHANGED_EVENT, (data) => {
|
||||
this.updateBadge(data.siteId);
|
||||
|
|
|
@ -121,7 +121,7 @@ import { AddonMessageOutputModule } from '@addon/messageoutput/messageoutput.mod
|
|||
import { AddonMessageOutputAirnotifierModule } from '@addon/messageoutput/airnotifier/airnotifier.module';
|
||||
import { AddonMessagesModule } from '@addon/messages/messages.module';
|
||||
import { AddonNotesModule } from '../addon/notes/notes.module';
|
||||
import { AddonPushNotificationsModule } from '@addon/pushnotifications/pushnotifications.module';
|
||||
import { CorePushNotificationsModule } from '@core/pushnotifications/pushnotifications.module';
|
||||
import { AddonNotificationsModule } from '@addon/notifications/notifications.module';
|
||||
import { AddonRemoteThemesModule } from '@addon/remotethemes/remotethemes.module';
|
||||
import { AddonQbehaviourModule } from '@addon/qbehaviour/qbehaviour.module';
|
||||
|
@ -201,6 +201,7 @@ export const CORE_PROVIDERS: any[] = [
|
|||
CoreCommentsModule,
|
||||
CoreBlockModule,
|
||||
CoreRatingModule,
|
||||
CorePushNotificationsModule,
|
||||
AddonBadgesModule,
|
||||
AddonBlogModule,
|
||||
AddonCalendarModule,
|
||||
|
@ -241,7 +242,6 @@ export const CORE_PROVIDERS: any[] = [
|
|||
AddonMessagesModule,
|
||||
AddonNotesModule,
|
||||
AddonNotificationsModule,
|
||||
AddonPushNotificationsModule,
|
||||
AddonRemoteThemesModule,
|
||||
AddonQbehaviourModule,
|
||||
AddonQtypeModule
|
||||
|
|
|
@ -35,6 +35,7 @@ import { CORE_QUESTION_PROVIDERS } from '@core/question/question.module';
|
|||
import { CORE_SHAREDFILES_PROVIDERS } from '@core/sharedfiles/sharedfiles.module';
|
||||
import { CORE_SITEHOME_PROVIDERS } from '@core/sitehome/sitehome.module';
|
||||
import { CORE_USER_PROVIDERS } from '@core/user/user.module';
|
||||
import { CORE_PUSHNOTIFICATIONS_PROVIDERS } from '@core/pushnotifications/pushnotifications.module';
|
||||
import { IONIC_NATIVE_PROVIDERS } from '@core/emulator/emulator.module';
|
||||
|
||||
// Import only this provider to prevent circular dependencies.
|
||||
|
@ -114,7 +115,6 @@ import { ADDON_MOD_WIKI_PROVIDERS } from '@addon/mod/wiki/wiki.module';
|
|||
import { ADDON_MOD_WORKSHOP_PROVIDERS } from '@addon/mod/workshop/workshop.module';
|
||||
import { ADDON_NOTES_PROVIDERS } from '@addon/notes/notes.module';
|
||||
import { ADDON_NOTIFICATIONS_PROVIDERS } from '@addon/notifications/notifications.module';
|
||||
import { ADDON_PUSHNOTIFICATIONS_PROVIDERS } from '@addon/pushnotifications/pushnotifications.module';
|
||||
import { ADDON_REMOTETHEMES_PROVIDERS } from '@addon/remotethemes/remotethemes.module';
|
||||
|
||||
// Import some addon modules that define components, directives and pipes. Only import the important ones.
|
||||
|
@ -233,7 +233,7 @@ export class CoreCompileProvider {
|
|||
.concat(ADDON_MOD_QUIZ_PROVIDERS).concat(ADDON_MOD_RESOURCE_PROVIDERS).concat(ADDON_MOD_SCORM_PROVIDERS)
|
||||
.concat(ADDON_MOD_SURVEY_PROVIDERS).concat(ADDON_MOD_URL_PROVIDERS).concat(ADDON_MOD_WIKI_PROVIDERS)
|
||||
.concat(ADDON_MOD_WORKSHOP_PROVIDERS).concat(ADDON_NOTES_PROVIDERS).concat(ADDON_NOTIFICATIONS_PROVIDERS)
|
||||
.concat(ADDON_PUSHNOTIFICATIONS_PROVIDERS).concat(ADDON_REMOTETHEMES_PROVIDERS).concat(CORE_BLOCK_PROVIDERS);
|
||||
.concat(CORE_PUSHNOTIFICATIONS_PROVIDERS).concat(ADDON_REMOTETHEMES_PROVIDERS).concat(CORE_BLOCK_PROVIDERS);
|
||||
|
||||
// We cannot inject anything to this constructor. Use the Injector to inject all the providers into the instance.
|
||||
for (const i in providers) {
|
||||
|
|
|
@ -19,7 +19,7 @@ import { CoreLoggerProvider } from '@providers/logger';
|
|||
import { CoreSitesProvider, CoreSiteBasicInfo } from '@providers/sites';
|
||||
import { CoreDomUtilsProvider } from '@providers/utils/dom';
|
||||
import { CoreTextUtilsProvider } from '@providers/utils/text';
|
||||
import { AddonPushNotificationsProvider } from '@addon/pushnotifications/providers/pushnotifications';
|
||||
import { CorePushNotificationsProvider } from '@core/pushnotifications/providers/pushnotifications';
|
||||
import { CoreLoginHelperProvider } from '../../providers/helper';
|
||||
|
||||
/**
|
||||
|
@ -37,7 +37,7 @@ export class CoreLoginSitesPage {
|
|||
|
||||
constructor(private domUtils: CoreDomUtilsProvider, private textUtils: CoreTextUtilsProvider,
|
||||
private sitesProvider: CoreSitesProvider, private loginHelper: CoreLoginHelperProvider, logger: CoreLoggerProvider,
|
||||
private translate: TranslateService, private pushNotificationsProvider: AddonPushNotificationsProvider) {
|
||||
private translate: TranslateService, private pushNotificationsProvider: CorePushNotificationsProvider) {
|
||||
this.logger = logger.getInstance('CoreLoginSitesPage');
|
||||
}
|
||||
|
||||
|
|
|
@ -20,14 +20,14 @@ import { Subject } from 'rxjs';
|
|||
* Service to handle push notifications actions to perform when clicked and received.
|
||||
*/
|
||||
@Injectable()
|
||||
export class AddonPushNotificationsDelegate {
|
||||
export class CorePushNotificationsDelegate {
|
||||
|
||||
protected logger;
|
||||
protected observables: { [s: string]: Subject<any> } = {};
|
||||
protected counterHandlers: { [s: string]: string } = {};
|
||||
|
||||
constructor(loggerProvider: CoreLoggerProvider) {
|
||||
this.logger = loggerProvider.getInstance('AddonPushNotificationsDelegate');
|
||||
this.logger = loggerProvider.getInstance('CorePushNotificationsDelegate');
|
||||
this.observables['click'] = new Subject<any>();
|
||||
this.observables['receive'] = new Subject<any>();
|
||||
}
|
|
@ -23,7 +23,7 @@ import { CoreInitDelegate } from '@providers/init';
|
|||
import { CoreLoggerProvider } from '@providers/logger';
|
||||
import { CoreSitesProvider, CoreSiteSchema } from '@providers/sites';
|
||||
import { CoreSitesFactoryProvider } from '@providers/sites-factory';
|
||||
import { AddonPushNotificationsDelegate } from './delegate';
|
||||
import { CorePushNotificationsDelegate } from './delegate';
|
||||
import { CoreLocalNotificationsProvider } from '@providers/local-notifications';
|
||||
import { CoreUtilsProvider } from '@providers/utils/utils';
|
||||
import { CoreTextUtilsProvider } from '@providers/utils/text';
|
||||
|
@ -37,7 +37,7 @@ import { CoreSite } from '@classes/site';
|
|||
/**
|
||||
* Data needed to register a device in a Moodle site.
|
||||
*/
|
||||
export interface AddonPushNotificationsRegisterData {
|
||||
export interface CorePushNotificationsRegisterData {
|
||||
/**
|
||||
* App ID.
|
||||
* @type {string}
|
||||
|
@ -85,19 +85,19 @@ export interface AddonPushNotificationsRegisterData {
|
|||
* Service to handle push notifications.
|
||||
*/
|
||||
@Injectable()
|
||||
export class AddonPushNotificationsProvider {
|
||||
export class CorePushNotificationsProvider {
|
||||
protected logger;
|
||||
protected pushID: string;
|
||||
protected appDB: SQLiteDB;
|
||||
static COMPONENT = 'AddonPushNotificationsProvider';
|
||||
static COMPONENT = 'CorePushNotificationsProvider';
|
||||
|
||||
// Variables for database.
|
||||
// Variables for database. The name still contains the name "addon" for backwards compatibility.
|
||||
static BADGE_TABLE = 'addon_pushnotifications_badge';
|
||||
static PENDING_UNREGISTER_TABLE = 'addon_pushnotifications_pending_unregister';
|
||||
static REGISTERED_DEVICES_TABLE = 'addon_pushnotifications_registered_devices';
|
||||
protected appTablesSchema: SQLiteDBTableSchema[] = [
|
||||
{
|
||||
name: AddonPushNotificationsProvider.BADGE_TABLE,
|
||||
name: CorePushNotificationsProvider.BADGE_TABLE,
|
||||
columns: [
|
||||
{
|
||||
name: 'siteid',
|
||||
|
@ -115,7 +115,7 @@ export class AddonPushNotificationsProvider {
|
|||
primaryKeys: ['siteid', 'addon']
|
||||
},
|
||||
{
|
||||
name: AddonPushNotificationsProvider.PENDING_UNREGISTER_TABLE,
|
||||
name: CorePushNotificationsProvider.PENDING_UNREGISTER_TABLE,
|
||||
columns: [
|
||||
{
|
||||
name: 'siteid',
|
||||
|
@ -138,11 +138,11 @@ export class AddonPushNotificationsProvider {
|
|||
}
|
||||
];
|
||||
protected siteSchema: CoreSiteSchema = {
|
||||
name: 'AddonPushNotificationsProvider',
|
||||
name: 'AddonPushNotificationsProvider', // The name still contains "Addon" for backwards compatibility.
|
||||
version: 1,
|
||||
tables: [
|
||||
{
|
||||
name: AddonPushNotificationsProvider.REGISTERED_DEVICES_TABLE,
|
||||
name: CorePushNotificationsProvider.REGISTERED_DEVICES_TABLE,
|
||||
columns: [
|
||||
{
|
||||
name: 'appid',
|
||||
|
@ -179,12 +179,12 @@ export class AddonPushNotificationsProvider {
|
|||
};
|
||||
|
||||
constructor(logger: CoreLoggerProvider, protected appProvider: CoreAppProvider, private initDelegate: CoreInitDelegate,
|
||||
protected pushNotificationsDelegate: AddonPushNotificationsDelegate, protected sitesProvider: CoreSitesProvider,
|
||||
protected pushNotificationsDelegate: CorePushNotificationsDelegate, protected sitesProvider: CoreSitesProvider,
|
||||
private badge: Badge, private localNotificationsProvider: CoreLocalNotificationsProvider,
|
||||
private utils: CoreUtilsProvider, private textUtils: CoreTextUtilsProvider, private push: Push,
|
||||
private configProvider: CoreConfigProvider, private device: Device, private zone: NgZone,
|
||||
private translate: TranslateService, private platform: Platform, private sitesFactory: CoreSitesFactoryProvider) {
|
||||
this.logger = logger.getInstance('AddonPushNotificationsProvider');
|
||||
this.logger = logger.getInstance('CorePushNotificationsProvider');
|
||||
this.appDB = appProvider.getDB();
|
||||
this.appDB.createTablesFromSchema(this.appTablesSchema);
|
||||
this.sitesProvider.registerSiteSchema(this.siteSchema);
|
||||
|
@ -207,7 +207,7 @@ export class AddonPushNotificationsProvider {
|
|||
* @return {Promise<any>} Resolved when done.
|
||||
*/
|
||||
cleanSiteCounters(siteId: string): Promise<any> {
|
||||
return this.appDB.deleteRecords(AddonPushNotificationsProvider.BADGE_TABLE, {siteid: siteId} ).finally(() => {
|
||||
return this.appDB.deleteRecords(CorePushNotificationsProvider.BADGE_TABLE, {siteid: siteId} ).finally(() => {
|
||||
this.updateAppCounter();
|
||||
});
|
||||
}
|
||||
|
@ -267,9 +267,9 @@ export class AddonPushNotificationsProvider {
|
|||
/**
|
||||
* Get data to register the device in Moodle.
|
||||
*
|
||||
* @return {AddonPushNotificationsRegisterData} Data.
|
||||
* @return {CorePushNotificationsRegisterData} Data.
|
||||
*/
|
||||
protected getRegisterData(): AddonPushNotificationsRegisterData {
|
||||
protected getRegisterData(): CorePushNotificationsRegisterData {
|
||||
return {
|
||||
appid: CoreConfigConstants.app_id,
|
||||
name: this.device.manufacturer || '',
|
||||
|
@ -338,7 +338,7 @@ export class AddonPushNotificationsProvider {
|
|||
}));
|
||||
|
||||
Promise.all(promises).then(() => {
|
||||
this.localNotificationsProvider.schedule(localNotif, AddonPushNotificationsProvider.COMPONENT, data.site);
|
||||
this.localNotificationsProvider.schedule(localNotif, CorePushNotificationsProvider.COMPONENT, data.site);
|
||||
});
|
||||
}
|
||||
|
||||
|
@ -381,11 +381,11 @@ export class AddonPushNotificationsProvider {
|
|||
const promises = [];
|
||||
|
||||
// Remove the device from the local DB.
|
||||
promises.push(site.getDb().deleteRecords(AddonPushNotificationsProvider.REGISTERED_DEVICES_TABLE,
|
||||
promises.push(site.getDb().deleteRecords(CorePushNotificationsProvider.REGISTERED_DEVICES_TABLE,
|
||||
this.getRegisterData()));
|
||||
|
||||
// Remove pending unregisters for this site.
|
||||
promises.push(this.appDB.deleteRecords(AddonPushNotificationsProvider.PENDING_UNREGISTER_TABLE, {siteid: site.id}));
|
||||
promises.push(this.appDB.deleteRecords(CorePushNotificationsProvider.PENDING_UNREGISTER_TABLE, {siteid: site.id}));
|
||||
|
||||
return Promise.all(promises).catch(() => {
|
||||
// Ignore errors.
|
||||
|
@ -397,7 +397,7 @@ export class AddonPushNotificationsProvider {
|
|||
}
|
||||
|
||||
// Store the pending unregister so it's retried again later.
|
||||
return this.appDB.insertRecord(AddonPushNotificationsProvider.PENDING_UNREGISTER_TABLE, {
|
||||
return this.appDB.insertRecord(CorePushNotificationsProvider.PENDING_UNREGISTER_TABLE, {
|
||||
siteid: site.id,
|
||||
siteurl: site.getURL(),
|
||||
token: site.getToken(),
|
||||
|
@ -587,7 +587,7 @@ export class AddonPushNotificationsProvider {
|
|||
// Now register the device.
|
||||
return site.write('core_user_add_user_device', this.utils.clone(data)).then((response) => {
|
||||
// Insert the device in the local DB.
|
||||
return site.getDb().insertRecord(AddonPushNotificationsProvider.REGISTERED_DEVICES_TABLE, data)
|
||||
return site.getDb().insertRecord(CorePushNotificationsProvider.REGISTERED_DEVICES_TABLE, data)
|
||||
.catch((error) => {
|
||||
// Ignore errors.
|
||||
});
|
||||
|
@ -595,7 +595,7 @@ export class AddonPushNotificationsProvider {
|
|||
}
|
||||
}).finally(() => {
|
||||
// Remove pending unregisters for this site.
|
||||
this.appDB.deleteRecords(AddonPushNotificationsProvider.PENDING_UNREGISTER_TABLE, {siteid: site.id}).catch(() => {
|
||||
this.appDB.deleteRecords(CorePushNotificationsProvider.PENDING_UNREGISTER_TABLE, {siteid: site.id}).catch(() => {
|
||||
// Ignore errors.
|
||||
});
|
||||
});
|
||||
|
@ -609,7 +609,7 @@ export class AddonPushNotificationsProvider {
|
|||
* @return {Promise<any>} Promise resolved with the stored badge counter for the addon or site or 0 if none.
|
||||
*/
|
||||
protected getAddonBadge(siteId?: string, addon: string = 'site'): Promise<any> {
|
||||
return this.appDB.getRecord(AddonPushNotificationsProvider.BADGE_TABLE, {siteid: siteId, addon: addon}).then((entry) => {
|
||||
return this.appDB.getRecord(CorePushNotificationsProvider.BADGE_TABLE, {siteid: siteId, addon: addon}).then((entry) => {
|
||||
return (entry && entry.number) || 0;
|
||||
}).catch(() => {
|
||||
return 0;
|
||||
|
@ -627,10 +627,10 @@ export class AddonPushNotificationsProvider {
|
|||
|
||||
if (siteId) {
|
||||
// Check if the site has a pending unregister.
|
||||
promise = this.appDB.getRecords(AddonPushNotificationsProvider.REGISTERED_DEVICES_TABLE, {siteid: siteId});
|
||||
promise = this.appDB.getRecords(CorePushNotificationsProvider.REGISTERED_DEVICES_TABLE, {siteid: siteId});
|
||||
} else {
|
||||
// Get all pending unregisters.
|
||||
promise = this.appDB.getAllRecords(AddonPushNotificationsProvider.PENDING_UNREGISTER_TABLE);
|
||||
promise = this.appDB.getAllRecords(CorePushNotificationsProvider.PENDING_UNREGISTER_TABLE);
|
||||
}
|
||||
|
||||
return promise.then((results) => {
|
||||
|
@ -665,7 +665,7 @@ export class AddonPushNotificationsProvider {
|
|||
number: value
|
||||
};
|
||||
|
||||
return this.appDB.insertRecord(AddonPushNotificationsProvider.BADGE_TABLE, entry).then(() => {
|
||||
return this.appDB.insertRecord(CorePushNotificationsProvider.BADGE_TABLE, entry).then(() => {
|
||||
return value;
|
||||
});
|
||||
}
|
||||
|
@ -673,21 +673,21 @@ export class AddonPushNotificationsProvider {
|
|||
/**
|
||||
* Check if device should be registered (and unregistered first).
|
||||
*
|
||||
* @param {AddonPushNotificationsRegisterData} data Data of the device.
|
||||
* @param {CorePushNotificationsRegisterData} data Data of the device.
|
||||
* @param {CoreSite} site Site to use.
|
||||
* @return {Promise<{register: boolean, unregister: boolean}>} Promise resolved with booleans: whether to register/unregister.
|
||||
*/
|
||||
protected shouldRegister(data: AddonPushNotificationsRegisterData, site: CoreSite)
|
||||
protected shouldRegister(data: CorePushNotificationsRegisterData, site: CoreSite)
|
||||
: Promise<{register: boolean, unregister: boolean}> {
|
||||
|
||||
// Check if the device is already registered.
|
||||
return site.getDb().getRecords(AddonPushNotificationsProvider.REGISTERED_DEVICES_TABLE, {
|
||||
return site.getDb().getRecords(CorePushNotificationsProvider.REGISTERED_DEVICES_TABLE, {
|
||||
appid: data.appid,
|
||||
uuid: data.uuid
|
||||
}).catch(() => {
|
||||
// Ignore errors.
|
||||
return [];
|
||||
}).then((records: AddonPushNotificationsRegisterData[]) => {
|
||||
}).then((records: CorePushNotificationsRegisterData[]) => {
|
||||
let isStored = false,
|
||||
versionOrPushChanged = false;
|
||||
|
|
@ -14,16 +14,16 @@
|
|||
|
||||
import { Injectable } from '@angular/core';
|
||||
import { CoreCronHandler } from '@providers/cron';
|
||||
import { AddonPushNotificationsProvider } from './pushnotifications';
|
||||
import { CorePushNotificationsProvider } from './pushnotifications';
|
||||
|
||||
/**
|
||||
* Cron handler to force a register on a Moodle site when a site is manually synchronized.
|
||||
*/
|
||||
@Injectable()
|
||||
export class AddonPushNotificationsRegisterCronHandler implements CoreCronHandler {
|
||||
name = 'AddonPushNotificationsRegisterCronHandler';
|
||||
export class CorePushNotificationsRegisterCronHandler implements CoreCronHandler {
|
||||
name = 'CorePushNotificationsRegisterCronHandler';
|
||||
|
||||
constructor(private pushNotificationsProvider: AddonPushNotificationsProvider) {}
|
||||
constructor(private pushNotificationsProvider: CorePushNotificationsProvider) {}
|
||||
|
||||
/**
|
||||
* Check whether the sync can be executed manually. Call isSync if not defined.
|
|
@ -14,16 +14,16 @@
|
|||
|
||||
import { Injectable } from '@angular/core';
|
||||
import { CoreCronHandler } from '@providers/cron';
|
||||
import { AddonPushNotificationsProvider } from './pushnotifications';
|
||||
import { CorePushNotificationsProvider } from './pushnotifications';
|
||||
|
||||
/**
|
||||
* Cron handler to retry pending unregisters.
|
||||
*/
|
||||
@Injectable()
|
||||
export class AddonPushNotificationsUnregisterCronHandler implements CoreCronHandler {
|
||||
name = 'AddonPushNotificationsUnregisterCronHandler';
|
||||
export class CorePushNotificationsUnregisterCronHandler implements CoreCronHandler {
|
||||
name = 'CorePushNotificationsUnregisterCronHandler';
|
||||
|
||||
constructor(private pushNotificationsProvider: AddonPushNotificationsProvider) {}
|
||||
constructor(private pushNotificationsProvider: CorePushNotificationsProvider) {}
|
||||
|
||||
/**
|
||||
* Execute the process.
|
|
@ -14,10 +14,10 @@
|
|||
|
||||
import { NgModule } from '@angular/core';
|
||||
import { Platform } from 'ionic-angular';
|
||||
import { AddonPushNotificationsProvider } from './providers/pushnotifications';
|
||||
import { AddonPushNotificationsDelegate } from './providers/delegate';
|
||||
import { AddonPushNotificationsRegisterCronHandler } from './providers/register-cron-handler';
|
||||
import { AddonPushNotificationsUnregisterCronHandler } from './providers/unregister-cron-handler';
|
||||
import { CorePushNotificationsProvider } from './providers/pushnotifications';
|
||||
import { CorePushNotificationsDelegate } from './providers/delegate';
|
||||
import { CorePushNotificationsRegisterCronHandler } from './providers/register-cron-handler';
|
||||
import { CorePushNotificationsUnregisterCronHandler } from './providers/unregister-cron-handler';
|
||||
import { CoreCronDelegate } from '@providers/cron';
|
||||
import { CoreEventsProvider } from '@providers/events';
|
||||
import { CoreLoggerProvider } from '@providers/logger';
|
||||
|
@ -25,9 +25,9 @@ import { CoreLocalNotificationsProvider } from '@providers/local-notifications';
|
|||
import { CoreUpdateManagerProvider } from '@providers/update-manager';
|
||||
|
||||
// List of providers (without handlers).
|
||||
export const ADDON_PUSHNOTIFICATIONS_PROVIDERS: any[] = [
|
||||
AddonPushNotificationsProvider,
|
||||
AddonPushNotificationsDelegate
|
||||
export const CORE_PUSHNOTIFICATIONS_PROVIDERS: any[] = [
|
||||
CorePushNotificationsProvider,
|
||||
CorePushNotificationsDelegate
|
||||
];
|
||||
|
||||
@NgModule({
|
||||
|
@ -36,20 +36,20 @@ export const ADDON_PUSHNOTIFICATIONS_PROVIDERS: any[] = [
|
|||
imports: [
|
||||
],
|
||||
providers: [
|
||||
AddonPushNotificationsProvider,
|
||||
AddonPushNotificationsDelegate,
|
||||
AddonPushNotificationsRegisterCronHandler,
|
||||
AddonPushNotificationsUnregisterCronHandler
|
||||
CorePushNotificationsProvider,
|
||||
CorePushNotificationsDelegate,
|
||||
CorePushNotificationsRegisterCronHandler,
|
||||
CorePushNotificationsUnregisterCronHandler
|
||||
]
|
||||
})
|
||||
export class AddonPushNotificationsModule {
|
||||
constructor(platform: Platform, pushNotificationsProvider: AddonPushNotificationsProvider, eventsProvider: CoreEventsProvider,
|
||||
export class CorePushNotificationsModule {
|
||||
constructor(platform: Platform, pushNotificationsProvider: CorePushNotificationsProvider, eventsProvider: CoreEventsProvider,
|
||||
localNotificationsProvider: CoreLocalNotificationsProvider, loggerProvider: CoreLoggerProvider,
|
||||
updateManager: CoreUpdateManagerProvider, cronDelegate: CoreCronDelegate,
|
||||
registerCronHandler: AddonPushNotificationsRegisterCronHandler,
|
||||
unregisterCronHandler: AddonPushNotificationsUnregisterCronHandler) {
|
||||
registerCronHandler: CorePushNotificationsRegisterCronHandler,
|
||||
unregisterCronHandler: CorePushNotificationsUnregisterCronHandler) {
|
||||
|
||||
const logger = loggerProvider.getInstance('AddonPushNotificationsModule');
|
||||
const logger = loggerProvider.getInstance('CorePushNotificationsModule');
|
||||
|
||||
// Register the handlers.
|
||||
cronDelegate.register(registerCronHandler);
|
||||
|
@ -80,13 +80,13 @@ export class AddonPushNotificationsModule {
|
|||
});
|
||||
|
||||
// Listen for local notification clicks (generated by the app).
|
||||
localNotificationsProvider.registerClick(AddonPushNotificationsProvider.COMPONENT,
|
||||
localNotificationsProvider.registerClick(CorePushNotificationsProvider.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,
|
||||
newName: CorePushNotificationsProvider.BADGE_TABLE,
|
||||
fields: [
|
||||
{
|
||||
name: 'siteid',
|
||||
|
@ -96,6 +96,6 @@ export class AddonPushNotificationsModule {
|
|||
});
|
||||
|
||||
// Migrate the component name.
|
||||
updateManager.registerLocalNotifComponentMigration('mmaPushNotifications', AddonPushNotificationsProvider.COMPONENT);
|
||||
updateManager.registerLocalNotifComponentMigration('mmaPushNotifications', CorePushNotificationsProvider.COMPONENT);
|
||||
}
|
||||
}
|
|
@ -22,7 +22,7 @@ import { CoreLangProvider } from '@providers/lang';
|
|||
import { CoreLocalNotificationsProvider } from '@providers/local-notifications';
|
||||
import { CoreSitesProvider } from '@providers/sites';
|
||||
import { CoreConfigConstants } from '../../../../configconstants';
|
||||
import { AddonPushNotificationsProvider } from '@addon/pushnotifications/providers/pushnotifications';
|
||||
import { CorePushNotificationsProvider } from '@core/pushnotifications/providers/pushnotifications';
|
||||
|
||||
/**
|
||||
* Page that displays the about settings.
|
||||
|
@ -58,7 +58,7 @@ export class CoreSettingsAboutPage {
|
|||
|
||||
constructor(platform: Platform, device: Device, appProvider: CoreAppProvider, fileProvider: CoreFileProvider,
|
||||
initDelegate: CoreInitDelegate, langProvider: CoreLangProvider, sitesProvider: CoreSitesProvider,
|
||||
localNotificationsProvider: CoreLocalNotificationsProvider, pushNotificationsProvider: AddonPushNotificationsProvider) {
|
||||
localNotificationsProvider: CoreLocalNotificationsProvider, pushNotificationsProvider: CorePushNotificationsProvider) {
|
||||
|
||||
const currentSite = sitesProvider.getCurrentSite();
|
||||
|
||||
|
|
|
@ -1,6 +1,10 @@
|
|||
This files describes API changes in the Moodle Mobile app,
|
||||
information provided here is intended especially for developers.
|
||||
|
||||
=== 3.7.0 ===
|
||||
|
||||
- The pushnotifications addon has been moved to core. All imports of that addon need to be fixed to use the right path and name.
|
||||
|
||||
=== 3.6.1 ===
|
||||
|
||||
- The local notifications plugin was updated to its latest version. The new API has some breaking changes, so please check its documentation if you're using local notifications. Also, you need to run "npm install" to update the ionic-native library.
|
||||
|
|
Loading…
Reference in New Issue