Merge pull request #2600 from dpalou/MOBILE-3507

Mobile 3507
main
Juan Leyva 2020-11-11 12:20:38 +01:00 committed by GitHub
commit dbe0b86821
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 12 additions and 4 deletions

View File

@ -39,6 +39,11 @@ export class AddonNotificationsPushClickHandler implements CorePushNotifications
* @return Whether the notification click is handled by this handler
*/
handles(notification: any): boolean | Promise<boolean> {
if (!notification.moodlecomponent) {
// The notification doesn't come from Moodle. Handle it.
return true;
}
if (this.utils.isTrueOrOne(notification.notif)) {
// Notification clicked, mark as read. Don't block for this.
const notifId = notification.savedmessageid || notification.id;
@ -74,7 +79,7 @@ export class AddonNotificationsPushClickHandler implements CorePushNotifications
// Try to handle the appurl.
if (notification.customdata && notification.customdata.appurl) {
switch (notification.customdata.appurlopenin) {
case 'inappbrowser':
case 'inapp':
this.utils.openInApp(notification.customdata.appurl);
return;

View File

@ -37,8 +37,8 @@ export class CoreCoursesEnrolPushClickHandler implements CorePushNotificationsCl
* @return Whether the notification click is handled by this handler
*/
handles(notification: any): boolean | Promise<boolean> {
return this.utils.isTrueOrOne(notification.notif) && notification.moodlecomponent.indexOf('enrol_') === 0 &&
notification.name == 'expiry_notification';
return this.utils.isTrueOrOne(notification.notif) && notification.moodlecomponent &&
notification.moodlecomponent.indexOf('enrol_') === 0 && notification.name == 'expiry_notification';
}
/**

View File

@ -124,7 +124,10 @@ export class CorePushNotificationsDelegate {
* @return Promise resolved with boolean: whether the handler feature is disabled.
*/
protected isFeatureDisabled(handler: CorePushNotificationsClickHandler, siteId: string): Promise<boolean> {
if (handler.featureName) {
if (!siteId) {
// Notification doesn't belong to a site. Assume all handlers are enabled.
return Promise.resolve(false);
} else if (handler.featureName) {
// Check if the feature is disabled.
return this.sitesProvider.isFeatureDisabled(handler.featureName, siteId);
} else {