Thank you Basem, Juan & Moodle community. I finally got my custom moodle mobile app with self-hosted Airnotifier setup (non-ssl) working for gcm notification.
Moodle Version: Moodle 3.1.1+ (Build: 20160728) up-to-date. [AWS Ubuntu 14.04]
Airnotifier [AWS Ubuntu 14.04] - separate server
Moodle Mobile: 3.1.2 [custom app - phonegap guild published to Play Store]
Here are some errors I encountered & how they got resolved -
{"error": "Invalid token"}
- In my case this was due to wrong build of airnotifer (no excuses for this). I reinstalled correct one - https://github.com/moodlehq/airnotifier/tree/moodle2 (branch moodle2)'. To uninstall wrong setup, I removed 'airnotifier' folder & I had to manually delete related mongodb database(s) before fresh setup.
SSLError: bad handshake: Error([('SSL routines', 'SSL3_GET_SERVER_CERTIFICATE', 'certificate verify failed')],)
- This was due to "certifi" python library I think
- First I did the below steps (recommended by Juan in a forum post), it still did not solve.
https://tracker.moodle.org/browse/MDLSITE-3730
- Then, I followed this thread & reinstalled "certifi" version as suggested. It resolved the SSL error.
{"error": "There was an error authenticating the sender account."}
500 POST /api/v2/push/ (52.76.77.226) 70.72ms
- this was due to wrong API key. I could resolve it by using the correct key from "credentials' section of 'API Manager" in Google Developer Console
Lastly, device was not getting listed in the user preferences section when I logged in as admin & checked preferences of a particular user. But when I logged in as that specific user, I could see the device in the "Mobile Notifications" section. Not sure if this is how it is meant to be.
- thanks