django-push-notifications: Push notification are not sending out

I have tested with 3 cases.

  1. From admin module, I use ‘Send test message’
  2. I write my own view and send message to all

class PushNotification(APIView):
    permission_classes = (IsAuthenticated,)

    def post(self, request):

        data = request.data
        message = data['message']
        devices = APNSDevice.objects.filter()
        devices.send_message(message)

        return Response(status=status.HTTP_200_OK)

  1. I write my own view and send message to particular token

class PushNotificationToSpecificToken(APIView):
    permission_classes = (IsAuthenticated,)

    def post(self, request):

        data = request.data
        message = data['message']
        token = data['token']
        device = APNSDevice.objects.get(registration_id=token)
        device.send_message(message)

        return Response(status=status.HTTP_200_OK)

1 and 3 are still okay. It means my push certificate is working well. Problem is that when I send message to all user, it doesn’t send already. Last time, I only have like 10 devices and it is okay. Currently, I am testing with 100 devices and it is not okay already. How shall I do?

About this issue

  • Original URL
  • State: open
  • Created 8 years ago
  • Comments: 15 (4 by maintainers)

Most upvoted comments

Hey, I think I have a similar problem. There are 3 APNS devices shown on django admin page for my user:

  • iPhone1 (correct)
  • incorrect device (created manually by me by copying the data from another entry and modifying the Registration ID)
  • iPhone2 (correct)

Both iPhones are separate physical devices. When I select ‘Send test message’ from django admin page (all 3 devices are selected) then both iPhones receive the message. However, when I select ‘Send test message in bulk’ (again, all 3 devices are selected), only iPhone1 receives the message. If I select only the two correct devices or I set Is active to false for the incorrect device, then both iPhones receive the bulk message correctly.

It seem that django-push-notifications are trying to send bulk messages in order the devices appear on django admin page and if any error occurs the whole process stops. Please let me know if this issue is related the one reported by @khantthulinn and what can be done to fix it? Is there an option for apns_send_bulk_message to ignore the errors or do I have to use the for loop each time I send multiple notifications? Or maybe I can somehow detect the incorrect registration ids and remove them from the database before I send the notifications?

Has anybody found a solution on this issue?

My experience is that when I select all devices on admin and select “Send test message in bulk” the iOS devices can receive a push notification message. But if it’s triggered on command line or cron job or in Django shell the iOS devices can’t receive any push notifications.

Thanks,