Push Notifications for New Resources

Re: Push Notifications for New Resources

by Abhijeet Viswa -
Number of replies: 0
We were able to set up Airnotifier on a custom Moodle client as well.

Firstly, setup airnotifier by cloning the master branch from airnotifier/airnotifier. For reference, we are on commit 27207bc9e8ee8f3ac9db428a456020d9e55eabda. All of this is assuming you are forking the official Moodle app, if you are making your own app from scratch then you can checkout crux-bphc/CMS-Android, specifically commits 27b342c and 98bcf43. For iOS, checkout crux-bphc/CMS-iOS.

Let's start with FCM:

Setup an Airnotifier project and provide the FCM project ID and JSON key. You have to setup your Android application to use the FCM config file. For the official Moodle app I believe all you'll need to do is to change the google-services.json file.

For APN:
The Moodle hook for Airnotifier has a bug making it incompatible with APN. Use this fork instead: chaubss/airnotifier. I did not work on the APN side for our app so I'm not sure what more there is to it on the Apple side. But the iOS/APN documentation should help you out here.

Once this is done, make sure Airnotifier works by running the server and sending a PUSH request to the Airnotifier API. The Airnotifier repository has a Postman workspace that you can use to test. Once you know Airnotifier works, it should be pretty straight forward to test with a hosted Moodle instance itself. Note that Moodle doesn't allow a namespace and you need to use a subdomain (i.e you cannot do example.com/airnotifier you need to do airnotifier.example.com). You can check if your mobile device registers itself to Moodle by using the mdl_user_devices table. Notifications can be tested by sending messages between two users or by creating discussions and making sure notifications are sent out immediately.

This explanation probably is inadequate, so if you face any trouble, do reach out.