Hi,
I am writing a moodle schedule task which will run automatically using Schedule task.I need to send a push notification to iOS mobile when this scheduled task will run.
For this, I have imported PushNotifications.php class external file into my working folder i.e "/home/onlin200/public_html/mod/certificate/classes/task/PushNotifications.php" which will help me send notification.
The file in which I am writing my schedule task is also in the same folder "/home/onlin200/public_html/mod/certificate/classes/task/drill_re_certification_notification.php"
The class file which I am importing: https://gist.github.com/joashp/b2f6c7e24127f2798eb2 into my task folder.I want to access function written in PushNotifications.php class file into my Task file.
Below is my code.
<?php
namespace mod_certificate\task;
require('PushNotifications.php');
class drill_re_certification_notification extends \core\task\scheduled_task{
function execute() {
global $DB;
$subject = get_string('recertify', 'mod_certificate','');
$emailbody = get_string('recertify_emailbody', 'mod_certificate','');
$msg_payload = array (
'mtitle' => 'Test push notification title',
'mdesc' => 'Test push notification body',
);
$DATA = $DB->get_recordset_sql ("Select notifydate,deviceToken from vw_user_recertification_notify");
foreach ($DATA as $id => $student) {
$record = new \stdClass();
$record ->email = $student->email;
$record ->notifydate= $student->notifydate;
$record ->devicetoken= $student->devicetoken;
if(time() == time())
{
PushNotifications::iOS($msg_payload, (string)($record ->deviceToken)); --Function
if (mail((string)($record ->email), $subject, $emailbody, $header, '-f'."b@test.com"))
{
}
}
}
}
Error message:
Fatal error: Class 'mod_certificate\task\PushNotifications' not found in /home/onlin200/public_html/mod/certificate/classes/task/drill_re_certification_notification.php on line 61