【发布时间】:2019-01-15 03:26:45
【问题描述】:
我能够使用 pyfcm 成功发送标题/文本消息:
result = push_service.notify_multiple_devices(registration_ids=registration_tokens, message_title="title",
message_body="testing")
但是当我尝试发送数据消息时,它失败了:
payload = {
'action': 'testing',
'test number': 1,
'question': "what do you do with a klondike bar?",
}
result = push_service.multiple_devices_data_message(registration_ids=registration_tokens, data_message=payload)
在第一种情况下,我按预期通过 onMessageReceived 方法在电话上的 FirebaseMessagingService 中接收文本/消息。在第二种情况下(字典数据负载),它永远不会被接收到:
@Override
public void onMessageReceived(RemoteMessage remoteMessage) {
super.onMessageReceived(remoteMessage);
RemoteMessage.Notification data = remoteMessage.getNotification();
System.out.print("here");
}
在这两种情况下,结果似乎都是成功的。
欢迎提出任何建议!
【问题讨论】:
-
你能打印出第二种情况下
payload的实际值吗? -
payload = { 'action': 'testing', 'test number': 1, 'question': "你用克朗代克酒吧做什么?", }
-
Err... 负载项不应该包含在
notification或data父级中吗? -
我按照pypi.org/project/pyfcm 的指示进行操作。没有提及通知或数据父级。
标签: python firebase firebase-cloud-messaging pyfcm