代码之家  ›  专栏  ›  技术社区  ›  jordanthompson

发送带有数据的Firebase消息时出现问题

  •  0
  • jordanthompson  · 技术社区  · 7 年前

    我能够使用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)
    

    在第一种情况下,我在电话上的FirebaseMessagingService中按预期的onMessageReceived方法接收文本/消息。在第二种情况下(字典数据有效负载),从未接收到:

    @Override
    public void onMessageReceived(RemoteMessage remoteMessage) {
        super.onMessageReceived(remoteMessage);
        RemoteMessage.Notification data = remoteMessage.getNotification();
        System.out.print("here");
    }
    

    在这两种情况下,结果似乎都是成功的。

    欢迎您提出任何建议!

    1 回复  |  直到 7 年前
        1
  •  0
  •   jordanthompson    7 年前

    似乎有问题 multiple_devices_data_message

    我试过这个:

    result = push_service.single_device_data_message(registration_id=registration_tokens[0], data_message=payload)

    一切如期而至。所以现在要解决我的问题,我需要迭代每个注册令牌,调用 single_device_data_message 为每一个

    推荐文章