Skip to content

Commit e46aab5

Browse files
committed
MOBILE-3507 push: Support notifications without component
1 parent ca172ba commit e46aab5

File tree

2 files changed

+8
-3
lines changed

2 files changed

+8
-3
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
/**

0 commit comments

Comments
 (0)