I have implemented the FCM exactly like documentation of if says:
I have a service like this
public class TCMessagingService extends FirebaseMessagingService
And I have declared it in manifest like so:
<service android:name=".services.TCMessagingService">
<intent-filter>
<action android:name="com.google.firebase.MESSAGING_EVENT" />
</intent-filter>
</service>
I target and compile with SDK level 25, and my firebase version is 10.2.1.
Now the problem is that on Android 8.0 sometimes I have huge delays when I receive push notifications. it can come after a few minutes. But this is not always so, sometimes things work just like expected, push notifications came very quickly.
I tried to update the FCM version to the last one but that did not help.
But when in the settings I turn off the battery optimization for my app everything works fine. But this is not a solution. What can I do to make FCM work as expected on Android 8.0?