I use Django and Gunicorn to power my front end iOS applications. Up until now, I've been using simple GET, PUT, POST requests to send and receive json data from my iOS application to my Django server and vice versa.
This setup has been solid however, I would like to implement real time messaging. When I first started out, I used APNS (Apple's Push Notifications Service) to deliver messages real time to recipients. Here is an example of what I used to do:
If UserA messaged UserB, I would send the message to the Django Server via JSON, process it in a Django view, use pyAPNS - a python wrapper for APNS and it would send a push notification to UserB (the recipient) along with a payload size of 256 bytes. This worked well however it also has a few cons.
If the recipient chooses to disable push notifications, then they will not receive the message. When you implement core data in your iOS app, this can be quite messy if you cache objects.
So this leaves me with another option. Building something that is socket based that can work with Django and send the payload as JSON. Any ideas?
What is Django Channels? Django Channels (or just Channels) extends the built-in capabilities of Django allowing Django projects to handle not only HTTP but also protocols that require long-running connections, such as WebSockets, MQTT (IoT), chatbots, radios, and other real-time applications.
What is Django? Django is a Python framework that makes it easier to create web sites using Python. Django takes care of the difficult stuff so that you can concentrate on building your web applications.
Have you taken a look here:
https://pypi.python.org/pypi/django-socketio/
or here:
http://maxburstein.com/blog/realtime-django-using-nodejs-and-socketio/
or here:
https://www.djangopackages.com/grids/g/websockets/
It is possible to do.
Also, I don't see why real-time messaging has to be parsed within django itself. You could simply implement some node.js type server to handle this for you, with the iOS app pulling in data via different APIs. This will work, unless you need to keep messaging data attached to the other data.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With