Uploaded image for project: 'Moodle'
  1. Moodle
  2. MDL-47163

Upgrade the Mobile notifications plugin to use Airnotifier API v2

    XMLWordPrintable

    Details

    • Type: Task
    • Status: Closed
    • Priority: Minor
    • Resolution: Fixed
    • Affects Version/s: 2.8
    • Fix Version/s: 2.8
    • Component/s: Messages
    • Labels:
    • Testing Instructions:
      Hide

      Testing requires an Android or iOs phone with the Moodle Mobile app installed.
      It also requires to have the testing Moodle installation under a local domain accesible by the mobile device.

      1. Configure and enable the "Mobile notifications" message output, you can find and access key in the comments bellow (comment restricted)
      2. Once configured (you only need to add the access key), remember to enable the plugin.
      3. Access with the Mobile app to your Moodle site using a student account
      4. Log in with the same student account in the Moodle site (using the browser), go to your messaging preferences and enable receive Mobile notifications for internal messages. Check that your mobile device is listed at the bottom of the page
      5. Now, since there is not a public instance of Airnotifier v2 for testing, we need to test that Moodle is sending the Push message data correctoy, so I've created a PHP file that "emulates" Airnotifier push handler you need to:
      6. As and admin user, log in in Moodle, edit the "Mobile notifications" plugin and change the host and port to point to your local server, i.e: http://localhost and 80 (Notice, that you should point to your www root not to the notification directory) Notice also that the URL shouldn't have a slash at the end
      7. As and admin user send an internal message to the student account
      8. Go to the "notification" directory, you should see a log.txt file, open that file
      9. Confirm that:
        • In the log.txt file you see the message: JSON data correctly received and parsed and a PHP array like (with your custom message)

          stdClass::__set_state(array(
             'device' => 'Android',
             'token' => 'APA91bGp6PnO-Pzgw2E9cUXQuJ-U09MVKguLWdMcEaT4AdcitimY4Td3vUwP2ZAroVJaBUKpqY2Ngp3Q1hnTQ7UiRE9Yz-N2GZtlmQknKT1I4Ao78E3EJOX0CSPWKa6nL1FAfky97Je7z6pWHuLmWljJqY_SdrxJlsIurZSNokxYfpeMW7MGrao',
             'extra' => 
            stdClass::__set_state(array(
               'component' => 'moodle',
               'name' => 'instantmessage',
               'subject' => 'New message from Admin User',
               'fullmessage' => 'ho hoy there
           
          ---------------------------------------------------------------------
          This is a copy of a message sent to you at "Moodle Bugs". Go to http://localhost/moodlebugs/message/index.php?user=4&id=2 to reply.',
               'fullmessagehtml' => '',
               'fullmessageformat' => '0',
               'smallmessage' => 'ho hoy there',
               'timecreated' => 1410781172,
               'notification' => '0',
               'savedmessageid' => 94,
               'userfromid' => '2',
               'userfromfullname' => 'Admin User',
               'usertoid' => '4',
               'processor' => 'moodle',
               'site' => '11bf3b646c9106f51fd67ae97139d458',
               'date' => 1410781172,
            )),
          ))
          

      Show
      Testing requires an Android or iOs phone with the Moodle Mobile app installed. It also requires to have the testing Moodle installation under a local domain accesible by the mobile device. Configure and enable the "Mobile notifications" message output, you can find and access key in the comments bellow (comment restricted) Once configured (you only need to add the access key), remember to enable the plugin. Access with the Mobile app to your Moodle site using a student account Log in with the same student account in the Moodle site (using the browser), go to your messaging preferences and enable receive Mobile notifications for internal messages. Check that your mobile device is listed at the bottom of the page Now, since there is not a public instance of Airnotifier v2 for testing, we need to test that Moodle is sending the Push message data correctoy, so I've created a PHP file that "emulates" Airnotifier push handler you need to: Create a new folder in your web server document root called "notification" Copy there this index.php file: https://gist.github.com/jleyva/ef5a30f93b0fffa17e12/download Grant 777 permissions or web server user write permissions to that directory (a new log.txt file will be created) As and admin user, log in in Moodle, edit the "Mobile notifications" plugin and change the host and port to point to your local server, i.e: http://localhost and 80 (Notice, that you should point to your www root not to the notification directory) Notice also that the URL shouldn't have a slash at the end As and admin user send an internal message to the student account Go to the "notification" directory, you should see a log.txt file, open that file Confirm that: In the log.txt file you see the message: JSON data correctly received and parsed and a PHP array like (with your custom message) stdClass::__set_state(array( 'device' => 'Android', 'token' => 'APA91bGp6PnO-Pzgw2E9cUXQuJ-U09MVKguLWdMcEaT4AdcitimY4Td3vUwP2ZAroVJaBUKpqY2Ngp3Q1hnTQ7UiRE9Yz-N2GZtlmQknKT1I4Ao78E3EJOX0CSPWKa6nL1FAfky97Je7z6pWHuLmWljJqY_SdrxJlsIurZSNokxYfpeMW7MGrao', 'extra' => stdClass::__set_state(array( 'component' => 'moodle', 'name' => 'instantmessage', 'subject' => 'New message from Admin User', 'fullmessage' => 'ho hoy there   --------------------------------------------------------------------- This is a copy of a message sent to you at "Moodle Bugs". Go to http://localhost/moodlebugs/message/index.php?user=4&id=2 to reply.', 'fullmessagehtml' => '', 'fullmessageformat' => '0', 'smallmessage' => 'ho hoy there', 'timecreated' => 1410781172, 'notification' => '0', 'savedmessageid' => 94, 'userfromid' => '2', 'userfromfullname' => 'Admin User', 'usertoid' => '4', 'processor' => 'moodle', 'site' => '11bf3b646c9106f51fd67ae97139d458', 'date' => 1410781172, )), ))
    • Affected Branches:
      MOODLE_28_STABLE
    • Fixed Branches:
      MOODLE_28_STABLE
    • Pull from Repository:
    • Pull Master Branch:
      MDL-47163-master

      Description

      As mentioned in MDL-45492 Airnotifier API v2 has a new API that will be able to handle full Moodle message objects

      This will allow us to not use specific platforms hacks in Moodle code, we just need to send a full message object to Airnotifier:

      Airnotifier is backwards compatible so old sites using the old API still works

        Attachments

          Issue Links

            Activity

              People

              • Votes:
                0 Vote for this issue
                Watchers:
                5 Start watching this issue

                Dates

                • Created:
                  Updated:
                  Resolved:
                  Fix Release Date:
                  10/Nov/14