FCM message not sent from skygear server


#1

Hi,

We are having an issue receiving the FCM notification messages from the skygear server to the Android application. Skygear server version used is 1.7.2. There is one environment using the Skygear.io and the other deployed on our server and both are not working. They are configured with the service account json and the connection of the Android app to Firebase is verified working.

Configured properties on the server:
FCM_ENABLE : “true”
FCM_TYPE : service_account
FCM_SERVICE_ACCOUNT_KEY_PATH :

On our server we get the following log when a message is sent from the web app and a notification message is attempted to be compiled and sent:

time=“2019-10-22T11:52:21Z” level=info msg=“Received a notify” logger=skydb pqNotification="&{7772 record_change 21903}" process=server tag=skydb
time=“2019-10-22T11:52:21Z” level=info msg=“Sending notification to device token = ehhwUXuh718:APA91bG8swc-8CLQ369h9ij5bROzCIitEyo2gaJ7NGlCPuU5r3ba7ZSeY5wpEZb8mnxf5Q856Va-Kaksz5vU49HuHdTapYU0Hms-o1hCLnnIm-rTzIIGJC6J_TMm-b4WMMYHmDQfs89B”
time=“2019-10-22T11:52:21Z” level=error msg=“fcm/key: failed to convert fcm message: fcm: payload has no fcm dictionary” logger=push process=server tag=push
time=“2019-10-22T11:52:21Z” level=warning msg=“Failed to send notification: fcm: payload has no fcm dictionary\n”

Thanks and regards,
Aleks


#2

Hi Skygear

Can you please help us? We need to fix this ASAP. Do you need anymore details?

Thank you a lot.

Kind regards
Kevin


#3

Hi @aveljanov @kevin.seidler

From the server log, it looks like fcm is missing in the push notification request payload. In the notification argument, fcm is required.

container = SkygearContainer(api_key="your-api-key")
user_id = "user-id"
notification = {
    'fcm': {
         'notification': {
              'title': title,
              'body': message,
          }
    }
}

response = push_user(container, user_id, notification)

To send push notification in cloud code, you can reference to following guides:

Sending push notification in python cloud code: https://docs.skygear.io/guides/cloud-function/calling-skygear-api/python/#push-notifications
Sending push notification in JS cloud code: https://docs.skygear.io/guides/cloud-function/calling-skygear-api/js/#push-notifications

Hope this help!

Carmen