Giter Site home page Giter Site logo

push-notifications-async's Introduction

Push notifications boilerplate.

This is minimalistic setup for sending asynchronous push notifications in django using django-rest-framework. Components used:

How to run

If you have docker and docker-compose installed, simply go to the project main directory and type docker-compose up -d. Project is now running on port 4000 on your localhost. Go to the http://localhost:4000/notifications/test/ to send test push.

Usage

Main advantage of this setup is sending push notifications to all user's devices asynchronously. First, read the docs of django-push-notifications package to know how to register user's device. Then you can use push_to_all_devices task to push notification to all user's devices.

Example: views.py

from rest_framework.decorators import api_view
from rest_framework.response import Response

from notifications.tasks import push_to_all_devices


@api_view(['POST'])
def send_test_push(request):
    receiver_id = request.POST['receiver_id']
    message = request.POST['message']
    push_to_all_devices.delay(message, receiver_id)
    return Response(data={'info': 'Push notification sent.'})

urls.py

from django.conf.urls import include, url
from django.contrib import admin

from .views import send_test_push

urlpatterns = [
    url(r'^admin/', admin.site.urls),
    url(r'^notifications/', send_test_push, name='test-push'),
]

push-notifications-async's People

Contributors

hidalgopl avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.