jazzband / django-push-notifications

Send push notifications to mobile devices through GCM or APNS in Django.
MIT License
2.26k stars 614 forks source link

Application Registry API #362

Open matthewh opened 7 years ago

matthewh commented 7 years ago

@jleclanche, I'm working on a feature to add DRF support for triggering a push message via HTTP POST.

Example: POST /api/v1/push/ with a JSON payload:

{
    "message": {
        "badge": <int>,
        "sound": <str>,
        "alert": <str>,
        "apns": {
            "content-available": <bool>
            ...
        },
        ...
    },
    "filter": {
        "id": <str>,
        "name": <str>
    }
}

Message includes all of the message details. With each platforms specific options defined individually. Optional filters would allow for bulk notifications against devices matching the criteria.

Is this a feature that you would be interested in including in django-push-notifications?

jleclanche commented 7 years ago

Sure, sounds useful.

matthewh commented 7 years ago

What's your comfort level on adding an optional dependency django-filter to handle the device filtering? If you are using DRF, then django_filters would be required as well.

jleclanche commented 7 years ago

Seems unnecessary. I won't refuse it outright but it has to be justified.

matthewh commented 7 years ago

I do not associate devices with the django user model. Instead, the name field is set to the an identifier that is linked to a user account in another system. Essentially django-push-notifications runs by itself in a docker container and handles device registrations from iOS and Android clients and sends push notifications at the request of the backend infrastructure using a route like the one mentioned above.

We evaluated several other products (commercial and open source) in this space that could be self hosted. Many of them had deficiencies that we could not work around. Chiefly, allowing the same token to be present multiple times.

Given the current django-push-notifications model, ways to filter devices for sending a push message:

Given the extended model I use:

django-filter let's me easily add arbitrary filtering. I realize it's not complex but I would prefer not to reinvent the wheel.

jleclanche commented 7 years ago

Sorry, I thought i was in a different issue - that's what I get for juggling too many things at once.

Yes, depending on a DRF subdependency is fine within DRF itself. Make sure not to add the dependency in other parts of DPN.