I implemented FCM in the same way as the documentation if it says:
I have such a service
public class TCMessagingService extends FirebaseMessagingService
And I declared it in the manifest like this:
<service android:name=".services.TCMessagingService">
<intent-filter>
<action android:name="com.google.firebase.MESSAGING_EVENT" />
</intent-filter>
</service>
I am targeting and compiling with an SDK level of 25, and my version of firebase is 10.2.1.
Now the problem is that on Android 8.0 sometimes I have big delays when I receive push notifications. it may come in a few minutes. But this is not always the case, sometimes everything works the same as expected, push notifications arrived very quickly.
I tried updating the FCM version to the latest, but that didn't help.
But when in the settings I turn off battery optimization for my application, everything works fine. But this is not a solution. What can I do to make FCM work expected on Android 8.0?