GithubHelp home page GithubHelp logo

Only one device by user about fcm-django HOT 5 CLOSED

xtrinch avatar xtrinch commented on May 27, 2024
Only one device by user

from fcm-django.

Comments (5)

Pablo849 avatar Pablo849 commented on May 27, 2024 1

That's great, thanks for the effort. Thank you all for the contributions as well. Greetings.

from fcm-django.

xtrinch avatar xtrinch commented on May 27, 2024

Although you haven't mentioned how exactly your application should respond when a user with a registered device tries to register a new one:

When the user wants to register a new device, delete the old device from the same user.

Perhaps register a django pre-save handler and in it delete the old device.

from fcm-django.

BojanKogoj avatar BojanKogoj commented on May 27, 2024

You can also only use the last added device, though this could lead to weird issues

device = FCMDevice.objects.filter(user=user, active=True).last()

Or you could do what @xtrinch suggested, except in my example I use post_save

@receiver(post_save, sender=FCMDevice, dispatch_uid="my_unique_identifier")
def clean_old_devices(sender, instance, created, **kwargs):
    FCMDevice.objects.filter(user=instance.user, active=True).exclude(pk=instance.pk).delete()

from fcm-django.

xtrinch avatar xtrinch commented on May 27, 2024

I think this could probably be added to fcm-django settings and deleted within the package, since there seems to be a need for it.

from fcm-django.

xtrinch avatar xtrinch commented on May 27, 2024

I've added additional settings: ONE_DEVICE_PER_USER and DELETE_INACTIVE_DEVICES, with which you should be able to achieve all the above mentioned. Will be releasing a new version soon.

from fcm-django.

Related Issues (20)

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.