2

I need to obtain firebase push notifications in my android app, when app is on foreground and background. For this i use the next class:

public class FirebaseDataReceiver extends WakefulBroadcastReceiver {
    public void onReceive(Context context, Intent intent) {
        // work with data from intent and show notification...
        abortBroadcast(); // for disabling double pushes
    }
}

It works good on android lower than 8.0 (oreo). Device receives pushes successful when app on background(destroyed) or foreground. BUT, on android O (I tested on the many devices), when app is on background, every push shows notification not from my code in onReceive method. And in fact when app is on background i see two notifications when i receive only one push. And its so bad. So, how to resolve this problem? I know, that WakefulBroadcastReceiver is deprecated for 8 android sdk, so what is the alternatives for this? I only found that i must use Firebase JobService, but there is no normal examples in interntet how to receive push notifications with this. So, help me please.

Alex D.
  • 1,424
  • 15
  • 40
  • please Check [this answer](https://stackoverflow.com/a/38795553/7437508) i think that same problem – Hossam elsawy Nov 09 '17 at 15:16
  • Thanks, i checked your answer. But it doesnt help me, because i have no access to server-side and firebase console of this app. And i cant change push entities kind. – Alex D. Nov 09 '17 at 21:13

0 Answers0