From 5d3e75e22091a4084e4c7d9c1e71b4c6bc97e20c Mon Sep 17 00:00:00 2001 From: Dani Palou Date: Tue, 15 Sep 2020 08:27:16 +0200 Subject: [PATCH 1/3] MOBILE-3507 notifications: Support notifications with big pictures --- src/core/pushnotifications/providers/pushnotifications.ts | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/core/pushnotifications/providers/pushnotifications.ts b/src/core/pushnotifications/providers/pushnotifications.ts index 76b2faa73..7c8449406 100644 --- a/src/core/pushnotifications/providers/pushnotifications.ts +++ b/src/core/pushnotifications/providers/pushnotifications.ts @@ -527,6 +527,12 @@ export class CorePushNotificationsProvider { localNotif.icon = notification.image; // This feature isn't supported by the official plugin, we use a fork. ( localNotif).iconType = data['image-type']; + + localNotif.summary = data.summaryText; + + if (data.picture) { + localNotif.attachments = [data.picture]; + } } Promise.all(promises).then(() => { From 06ce5e765c2339666b9b399302af719036c2bb4c Mon Sep 17 00:00:00 2001 From: Dani Palou Date: Tue, 15 Sep 2020 12:03:31 +0200 Subject: [PATCH 2/3] MOBILE-3507 notifications: Support view rich text when clicked --- .../providers/push-click-handler.ts | 48 +++++++++---------- src/providers/utils/text.ts | 5 +- 2 files changed, 26 insertions(+), 27 deletions(-) diff --git a/src/addon/notifications/providers/push-click-handler.ts b/src/addon/notifications/providers/push-click-handler.ts index 425437ddb..4797819ae 100644 --- a/src/addon/notifications/providers/push-click-handler.ts +++ b/src/addon/notifications/providers/push-click-handler.ts @@ -14,6 +14,7 @@ import { Injectable } from '@angular/core'; import { CoreEventsProvider } from '@providers/events'; +import { CoreTextUtils } from '@providers/utils/text'; import { CoreUtilsProvider } from '@providers/utils/utils'; import { CorePushNotificationsClickHandler } from '@core/pushnotifications/providers/delegate'; import { CoreContentLinksHelperProvider } from '@core/contentlinks/providers/helper'; @@ -60,38 +61,35 @@ export class AddonNotificationsPushClickHandler implements CorePushNotifications * @param notification The notification to check. * @return Promise resolved when done. */ - handleClick(notification: any): Promise { - let promise; + async handleClick(notification: any): Promise { + + if (notification.customdata.extendedtext) { + // Display the text in a modal. + return CoreTextUtils.instance.viewText(notification.title, notification.customdata.extendedtext, { + displayCopyButton: true, + modalOptions: { cssClass: 'core-modal-fullscreen' }, + }); + } // Try to handle the appurl first. if (notification.customdata && notification.customdata.appurl) { - promise = this.linkHelper.handleLink(notification.customdata.appurl, undefined, undefined, true); - } else { - promise = Promise.resolve(false); + if (this.linkHelper.handleLink(notification.customdata.appurl, undefined, undefined, true)) { + // Link treated, stop. + return; + } } - return promise.then((treated) => { - - if (!treated) { - // No link or cannot be handled by the app. Try to handle the contexturl now. - if (notification.contexturl) { - return this.linkHelper.handleLink(notification.contexturl); - } else { - return false; - } + // No appurl or cannot be handled by the app. Try to handle the contexturl now. + if (notification.contexturl) { + if (this.linkHelper.handleLink(notification.contexturl)) { + // Link treated, stop. + return; } + } - return true; - }).then((treated) => { + // No contexturl or cannot be handled by the app. Open the notifications page. + await this.utils.ignoreErrors(this.notificationsProvider.invalidateNotificationsList(notification.site)); - if (!treated) { - // No link or cannot be handled by the app. Open the notifications page. - return this.notificationsProvider.invalidateNotificationsList(notification.site).catch(() => { - // Ignore errors. - }).then(() => { - return this.linkHelper.goInSite(undefined, 'AddonNotificationsListPage', undefined, notification.site); - }); - } - }); + await this.linkHelper.goInSite(undefined, 'AddonNotificationsListPage', undefined, notification.site); } } diff --git a/src/providers/utils/text.ts b/src/providers/utils/text.ts index af83ced3b..ddac24c1b 100644 --- a/src/providers/utils/text.ts +++ b/src/providers/utils/text.ts @@ -14,7 +14,7 @@ import { Injectable } from '@angular/core'; import { DomSanitizer, SafeUrl } from '@angular/platform-browser'; -import { ModalController } from 'ionic-angular'; +import { ModalController, ModalOptions } from 'ionic-angular'; import { TranslateService } from '@ngx-translate/core'; import { CoreLangProvider } from '../lang'; import { makeSingleton } from '@singletons/core.singletons'; @@ -1163,7 +1163,7 @@ export class CoreTextUtilsProvider { Object.assign(params, options); - const modal = this.modalCtrl.create('CoreViewerTextPage', params); + const modal = this.modalCtrl.create('CoreViewerTextPage', params, options.modalOptions); modal.present(); } } @@ -1181,6 +1181,7 @@ export type CoreTextUtilsViewTextOptions = { instanceId?: number; // The instance ID related to the context. courseId?: number; // Course ID the text belongs to. It can be used to improve performance with filters. displayCopyButton?: boolean; // Whether to display a button to copy the text. + modalOptions?: ModalOptions; // Modal options. }; export class CoreTextUtils extends makeSingleton(CoreTextUtilsProvider) {} From 4c32239b54cc08eb2fe100c282fde0a6d25bf715 Mon Sep 17 00:00:00 2001 From: Dani Palou Date: Wed, 16 Sep 2020 11:34:23 +0200 Subject: [PATCH 3/3] MOBILE-3507 notifications: Support open appurl in browser/iab --- .../providers/push-click-handler.ts | 19 +++++++++++++++---- 1 file changed, 15 insertions(+), 4 deletions(-) diff --git a/src/addon/notifications/providers/push-click-handler.ts b/src/addon/notifications/providers/push-click-handler.ts index 4797819ae..b6504debd 100644 --- a/src/addon/notifications/providers/push-click-handler.ts +++ b/src/addon/notifications/providers/push-click-handler.ts @@ -71,11 +71,22 @@ export class AddonNotificationsPushClickHandler implements CorePushNotifications }); } - // Try to handle the appurl first. + // Try to handle the appurl. if (notification.customdata && notification.customdata.appurl) { - if (this.linkHelper.handleLink(notification.customdata.appurl, undefined, undefined, true)) { - // Link treated, stop. - return; + switch (notification.customdata.appurlopenin) { + case 'inappbrowser': + this.utils.openInApp(notification.customdata.appurl); + + return; + + case 'browser': + return this.utils.openInBrowser(notification.customdata.appurl); + + default: + if (this.linkHelper.handleLink(notification.customdata.appurl, undefined, undefined, true)) { + // Link treated, stop. + return; + } } }