Push notifications

Hi,

The when-then rule notifications work OK via email. But it seems that the notifications through app are never sent to the Android device.

I have the following warning on the openremote console:

manager_1 | 2022-10-18 10:28:49.138 WARNING [Messaging-NotificationQu…e-13] manager.notification.NotificationService : Error processing from REALM_RULESET - NOTIFICATION_HANDLER_CONFIG_ERROR (Handler is not valid: push): Notification{name=‘null’, message=PushNotificationMessage{title=‘test’, body=‘test’, action=org.openremote.model.notification.PushNotificationAction@67f55774, buttons=[org.openremote.model.notification.PushNotificationButton@5fea762b, org.openremote.model.notification.PushNotificationButton@60a5d6ae], data=null, priority=null, targetType=null, target=‘null’, ttlSeconds=null}, repeatFrequency=null, repeatInterval=‘null’, targets=[Target{type=ASSET, id=372y4sdaVL76jK2O3dgykk}]}

Is it necessary to add any parameters in the docker-compose.yml file for this to work?

Hi,

Yes you need a valid firebase config file as this is how the manager actually sends out the push notifications, you then need to compile your Android app with the matching config file.

We need to improve documentation around this; something for the list @Don

Hi,

Could you guide me a little on this point? What steps should be followed?

Thank you

This should help:

FCM (Firebase cloud messaging) documentation:

https://firebase.google.com/docs/cloud-messaging/

Here’s the manager env variable that determines where the FCM config file is located:

https://github.com/openremote/openremote/blob/master/profile/deploy.yml#L174

The Android app that is shown in the iOS and Play stores is in our public repo and you can browse the play services config file (this is where FCM is configured):

https://github.com/openremote/openremote/blob/master/console/android/GenericApp/app/google-services.json

The iOS app has a similar config file where APNS is relayed to FCM.

1 Like

Thanks! this is very helpful.

Hi!

I’ll ask again about this matter.

Is the fcm.json file the one downloaded when clicking on “Generate new private key” in the Firebase console, right?

It looks like this:

{
   "type": "service_account",
   "project_id": "openremote-xxxxxx",
   "private_key_id": "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx",
   "private_key": "-----BEGIN PRIVATE KEY-----xxxxx-----END PRIVATE KEY-----\n",
   "client_email": "iot-openremote-xxxxxxgserviceaccount.com",
   "client_id": "116865988193844564127",
   "auth_uri": "https://accounts.google.com/o/oauth2/auth",
   "token_uri": "https://oauth2.googleapis.com/token",
   "auth_provider_x509_cert_url": "https://www.googleapis.com/oauth2/v1/certs",
   "client_x509_cert_url": "https://www.googleapis.com/robot/v1/metadata/x509/iot-openremote-xxxxxx.gserviceaccount.com"
}

Once the file is added in deployment/manager/fcm.json, is it necessary to add this to the docker-compose.yml file?:

OR_FIREBASE_CONFIG_FILE: ${OR_FIREBASE_CONFIG_FILE:-/deployment/manager/fcm.json}

Yes that file is correct and putting it in that path should be sufficient; you should see during system startup logs that the PushNotificationHandler will try and initialise the credentials and show any errors.

Always worth remembering that if you’re using the standard deployment-data named docker volume then you will have to prune the previous deployment-data volume before any new changes will be picked up.

Hi Rich, I have the same configuration and my log is as shown below (after “when” is true):


I checked the FCM dashboard report and see no new notifications coming from the server. Can you help me?

Hi,

I don’t see any error message from the PushNotificationHandler in that log; look for your console asset and check that the providers contains something sensible in the push provider section.

You have definitely compiled the Android/iOS app with your own FCM config file?

Could also check that you can send notifications to your device using the firebase admin console.

1 Like

Oh, thanks for your response, PushNotificationHandler has no error, I think I’m doing something wrong on the notification receiving side. Thanks for help!