0

I am able to successfully send a title/text message using pyfcm:

result = push_service.notify_multiple_devices(registration_ids=registration_tokens, message_title="title",
                                                  message_body="testing")

But when I try to send a data message, it fails:

    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)

In the first case, I receive the text/message in my FirebaseMessagingService on the phone in the onMessageReceived method as expected. In the second case (dictionary data payload), it is never received:

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

In both cases, result seems to be a success.

Any suggestions would be most welcome!

Doug Stevenson
  • 297,357
  • 32
  • 422
  • 441
jordanthompson
  • 888
  • 1
  • 12
  • 29

1 Answers1

0

There seems to be a problem with multiple_devices_data_message

I tried this:

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

and it worked as expected. So to solve my problem for now, I will need to iterate over each registration token, calling single_device_data_message for each one

jordanthompson
  • 888
  • 1
  • 12
  • 29