Skip to content

Commit dbe0b86

Browse files
authored
Merge pull request #2600 from dpalou/MOBILE-3507
Mobile 3507
2 parents 0197e5c + e46aab5 commit dbe0b86

File tree

3 files changed

+12
-4
lines changed

3 files changed

+12
-4
lines changed

src/addon/notifications/providers/push-click-handler.ts

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,11 @@ export class AddonNotificationsPushClickHandler implements CorePushNotifications
3939
* @return Whether the notification click is handled by this handler
4040
*/
4141
handles(notification: any): boolean | Promise<boolean> {
42+
if (!notification.moodlecomponent) {
43+
// The notification doesn't come from Moodle. Handle it.
44+
return true;
45+
}
46+
4247
if (this.utils.isTrueOrOne(notification.notif)) {
4348
// Notification clicked, mark as read. Don't block for this.
4449
const notifId = notification.savedmessageid || notification.id;
@@ -74,7 +79,7 @@ export class AddonNotificationsPushClickHandler implements CorePushNotifications
7479
// Try to handle the appurl.
7580
if (notification.customdata && notification.customdata.appurl) {
7681
switch (notification.customdata.appurlopenin) {
77-
case 'inappbrowser':
82+
case 'inapp':
7883
this.utils.openInApp(notification.customdata.appurl);
7984

8085
return;

src/core/courses/providers/enrol-push-click-handler.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,8 +37,8 @@ export class CoreCoursesEnrolPushClickHandler implements CorePushNotificationsCl
3737
* @return Whether the notification click is handled by this handler
3838
*/
3939
handles(notification: any): boolean | Promise<boolean> {
40-
return this.utils.isTrueOrOne(notification.notif) && notification.moodlecomponent.indexOf('enrol_') === 0 &&
41-
notification.name == 'expiry_notification';
40+
return this.utils.isTrueOrOne(notification.notif) && notification.moodlecomponent &&
41+
notification.moodlecomponent.indexOf('enrol_') === 0 && notification.name == 'expiry_notification';
4242
}
4343

4444
/**

src/core/pushnotifications/providers/delegate.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -124,7 +124,10 @@ export class CorePushNotificationsDelegate {
124124
* @return Promise resolved with boolean: whether the handler feature is disabled.
125125
*/
126126
protected isFeatureDisabled(handler: CorePushNotificationsClickHandler, siteId: string): Promise<boolean> {
127-
if (handler.featureName) {
127+
if (!siteId) {
128+
// Notification doesn't belong to a site. Assume all handlers are enabled.
129+
return Promise.resolve(false);
130+
} else if (handler.featureName) {
128131
// Check if the feature is disabled.
129132
return this.sitesProvider.isFeatureDisabled(handler.featureName, siteId);
130133
} else {

0 commit comments

Comments
 (0)