我在 django 项目中使用 django-push-notification 包,
在 android 中,json 响应应采用以下格式:
{ "data": { "title" : "You have a notification", "body" : "The body of the notification", "id" : 1234,
"backgroundImage" : "assets/notifications/background.png", },
"notification" : { "alert" : "You have a notification", "title" : "You have a notification",
"body" : "The body of the notification", "sound" : "default",
"backgroundImage" : "assets/notifications/background.png", "backgroundImageTextColour" : "#FFFFFF" } }
这样只有android才能获得前台和后台通知。
我尝试了代码:
视图.py -
from push_notifications.models import APNSDevice, GCMDevice
try:
fcm_device = GCMDevice.objects.all()
fcm_device.send_message("new-notification-out",title="title-out",\
extra={"data": { "title-data" : "title-in", "body" : "new-notification-in" }, \
"notification" : { "alert" : "You have one new notice", "title" : "title-notify",\
"body" : "new-notification" }})
except:
pass
但是在android端没有得到有效载荷“数据”,“通知”,我怎样才能从后端准确地发送有效载荷?