Open mirzadelic opened 7 years ago
+1
+1 Any news on this?
Guys, If anyone has that problem, try to fix that by putting a 'notification" payload as the example below .
That works for me when the iOS is in background. I think that is missing in the docs. The iOS only will get background push, if 'content_available': True, and content inside the 'notification' payload is set.
devices.send_message({'message': request.data['body'], 'title': title, 'type': 'chat', 'fromjid':request.data['fromjid']}, notification={ 'content_available': True, 'body': request.data['body'], 'title': title}, priority="high"), status = status.HTTP_200_OK)
cheers,
Thanks so much @claudiocleberson. It worked.
@hungnv132 @claudiocleberson,
I am trying the same for IOS, but it is not working for me. Below is my code:
user_phone = Device.objects.get(name='user1')
res = user_phone.send_message( { 'message':notification_message, 'type':'optyLost', 'notification':{ 'content_available':True, 'priority':'high', 'body':notification_message, 'category':'notification_category' } })
It is not sending notification to IOS device. Please help.
@joshisumit I think you pass wrong parameters to the method send_message
. Here is my way:
class UserDevice(AbstractDevice): def send_notification(self, message, title='Thông báo', sound='default', options): data = { 'title': title, 'message': message, 'type': 'chat' } notification = { 'title': title, 'body': message, 'sound': sound, 'content_available': True } return self.send_message(data=data, notification=notification, priority="high", options)
Thank you so much @hungnv132 It worked for me.
Does anyone have problem with iOS devices that they can't receive message from django-fcm? Android receives it, and when test from firebase console ios device receive message, just when using with django-fcm i can't get it work?