FirebaseMessagingService onReceivedMessage (RemteMessage rm) is not called while the application service is disabled in oreo mode

In my Android app, I want to start the service through Push Notification while my app service is killed. This is done for versions below (prior to Nougat-7.1.1). But the problem is that in the Oreo version it does not work.

I added a link to create a channel id for the oreo version:
https://developer.android.com/guide/topics/ui/notifiers/notifications.html

When the application starts initially (after starting the application, I closed the application and stopped the service (). Again I try to send Push Notification from a third-party server to the device, no notification was received (the onMessageReceive () method is not called). In this case, the third-party server successfully sent push- notification.

How to fix this problem? Thanks at Advance!

My build.gradle:

android { compileSdkVersion 27 buildToolsVersion '26.0.2' defaultConfig { minSdkVersion 18 targetSdkVersion 27 multiDexEnabled true versionCode 1 versionName "1.0.9" ndk { abiFilters "armeabi", "armeabi-v7a", "x86", "mips" } } } 
+5
source share
3 answers

Check if you get the refreshedToken in the FirebaseInstanceIdService correctly, and also check API KEY .

 @Override public void onTokenRefresh() { super.onTokenRefresh(); // Get updated InstanceID token. String refreshedToken = FirebaseInstanceId.getInstance().getToken(); Log.d(TAG, "Refreshed token: " + refreshedToken); } 
0
source

I want to start the service through a push notification while my application service is in kill mode.

In Oreo, you cannot start a service when your application is in the background until its front service appears. You can only run front services when the application is closed or killed, otherwise it will throw an exception for regular services. A regular service will work when the application is in the foreground state.

To send a notification, try sending a notification through the Firebase console and check the weather whether it is received or not

0
source

the onMessageReceived () method is not called

If the server sends a notification payload, onMessageReceived() not called when the application is in the background or killed.

To always call onMessageReceived() , the server must always send data and load useful data.

When you use the notification payload - Firebase will create a notification on its own, analyzing the notification payload, and the data will be transmitted using the intent of the targeted activity when you click on the notification.

Previously, in version com.google.firebase:firebase-messaging:10.2.1 was a handleIntent(Intent intent) method, but later they deleted it and forced firebase to process it completely.

I want to start my service using Push Notification while my application service is dead.

You can not. See the documentation for more details. You must schedule a job to complete the action in the background.

About the notification payload.

It might look like this:

 { "data":{ "id": 1, "key": value "key_1": value1 }, "to": "target --fhiT7evmZk8:APA91bFJq7Tkly4BtLRXdYvqHno2vHCRkzpJT8QZy0TlIGs......" } 
0
source

Source: https://habr.com/ru/post/1275330/


All Articles