eVitabu dev week, March 2025

Push notifications are finally in! 🥳

Hands holding a tablet.There's a white background showing an orange open book with the word "eVitabu".

It's been just over a year since the last eVitabu dev week (January 2024) and I've not done much development work on the project since then. On the plus side, since a change in job status I'm hoping to get more work done on it this year - starting with this dev week.

Logistical changes & travel

I focus better on the project when I'm working alongside Geoff, the Projects Coordinator for APF. Previously when I've travelled to the Welsh border I've carried everything - clothes, equipment, snacks. That worked, but my bag was ridiculously heavy. Plus, if I bent down to tie my shoe I'd be hit in the head by my keyboard swinging around my bag. This time I sent my portable monitor, laptop stand, and clothes ahead by tracked post. My bag was still heavy, but it was more manageable.

Trains in the UK are generally considered to be over priced and unreliable. Planning my journey out revealed that sometimes there was an extra train. Pretty confident that train doesn't actually exist, as searching for it directly never showed it. No matter, the route was sorted. I did get stuck outside a station for ten minutes on the way out, and the conductor ("on-board train manager") reminded us all to apply for delay repay. £14.15 recouped 🙂. The journey home went smoothly.

Goal

Much like in January 2024, the goal was to implement push notifications - this time without the sudden side quests (see the January 2024 post). The announcements feature was one of the first functions I built into EVM, the eVitabu Management system, back in 2017 but it's rarely been used. We're hoping to use this more and increase engagement with the app by implementing push notifications.

Day one - always a challenge

I always find the biggest issues of a dev week happen on day one, and this time was no different. I put this down to the fact that I'm getting used to the code again, and day one tends to be when I update any dependencies for the apps. After checking what updates were due and applying them I was ready to carry on writing features. I can't recall exactly what the problem was this time, but not everything worked first time.

Removing Android 5, 6, 7.0 support

There's a lot of older phones being used in Africa, and back in 2017 we decided that eVitabu should run on the oldest version of Android possible. Initially we supported Android 6, but we expanded that to Android 5. Android 4 was out of reach - it didn't support TLSv1.2.

Sadly we've had to now drop support for Android 5, 6, and 7.0 because they do not trust the root certificates used by Let's Encrypt [1]. In October 2024, Let's Encrypt changed to using root certificates that weren't supported on these earlier Android versions. A quick bit of analysis showed we'd got less than 100 users that would be affected, and realistically they wouldn't have been able to access eVitabu since October 2024 anyway. We hadn't received any complaints, and the last access times for those users were back in 2023 or earlier.

It's a shame, but Android 5 is over eleven years old, with 6 and 7 being released ten and nine years ago respectively, so they've had a good run.

An alternative would have been to change the certificate in use, if there's an authority that's still supported, but the access dates showed that wasn't relevant.

Coding with an "AI" partner (JetBrains AI)

When I worked for a software development company there was a lot of interest in using "AI" tools to help with development - both speed and efficiency. I'd used my JetBrains AI trial last year but I hadn't found it much use, so if I wanted to try again I'd need to purchase a month's access. The pricing was quite reasonable at around £9 per month (yearly billing would have been cheaper) and I paid for a month's usage - this was absolutely the right decision.

I'll be writing another post about coding with an "AI" partner, so keep an eye out for that.

For this work I would be using PhpStorm and Android Studio, both of which are made by JetBrains. Previously Android Studio couldn't use the AI plugin, but it's been updated and is now supported. I did have to roll Android Studio back to 2024.3.1 though, as there's a plugin dependency that's not supported in the latest release.

With the plugin installed in both tools, and keen to try it out, I started by asking what framework I was using for EVM. JetBrains AI correctly identified Yii2, which I figured was a good start! For my Android development, I used the "AI" to propose the easiest way to access a method from within another class, to make sure I could register Firebase Cloud Messaging (FCM) tokens via an API call. I also used the "AI" to explain the program flow within Main.java (it'd been a while...).

On the PHP side of things, I used JetBrains AI to tell me how I could interact with Firebase. The tool correctly identified an SDK, told me how I could include it in my project, and gave me instructions on what code I needed.

Adding push notification support

After including the SDK written by Kreait I was able to add methods to cause EVM to send push notifications to my test phones. This didn't work first time, partly because some of the proposed code from the "AI" had a mistake (the message format needs to be an array that contains an array for the title & message, with a separate array value for the FCM token [2]).

💰
The Firebase SDK by Kreait is unofficial but widely used. According to the developer, many people do not sponsor the project or contribute donations. If you use their SDK, please consider making a donation - we have sent one.

After working out the issue with the payload, which I used the "AI" to help me identify, I created an announcement in EVM and was pleased to send this screenshot to Dave who heads up APF:

Screenshot of an Android phone.  The icon is a picture of Africa and titled "An announcement that should make Dave happy".  The message text is "Hi Dave.  Still work in progress, but this announcement should be pushed to my test phone..."
A progress update to the charity CEO - a picture is worth a thousand words.

So the same announcement isn't sent multiple times, I made sure it's marked as sent with a date. Saving the date onto the announcement meant the "after save" process was being triggered, but I'd forgotten to add the logic to only send push notifications that hadn't been sent yet. Forty-nine push notifications hit my test phone before the script either timed out or Firebase stopped the repeat messages. Rookie mistake there 🤦‍♀️!

Initially I had the push notifications send immediately after the announcement was saved, and that led to the problem I mentioned above. While this is great in a test system, if there's 2,000 users each with an FCM token registered, the APF staff member's browser would wait until all the messages were sent before saying "announcement saved" - almost certainly the browser would time out. I moved the push notifications to send via a background process that runs on schedule. Now announcements will only send every ten minutes, and only if the announcement is over ten minutes old - that way my colleagues have time to make edits to fix details or typos.

Other improvements

There's been a bug in EVM for a while that I'd not noticed. Some time ago I moved EVM from an older version of Bootstrap to Bootstrap 4. What I failed to do was update all of my forms to use the new Bootstrap 4 styles. As a result, forgetting to fill in all required fields flagged up as red on some forms but not others.

Screenshot showing a form titled "create announcement".  The box labelled "title" contains no text.  There's an error under the box says "title cannot be blank".
It took me ages to see errors like "title cannot be blank" when they weren't highlighted!

The "error summary" was also missing. Fixed that now, but it did take me a while trying to work out why I couldn't save the announcement when the errors weren't highlighted to me...

The same form as before, but this time there's a pink box containing a summary of errors at the top, listing the fields that "cannot be blank".  The "title" field also now has a red border, and the error underneath it says "title cannot be blank" in red, highlighting it to the user.
✅ Much better 🙂.

Equipment this trip - the Framework 16 shines 🙂

This trip was the first time I've used my Framework 16 laptop for extensive development work. I'm pleased to say that it performed admirably. Previous dev weeks I've really struggled with RAM, as I had 16 GB at most in previous machines. With 64 GB in my Framework 16 I didn't run out of RAM. I had at least five Android virtual devices (emulators) running at one point, which was great. My JetBrains tools claimed they were running out of memory, so I just gave them more! Sometimes the emulators lagged, but I could cope with that once I realised what was happening.

I took along my WASD v3 mechanical keyboard, an external mouse, my portable 16" monitor, and my Kobo Libra Colour for making notes and to do lists.

All in all, productive

This was a really productive week, I think a combination of having grown as a developer, having (more) decent equipment, and having the JetBrains AI subscription. I'll be able to release the push notification feature to our partners after some final testing next week. The code works, but it's definitely ugly in places. Maybe I'll use JetBrains AI to suggest some refactoring and tidying up to help make things better (and easier to work with in future)...


Banner image: eVitabu app banner.

[1] We would have put EVM behind Cloudflare, but there are file upload limits with Cloudflare's free tier that would prevent us from working. I might look into using rules to work around that, but that'll definitely need some research to check the caching doesn't cause issues.

[2] For the developers:

$message = [
  'notification' => [
    'title' => 'Text string title',
    'body'  => 'Text string message body',
    ],
  'token' => $fcmToken,
];