Push Notification not received on smartphone using Firebase in a Django application

Hello everybody,

we have built a Vue app using a Django backend and are now converting it to a Capacitor app.
We are trying to send out push notifications during a webhook request from some sensors. Basically, when the last 2 readings surpass a set limit Django should send a push notification to all affected users.
In a test function this all works just fine, the push notifications are received on the respective phones.
When receiving sensor data however no push notifications arrive on the phones. The test and the webhook function use the exact same code and they’re both carried out on the live server.

This is the function for sending out the push notifications:

def send_push_notifications(recipients, data):
    for token in recipients:
            try:
                message = messaging.Message(
                    notification=messaging.Notification(title=data["title"], body=data["body"]),
                    token=token,
                )
                messaging.send(message)
                import time
                time.sleep(1)
            except Exception as e:
                continue

Here is the function that checks the readings and collects users to send notifications to:

last_readings = Reading.objects.filter(Q(sensor=sensor_db) & Q(outdoor_temperature__isnull=False)).order_by("-timestamp")[:2]
    notify = True
    for reading in last_readings:
        if reading.outdoor_temperature < sensor_db.max_temp:
            notify = False
            break

    if notify:
        users = UserToCompany.objects.filter(Q(company=sensor_db.company) & Q(user__gets_notifications=True))
        ids = []
        for i in users:
            ids.append(i.user.push_secret)

        data = {
            "title": "title",
            "body": f"message"
        }

        send_push_notifications(ids, data)

We tried threading in case the function returns before finishing for some reason. The code also works and sends out push notifications if triggered manually, e.g. on server restart.

Is this a capacitor issue or a Firebase issue and does anybody know how to solve this?
We’d love to get feedback on this as it’s driving us up the walls.

Thank you very much for your time.

It would only be a Capacitor issue if something is misconfigured. Did you follow the guide? - Push Notifications - Firebase | Capacitor Documentation

What Python Firebase library are you using?