Facing an issue with Firebase-messaging integration. For notifications I used firebase_unity_sdk - FirebaseMessaging. If I send message as a “notification” everything is working fine as per the documentation. If I send message as “data”, as per the documentation OnMessageReceived should call irrespective of application state(background or foreground or closed). But OnMessageReceived is getting called only if application is foreground(open state). Can you please help me in this.
JSONObject json = new JSONObject();
json.put( “to”, userDeviceIdKey.trim() );
JSONObject info = new JSONObject();
JSONObject data = new JSONObject();
info.put( “title”, “Notificatoin FCM” );
json.put( “notification”, info );
Above one is working fine , getting simple notification when application is closed or background and OnMessageReceived is getting called if app is in foreground.
JSONObject json = new JSONObject();
json.put( “to”, userDeviceIdKey.trim() );
JSONObject info = new JSONObject();
JSONObject data = new JSONObject();
data.put( “title”, “data FCM” );
json.put( “data”, data );
When I send above one (02), OnMessageReceived is not getting called if application is closed or in background.
I am not familiar with Firebase and the exact plugin you’re using, but on some platforms, if the app is not in the foreground it will not execute anything, including the code for handling any incoming messages.
Notifications I am able to receive and working fine. But for Customized notifications I want to create my own notification system. for that I am sending “data” payload from the server. OnMessageReceived method should catch that as per the documentation. But not getting triggered.
For me OnMessageReceived called when sending the notification from firebase console (checked the log while unity build is in foreground). But no notification is showing in the notification tray. How to enable that one.