Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

iOS payload problem #33

Open
mirzadelic opened this issue Dec 25, 2016 · 7 comments
Open

iOS payload problem #33

mirzadelic opened this issue Dec 25, 2016 · 7 comments

Comments

@mirzadelic
Copy link

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?

@danielchristopher1
Copy link

+1

@nwvaras
Copy link

nwvaras commented Jul 30, 2017

+1
Any news on this?

@claudiocleberson
Copy link

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,

@hungnv132
Copy link

Thanks so much @claudiocleberson. It worked.

@joshisumit
Copy link

@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.

@hungnv132
Copy link

hungnv132 commented Sep 27, 2017

@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)

@joshisumit
Copy link

Thank you so much @hungnv132 It worked for me.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

6 participants