Support push notification click for Plugin

Support push notification click for Plugin

by Dat Nguyen Thang -
Number of replies: 1

I see guide about support notification click for custom plugin:

https://docs.moodle.org/dev/Mobile_support_for_plugins#Support_push_notification_clicks

Is there any example or something like that?

I try to register click handler from CorePushNotificationsDelegate.

But when clicking it push to homepage or message page.

Any idea?



(function (t) {


//Handler to proceed Push Notification

function AddonFooPushClickHandler() {

        this.name = "AddonFooPushClickHandler";

this.priority = 1;

this.featureName = 'CoreMainMenuDelegate_AddonFoo';

    }


    AddonFooPushClickHandler.prototype.constructor = AddonFooPushClickHandler;

AddonFooPushClickHandler.prototype.handles = function(notification){

if (t.CoreUtilsProvider.isTrueOrOne(notification.notif) && notification.name == 'lesson') {

return true;

}

return false;

};


AddonFooPushClickHandler.prototype.handleClick = function(notification){

const data = notification.customdata || {},

            courseId = Number(notification.courseid),

            moduleId = Number(data.cmid);


        return this.CoreGradesHelperProvider.goToGrades(courseId, undefined, moduleId, undefined, notification.site);

};

    t.CorePushNotificationsDelegate.registerClickHandler(new AddonFooPushClickHandler());


})(this);

Average of ratings: -
In reply to Dat Nguyen Thang

Re: Support push notification click for Plugin

by Dat Nguyen Thang -
How to i could implement interface "CorePushNotificationsClickHandler" on Moodle Plugin!

I've used:
AddonAtsGamePushClickHandler.prototype = Object.create(t.CorePushNotificationsClickHandler.prototype);

it throws errror: CoreCompileProvider: Error evaluating javascript TypeError: Cannot read property 'prototype' of undefined

Any idea!