I'm searching for a way to send push notifications to devices from my django project. I want to send push notifications using pure python, with out third packages like django-gcm or python-gcm.
It is just an HTTP request to an endpoint. The docs explain how to use it. https://developers.google.com/cloud-messaging/downstream
Related
I want to develop an app that sends me an email when pricing offers for specific listings change using the AnyOfferChanged MWS notifications. However, I can't find any good documentation on how to go about receiving the notifications. Is it a must to have AWS SQS, or can I use Django? how do I go about subscribing to a notification?
I already have a developers account and I'm using the python mws library
You need to subscribe to the AnyOfferChangedNotification through the Subscriptions API and yes, it must use SQS. I found it easiest to use the scratchpad to create the subscription, since it's usually a one-time event.
Once your price change notifications start flowing into your queue, write an app that reads the queue and you can respond to your messages, including sending an email if that's what you want to do.
See if these code samples for SQS help you: https://docs.aws.amazon.com/code-samples/latest/catalog/code-catalog-python-example_code-sqs.html
I am having trouble finding an answer to this question.
I am looking for a framework where I can send a python function to a rest endpoint, and it sends a response upon completion.
If there is no precanned solution, what would be a good set of packages to use to do this?
Maybe you could try to use SocketIO with Celery.
SocketIO is an option to create a channel between clients (web, mobile apps, etc) and server.
When received a specific message (you can create you own protocol) you can call a task in a Message Queue using Celery framework with Redis or RabbitMQ.
Maybe you need to use an another framework called Kombu to be able to send a message using the connection in socketio.
You can find some tips on this link: http://python-socketio.readthedocs.io/en/latest/
I hope I could helped.
currently, I have a little script that receives a lot of information through various channels using ZeroMQ PUB-SUB sockets.
What i want to do is: receive the info with zmq, process it, and then, send it away through a WebSocket, in order to be able to use it in an AngularJS application, displaying real time information.
All the websocket libraries i have found for python work in an asynchronous way, where i can send messages as a responde to a message the browser send in advance. I don't want to send messages as a response, i want to stream all the information I am receiving, for any instance of my AngularJS app that might be running.
Thanks in advance.
EDIT: I forgot something. I found this How do I stream data through a flask application?, and got it working with flask, but it seems to only work with the flask app from which the websocket is created, i can't connect to it from angular.
One good example is on Miguel Grinberg blog here. He creates a flask backend and uses Angular on front-end.
After the browser open the channel, the back end can send messages any time, without any constraints related to timing.
What should be exact and most appropriate method to implement push notifications in django rest framework. DRF documentation doesn't explain it well.
Help me out with this one
Django REST framework is for creating API in django using built in django functionalities to retrieve request and serve response.
Django by itself doesn't support any protocol that will allow push notifications to be sent to client, so DRF also won't do that.
To create push notifications you have to use websockets, there are some third-party packages adding support of websockets to django. One of them is django-websocket-redis
If you are looking for push notification on the web (using web socket), you can try to use Firebase Cloud messaging (FCM, Firebase is free with certain usage threshold). What you need is adding code to your django server to request Firebase to send notifications.
If you are looking for push notifications on mobile devices, django-push-notifications package looks good, it even provide support for DRF to keep track of devices. On Android, this will also use FCM as well.
django-push-notifications is the one you are looking for. It is simple and can be implemented with few lines of code. It can be used for all android, iOS and web push notifications.
If you intend to use WebSocket to implement your own notification, you can check out channels
My Personal Favourite for this Purpose is: Django Notification! And Django Pushy!
Other Packages: django-push-notifications Django Activity Stream
Try using the django-instapush package. It is easily available to install via pip. This support all sql databases and also mongoDB via mongoengine to store device information. It has built-in models that can be used to store device information so this will work out of the box. Here is a little tutorial on sending django push notifications using django instapush.
You can Also use:
https://pypi.org/project/django-sns-mobile-push-notification/
You can also try with some other push providers. Infobip Push has some new things, for example you can track users by their locations and send push whenever they are apporaching some areas
If you project DRF was structured without asynchronous process in mind. You can try out django channels rest framework. you can easily pass asynch classes to you viewsets and make your endpoints behave like an asynchronous porcess.
I use https://github.com/mrjoes/sockjs-tornado for a Django app. I can send messages from javascript console very easy. But I want to create a signal in Django and send json string once the signal is active.
Could anyone give me a way to send a certain message in Python to sockjs-tornado socket server?
There are few options how to handle it:
Create simple REST API in your Tornado server and post your updates from Django using this API;
Use Redis. Tornado can subscribe to the update key and Django can publish updates to this key when something happens;
Use ZeroMQ (AMQP, etc) to send updates from the Django to the Tornado backend (variation of the 1 and 2).
In most of the cases, it is either first or second option. Some people prefer using 3rd option though.
I've wrote djazator, simple and easy to use django plugin. It uses zeromq for delivering messages from django to sockjs-tornado. Additionally, it can send messages to subset of authenticated django users.
I just put this up https://github.com/amagee/sockjs-client for talking directly to a SockJS server from Python (using xhr streaming).